The following is a list of 'Position' objects.
[Position(account='U3953931', contract=Forex('AUDUSD', conId=14433401, localSymbol='AUD.USD', tradingClass='AUD.USD'), position=100.0, avgCost=0.70995),
Position(account='U3953931', contract=Stock(conId=211651685, symbol='URA', exchange='ARCA', currency='USD', localSymbol='URA', tradingClass='URA'), position=-20.0, avgCost=23.06155705)]
How can I extract the -20.0 value given that I'm looking for the position within the URA symbol?
I managed to make this:
positions[1][2]
That returns the -20.0
probably not very elegant but this works:
for i in range(0, len(positions)):
if positions[i].contract.symbol == Stock_Symbol:
print(positions[i].position)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.