bitshares-core icon indicating copy to clipboard operation
bitshares-core copied to clipboard

Extend get_top_markets API

Open abitmore opened this issue 4 years ago • 7 comments

  • Added an optional base asset argument to get_top_markets API
    • get_top_market ( limit, optional base_asset )
    • To implement this, the plugin now stores two ticker objects for each market
  • Refactored some code for better performance

TODO:

  • add an API to get total trading volume of specified assets (already added an item to the enum but didn't write more code)

abitmore avatar Aug 14 '19 12:08 abitmore

@oxarbitrage: I think this would be helpful for https://github.com/bitshares/bitshares-explorer-api/pull/64.

abitmore avatar Aug 14 '19 12:08 abitmore

sure it will :)

oxarbitrage avatar Aug 14 '19 12:08 oxarbitrage

@oxarbitrage I think it's better to move the timestamp out of the individual items. Since the API was noted as experimental, I guess we can make the change.

{
  "time":xxx,
  "data":[ {ticker_1},{ticker_2},... ]
}

What do you think? Do you know who are using this API except the open explorer?

abitmore avatar Aug 14 '19 15:08 abitmore

Right now, the get_top_market API, if not called with the base asset parameter, the sorting doesn't make sense for users. Ideally, we need a reference price for each asset so that we can sort by trading "value" (volume * price). Data sources we have now:

  • CER, however it is not always reliable so it would mess up the results, perhaps still better than what we currently have though;
  • price feeds, currently it's usable for assets which are backed by CORE
    • We may need price feeds for every asset which wanted to be included in this API, it doesn't sound like a good idea though.
  • market price, can be off or stale for illiquid or inactive markets.

Possible approaches:

  • always use CER
  • use price feeds when available, otherwise use CER
  • use price feeds when available, otherwise assume trading_value = 0

Thoughts?

abitmore avatar Aug 16 '19 01:08 abitmore

what about considering also what @Zapata did in the bitshares-explorer-api to get top markets?

This is count of fill orders in the last 24 hours. It could mess the results a bit considering some markets will fill less but bigger orders but will still be better than what we have now as we have a reference value in all pairs.

oxarbitrage avatar Aug 25 '19 13:08 oxarbitrage

Another thing i tried in the past with @MichelSantos is to normalize the volume in BTS by querying the crosses tickers https://github.com/oxarbitrage/scripts/blob/master/bitshares_market_volume.lua#L73-L103 of the market base and quote against BTS.

Not very reliable, the ticker prices need to be up to date and we assume there is a cross in BTS for at least 1 asset or the market pair. Still can be an approach to consider.

oxarbitrage avatar Aug 25 '19 13:08 oxarbitrage

count of fill orders

Count of fill orders makes sense for some people (E.G. a website that measures Dapps' activities) but I think it doesn't make sense for traders.

normalize the volume in BTS

Ideally we should do this or normalize volume in another currency E.G. USD or CNY. However, if we can't stably get somewhat accurate reference prices, the result would be unreliable thus mostly useless. Specifically, hard to do this on-chain, perhaps we (API server admins) can feed some external data to the back end of explorer API and serve results from there.

abitmore avatar Aug 25 '19 15:08 abitmore