credmark.cmf.types.portfolio.Portfolio
- DTO class Portfolio(*, positions=[])[source]
Bases:
IterableListGenericDTO[Position]
Show JSON schema
{ "title": "Portfolio", "type": "object", "properties": { "positions": { "title": "Positions", "description": "List of positions", "default": [], "type": "array", "items": { "$ref": "#/definitions/Position" } } }, "examples": [ { "positions": [ { "amount": "4.2", "token": { "address": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9" } } ] }, { "positions": [ { "amount": "4.2", "token": { "symbol": "AAVE" } } ] }, { "positions": [ { "amount": "4.2", "token": { "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984" } } ] }, { "positions": [ { "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" } ] }, "Position": { "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" } } ] } } }
- Config
schema_extra: dict = {‘examples’: [{‘positions’: [{‘amount’: ‘4.2’, ‘token’: {‘address’: ‘0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9’}}]}, {‘positions’: [{‘amount’: ‘4.2’, ‘token’: {‘symbol’: ‘AAVE’}}]}, {‘positions’: [{‘amount’: ‘4.2’, ‘token’: {‘address’: ‘0x1F98431c8aD98523631AE4a59f267346ea31F984’}}]}, {‘positions’: [{‘amount’: ‘4.2’, ‘token’: {‘address’: ‘0x1F98431c8aD98523631AE4a59f267346ea31F984’, ‘abi’: ‘(Optional) contract abi JSON string or list’}}]}]}
- Fields
- Parameters
positions (list[credmark.cmf.types.position.Position]) –
- Return type
None
- field positions: list[credmark.cmf.types.position.Position] = []
List of positions
- append(obj)
- extend(obj)
- get_value(block_number=None, quote=None)[source]
- Returns
The value of the portfolio using the price_model.
- Raises
ModelDataError – if no pools available for a position’s price data.