from docs:
http://docs.pybitshares.com/en/latest/market.html?highlight=cancel#bitshares.market.Market.cancel
cancel(orderNumber, account=None)¶
Cancels an order you have placed in a given market.
Requires only the "orderNumber". An order number takes the form 1.7.xxx.
Parameters: orderNumber (str) – The Order Object ide of the form 1.7.xxxx
how can I get orderNumber actively while placing an order?
how can I get orderNumber after the fact for all outstanding orders?
I attempted
print(ACCOUNT.openorders)
and
for order in MARKET.accountopenorders():
print (order)
and this gives the order amount and price... but not orderNumber
thanks
spent several hours today trying to figure this out...
came here posted question... few minutes later figured it out
:D
found a snippet that helped
def cancelall(self):
""" Cancel all orders of this bot
"""
if self.orders:
return self.bitshares.cancel(
[o["id"] for o in self.orders],
account=self.account
https://github.com/xeroc/stakemachine/blob/master/stakemachine/basestrategy.py
so I can do:
for order in MARKET.accountopenorders():
print (order['id'])
works!
this should really be added to pybitshares docs
BTS litepresence1
this should be helpful:
for order in MARKET.accountopenorders():
#print(MARKET.cancel(order['id']))
print ('id', order['id'])
print ('price', 1/float(order['price']))
print ('asset', str(order['base']).split(' ')[1])
print ('currency', str(order['quote']).split(' ')[1])
print ('amount', str(order['base']).split(' ')[0])
returns:
id 1.7.5565xxxx
price 0.777
asset BTS
currency USD
amount 2.00000
Sorry for the late reply and glad you figured this out.
As a remark, allmost all objects in pybitshares behave like a dictionary, that means you may obtain more data from picking a key. You can get a list of the full data by 'print(order.items())' .. Or, respectively, 'print(account.items())' and so on