郎朗坤
当您遇到这样的情况时,我建议您使用 Python 内省工具,例如dir(open_bid)和type(open_bid)来找出您正在查看的内容!基于对源代码的快速阅读,我怀疑您正在查看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_idhttps://github.com/yanagisawa-kentaro-777/pybitmex/blob/08e6c4e7ae7bbadd5208ec01fd8d361c3a0ce992/pybitmex/models.py#L33有关内省 Python 中发生的事情的方法的更多信息:https://docs.python.org/3/library/functions.html?highlight=dir#dirhttps://docs.python.org/3/library/functions.html?highlight=dir#localshttps://docs.python.org/3/library/functions.html?highlight=dir#globalshttps://docs.python.org/3/library/functions.html?highlight=dir#varshttps://docs.python.org/3/library/inspect.html
慕娘9325324
查看函数的文档字符串: """ [{'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'])