Author Topic: pybitshares, historic trades() data & 100 limit?  (Read 2828 times)

0 Members and 1 Guest are viewing this topic.

Offline kwacorn

  • Newbie
  • *
  • Posts: 7
    • View Profile
This is exactly what you need to do ...
Thank you for your guidance, much appreciated.

if you want the data for a chart, you may want to look into another call that uses "buckets" ..
I tried searching for the "buckets" you refer to but without success, could you give a URL for the information on the buckets and call to which you refer?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Quote
I could put the trades() function in a loop and repeatedly call it for different start= and stop= datetimes until I have all the trade data, but that seems a crude workaround, so I was wondering if those with more knowledge and experience in this area could suggest any better approaches?  Is it possible to adjust the internal limit of 100 to a much higher value?
This is exactly what you need to do .. for performance reasons, the backend api does not provide more than 100 items on the corresponding call.
if you want the data for a chart, you may want to look into another call that uses "buckets" ..

Offline Brekyrself

  • Hero Member
  • *****
  • Posts: 514
    • View Profile
@xeroc should be able to assist with this question.

Offline kwacorn

  • Newbie
  • *
  • Posts: 7
    • View Profile
I am having my first venture into using pybitshares. I would like to obtain the historic market trade data for a trading pair, eg. BTS:ETH or other pairs, for up to their entire trading history.

The trades(limit=25, start=None, stop=None) function from the class bitshares.market provides the data I am interested in, however it appears there is an internal limit of 100 on the limit= parameter as if I try anything larger I get the following error:

Code: [Select]
---------------------------------------------------------------------------
RPCError                                  Traceback (most recent call last)
/usr/lib/python3.6/site-packages/bitsharesapi/bitsharesnoderpc.py in rpcexec(self, payload)
     41             # Forward call to GrapheneWebsocketRPC and catch+evaluate errors
---> 42             return super(BitSharesNodeRPC, self).rpcexec(payload)
     43         except exceptions.RPCError as e:

/usr/lib/python3.6/site-packages/grapheneapi/graphenewsrpc.py in rpcexec(self, payload)
    159             else:
--> 160                 raise RPCError(ret['error']['message'])
    161         else:

RPCError: Assert Exception: limit <= 100:

During handling of the above exception, another exception occurred:

UnhandledRPCError                         Traceback (most recent call last)
<ipython-input-6-7d79ce4640e5> in <module>()
      2 t2 = datetime(2017, 8, 12)  # to stop time
      3
----> 4 market.trades(start=t1, stop=t2, limit=101)

/usr/lib/python3.6/site-packages/bitshares/market.py in trades(self, limit, start, stop)
    269             formatTime(stop),
    270             formatTime(start),
--> 271             limit)
    272         return list(map(
    273             lambda x: FilledOrder(

/usr/lib/python3.6/site-packages/grapheneapi/graphenewsrpc.py in method(*args, **kwargs)
    193                      "jsonrpc": "2.0",
    194                      "id": self.get_request_id()}
--> 195             r = self.rpcexec(query)
    196             return r
    197         return method

/usr/lib/python3.6/site-packages/bitsharesapi/bitsharesnoderpc.py in rpcexec(self, payload)
     48                 raise exceptions.NoMethodWithName(msg)
     49             elif msg:
---> 50                 raise exceptions.UnhandledRPCError(msg)
     51             else:
     52                 raise e

UnhandledRPCError: Assert Exception: limit <= 100:


I could put the trades() function in a loop and repeatedly call it for different start= and stop= datetimes until I have all the trade data, but that seems a crude workaround, so I was wondering if those with more knowledge and experience in this area could suggest any better approaches?  Is it possible to adjust the internal limit of 100 to a much higher value?

Also I was wondering if the internal 100 limit was a legacy of the development process and someone forgot about it, as I might do, or if it was to limit server load, though it does seem a low value to limit it to?
« Last Edit: September 26, 2017, 03:20:20 pm by kwacorn »