我正在尝试使用持有的特定股票的数量作为变量。
我的相关代码是:
def position(self, account, contract, position, avgCost):
super().position(account, contract, position, avgCost)
print(contract, position)
# self.quantity_held = position
# if contract == 'applestock_contract':
# self.quantity_held = position
if contract == app.applestock_contract:
self.applestock_quantity_held = position # this was previously just "position", no "app."
# if contract == 'app.applestock_contract':
# self.quantity_held = position
我已经评论了我尝试过的其他代码。
当我尝试打印 applestock_contract 的值时,它显示为 0(但这是不正确的)。