map_onchain_asset_to_position#
API documentation for tradeexecutor.strategy.asset.map_onchain_asset_to_position Python function.
- map_onchain_asset_to_position(asset, state)[source]#
- Map an on-chain found asset to a trading position. - Any reserve currency deposits go to the reserve 
- Any trading position assets go to their respective open trading and frozen position 
- If there are trading position assets and no position is open, then panic 
- Always check reserve first 
- If multiple positions are sharing the asset e.g. collateral return the firs position 
 - Parameters:
- asset (AssetIdentifier) – On-chain read token we should make 
- state (State) – The current strategy state 
 
- Returns:
- The position we think the asset belongs to. - None if there is no reserve, open or frozen positions we know of. 
- Return type:
- tradeexecutor.state.position.TradingPosition | tradeexecutor.state.reserve.ReservePosition | None