Author Topic: Bitshares JS market trade history  (Read 293 times)

0 Members and 1 Guest are viewing this topic.

Offline Victor118

Bitshares JS market trade history
« on: December 17, 2018, 09:13:17 am »
Hi,
I would like to retrieve market history.
I'm trying with  :

Code: [Select]
Apis.instance().db_api().exec( "get_trade_history", [ base,quote,dateStart,dateEnd, 100 ] );
But i got an error :
Quote
basic_string::at: __n (which is 0) >= this->size() (which is 0): basic_string::at: __n (which is 0) >= this->size() (which is 0): unable to convert ISO-formatted string to fc::time_point_sec


Here is dateStart and dateEnd format :

Quote
2018-11-17 10:02:43
 2018-12-17 10:02:43

Someone can help me please ?

 Is there a better way to get history price for a chart, may be an OHLC format ?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12793
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: Bitshares JS market trade history
« Reply #1 on: December 17, 2018, 02:10:55 pm »
Try this format:

2018-12-17T15:00:00

note that **T** in the middle
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline Victor118

Re: Bitshares JS market trade history
« Reply #2 on: December 17, 2018, 02:31:37 pm »
Great, it works, thank you.

But I don't know why I have an empty array as result for :

Code: [Select]
Apis.instance().db_api().exec( "get_trade_history", [ "BTS","USD","2018-12-16T15:09:11","2018-12-17T15:09:11",100 ] );


Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12793
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: Bitshares JS market trade history
« Reply #3 on: December 17, 2018, 04:14:36 pm »
This is a query that returns a result for me:

{"method": "call", "params": [0, "get_trade_history", ["BTS", "USD", "2018-12-17T16:13:49", "2018-12-16T16:13:49", 10]], "jsonrpc": "2.0", "id": 3}

It requires the market_plugin to be enabled on the backend. Try against "wss://node.bitshares.eu"
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline Victor118

Re: Bitshares JS market trade history
« Reply #4 on: December 18, 2018, 11:13:13 am »
Ok I just found why I had an empty array, it seems that params order is dateEnd then dateStart like you did.
But the documentation of bitsharesjs-ws is :
https://github.com/bitshares/bitsharesjs-ws

Quote
get_trade_history   [string base, string quote, date start, date stop, int limit]



Thanks


Offline Digital Lucifer

  • Global Moderator
  • Full Member
  • *****
  • Posts: 180
  • 13 years of being Slackware abUser
    • View Profile
    • BitShares 2.0
  • BitShares: steem-not
  • GitHub: dls-cipher
Re: Bitshares JS market trade history
« Reply #5 on: December 23, 2018, 07:46:00 am »
Ok I just found why I had an empty array, it seems that params order is dateEnd then dateStart like you did.
But the documentation of bitsharesjs-ws is :
https://github.com/bitshares/bitsharesjs-ws

Quote
get_trade_history   [string base, string quote, date start, date stop, int limit]



Thanks

Keep in mind that repo and documentation is few months out-of-date :)))
Milos (Mike) Preocanin - General Manager @ Syntek Solutions
TOANDI Co., LTD. (BOI Approved) - TAX ID: 0205549016913 - 95/5 Moo 4 Siam Country Club Rd.
Nong Prue, Bang Lamung, Chonburi 20250, Thailand.