2 回答

TA貢獻1921條經(jīng)驗 獲得超9個贊
當您遇到這樣的情況時,我建議您使用 Python 內(nèi)省工具,例如dir(open_bid)和type(open_bid)來找出您正在查看的內(nèi)容!
基于對源代碼的快速閱讀,我懷疑您正在查看
class OpenOrder:
def __init__(self, order_id, client_order_id, side, quantity, price, timestamp):
self.order_id = order_id
self.client_order_id = client_order_id
self.side = side
self.quantity = quantity
self.price = price
self.timestamp = timestamp
def __str__(self):
return "Side: {}; Quantity: {:d}; Price: {:.1f}; OrderID: {}; ClOrdID: {}; Timestamp: {}; ".format(
self.side, self.quantity, self.price, self.order_id, self.client_order_id,
self.timestamp.strftime("%Y%m%d_%H%M%S")
)
所以你可能想要open_bid.order_id
https://github.com/yanagisawa-kentaro-777/pybitmex/blob/08e6c4e7ae7bbadd5208ec01fd8d361c3a0ce992/pybitmex/models.py#L33
有關(guān)內(nèi)省 Python 中發(fā)生的事情的方法的更多信息:
https://docs.python.org/3/library/functions.html?highlight=dir#dir
https://docs.python.org/3/library/functions.html?highlight=dir#locals
https://docs.python.org/3/library/functions.html?highlight=dir#globals
https://docs.python.org/3/library/functions.html?highlight=dir#vars
https://docs.python.org/3/library/inspect.html

TA貢獻1783條經(jīng)驗 獲得超4個贊
查看函數(shù)的文檔字符串:
"""
[{'orderID': '57180f5f-d16a-62d6-ff8d-d1430637a8d9',
'clOrdID': '', 'clOrdLinkID': '',
'account': XXXXX, 'symbol': 'XBTUSD', 'side': 'Sell',
'simpleOrderQty': None,
'orderQty': 30, 'price': 3968,
'displayQty': None, 'stopPx': None, 'pegOffsetValue': None,
'pegPriceType': '', 'currency': 'USD', 'settlCurrency': 'XBt',
'ordType': 'Limit', 'timeInForce': 'GoodTillCancel',
'execInst': 'ParticipateDoNotInitiate', 'contingencyType': '',
'exDestination': 'XBME', 'ordStatus': 'New', 'triggered': '',
'workingIndicator': True, 'ordRejReason': '', 'simpleLeavesQty': None,
'leavesQty': 30, 'simpleCumQty': None, 'cumQty': 0, 'avgPx': None,
'multiLegReportingType': 'SingleSecurity', 'text': 'Submission from www.bitmex.com',
'transactTime': '2019-03-25T07:10:34.290Z', 'timestamp': '2019-03-25T07:10:34.290Z'}]
"""
這表明它返回一個字典列表,而不是一個對象。沒有bids您需要訪問的屬性。
open_orders = bitmex.ws_open_order_objects_of_account()
for order in open_orders:
print(order['price'])
添加回答
舉報