我有这个代码,我需要将最后的价格存储在一个变量中,我该怎么办?
class IBapi(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def tickPrice(self, reqId, tickType, price, attrib):
if tickType == 2 and reqId == 1:
print('The current ask price is: ', price)
app = IBapi()
app.connect('127.0.0.1', 7497, 123)
#Create contract object
apple_contract = Contract()
apple_contract.symbol = 'AAPL'
apple_contract.secType = 'STK'
apple_contract.exchange = 'SMART'
apple_contract.currency = 'USD'
app.reqMktData(1, apple_contract, '', False, False, [])
我需要将当前价格保存在一个变量中