Author Topic: pybitshares: how do I get orderNumber in 1.7.xxxx format?  (Read 1854 times)

0 Members and 1 Guest are viewing this topic.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
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

Offline litepresence

this should be helpful:


Code: [Select]
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:
Code: [Select]
id 1.7.5565xxxx
price 0.777
asset BTS
currency USD
amount 2.00000
« Last Edit: February 21, 2018, 03:02:49 pm by litepresence »

Offline litepresence

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

Code: [Select]
    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:

Code: [Select]
for order in MARKET.accountopenorders():
    print (order['id'])


works!

this should really be added to pybitshares docs


BTS litepresence1
« Last Edit: February 21, 2018, 01:02:18 am by litepresence »

Offline litepresence

from docs:

http://docs.pybitshares.com/en/latest/market.html?highlight=cancel#bitshares.market.Market.cancel
Code: [Select]
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

Code: [Select]
print(ACCOUNT.openorders)
and

Code: [Select]
for order in MARKET.accountopenorders():
    print (order)

and this gives the order amount and price... but not orderNumber


thanks