credmark.cmf.types.position.Position
- DTO class Position(*, amount=0.0, asset, price_quote=None, value=None)[source]
Bases:
BaseModel
Show JSON schema
{ "title": "Position", "type": "object", "properties": { "amount": { "title": "Amount", "description": "Quantity of token held", "default": 0.0, "type": "number" }, "asset": { "$ref": "#/definitions/Token" }, "price_quote": { "$ref": "#/definitions/PriceWithQuote" }, "value": { "title": "Value", "type": "number" } }, "required": [ "asset" ], "examples": [ { "amount": "4.2", "token": { "address": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" } }, { "amount": "4.2", "token": { "symbol": "AAVE" } }, { "amount": "4.2", "token": { "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984" } }, { "amount": "4.2", "token": { "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "abi": "(Optional) contract abi JSON string or list" } } ], "definitions": { "Token": { "title": "Token", "description": "Fungible Token that conforms to ERC20 standards.\nYou could create a token with the following\n\n t = Token(symbol='CMK')\n\n t = Token(address='0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')\n\n t = Token('CMK')\n\n t = Token('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')", "type": "object", "properties": { "address": { "title": "Address", "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$", "format": "evm-address" } }, "required": [ "address" ], "examples": [ { "address": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" }, { "symbol": "AAVE" }, { "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984" }, { "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "abi": "(Optional) contract abi JSON string or list" } ] }, "PriceWithQuote": { "title": "PriceWithQuote", "type": "object", "properties": { "price": { "title": "Price", "description": "Value of one Token", "default": 0.0, "type": "number" }, "src": { "title": "Src", "description": "Source", "type": "string" }, "quoteAddress": { "title": "Quoteaddress", "description": "The address of quoted currency", "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$", "format": "evm-address" } }, "required": [ "quoteAddress" ], "examples": [ { "price": 4.2, "quoteAddress": "0x0000000000000000000000000000000000000348" }, { "price": 4.2, "src": "uniswap-v3", "quoteAddress": "0x0000000000000000000000000000000000000348" } ] } } }
- Config
schema_extra: dict = {‘examples’: [{‘amount’: ‘4.2’, ‘token’: {‘address’: ‘0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9’}}, {‘amount’: ‘4.2’, ‘token’: {‘symbol’: ‘AAVE’}}, {‘amount’: ‘4.2’, ‘token’: {‘address’: ‘0x1F98431c8aD98523631AE4a59f267346ea31F984’}}, {‘amount’: ‘4.2’, ‘token’: {‘address’: ‘0x1F98431c8aD98523631AE4a59f267346ea31F984’, ‘abi’: ‘(Optional) contract abi JSON string or list’}}]}
- Fields
- Validators
- Parameters
amount (float) –
asset (Token) –
price_quote (credmark.cmf.types.price.PriceWithQuote | None) –
value (float | None) –
- Return type
None
- field price_quote: credmark.cmf.types.price.PriceWithQuote | None = None
- get_value(price_model='price.quote', block_number=None, quote=None)[source]
- Returns
The value of the position using the price_model.
- Raises
ModelDataError – if no pools available for price data.
- Return type