drpout / boilr

Price alarms for Bitcoin, cryptocurrencies, cryptoassets, futures and options.
http://boilr.mobi
GNU General Public License v3.0
128 stars 67 forks source link

Add BitShares Decentralized Exchange aka OpenLedger #236

Open dllud opened 8 years ago

dllud commented 8 years ago

In a BitShares full node we can use the Database API to query all the info we need in Boilr: list of traded pairs and last price.

There are two ways to access the API: JSON-RPC and Websocket.

As detailed elsewhere, we should not use the long-lived Websocket connections due to the power and data restrictions of a mobile environment. As such we would like to refrain from adding code to interface with Websocket APIs.

Fortunately there are a couple of BitShares' public full nodes, allowing calls to their JSON-RPC interfaces via simple HTTP POST requests. The endpoints are: https://bitshares.openledger.info/ws and https://dele-puppy.com/ws.

I am able to call the list_assets function and retrieve a list of traded pairs (aka assets):

curl --silent --data '{"jsonrpc": "2.0", "id": 1, "method": "list_assets", "params": ["Z", 2]}' https://bitshares.openledger.info/ws | aeson-pretty

Unfortunately I get errors with both functions that could retrieve the last price. get_ticker seems to be undefined:

curl --silent --data '{"jsonrpc": "2.0", "id":1, "method":"get_ticker", "params":["BLOCKPAY","BTS"]}' https://bitshares.openledger.info/ws | aeson-pretty

[...]
"message": "10 assert_exception: Assert Exception\nitr != _by_name.end(): no method with name 'get_ticker'
[...]

While get_trade_history always returns an empty result:

curl --silent --data '{"jsonrpc": "2.0", "id":1, "method":"get_trade_history", "params":["BLOCKPAY","BTS","2015-01-01T00:00:00","2016-10-01T21:06:06",100]}' https://bitshares.openledger.info/ws | aeson-pretty

{
    "result": [],
    "id": 1
}

Perhaps these two functions are only available through Websocket? That would be a shame...

I am trying to some get help at bitsharestalk.org but I'm facing issues while registering a new account.

dllud commented 7 years ago

get_ticker is now working, we can add this exchange to libdynticker.

curl --silent --data '{"jsonrpc": "2.0", "id":1, "method":"get_ticker", "params":["BLOCKPAY","BTS"]}' https://bitshares.openledger.info/ws | aeson-pretty
{
    "result": {
        "highest_bid": "0.04000707970749844",
        "base_volume": "296.10489999999998645",
        "base": "BLOCKPAY",
        "quote_volume": "7528.56624000000101660",
        "lowest_ask": "0.04149531752568082",
        "quote": "BTS",
        "percent_change": "2.91849996917492582",
        "latest": "0.04170420553180162"
    },
    "id": 1
}