Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional subscribe option to get_ticker #2001

Closed
wants to merge 1 commit into from
Closed

Conversation

oxarbitrage
Copy link
Member

For issue #1937

While testing this i found that all the apis that have subscribe in this manner is that it is actually true by default when the option is not present(get_assets, get_accounts, etc).
Most probably nobody noticed as it will not start sending data without set_subscribe_callback.
Not sure if this is what we want, i was expecting a false by default.

@@ -1280,6 +1283,9 @@ market_ticker database_api_impl::get_ticker( const string& base, const string& q
{
orders = get_order_book(assets[0]->symbol, assets[1]->symbol, 1);
}
if( to_subscribe )
subscribe_to_item( itr->id );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not sufficient.

  1. Currently we don't return id in market_ticker, so the client don't know what id is for what.

  2. I guess, when the data changed, only the id will be pushed to the client, so the client need to call get_objects to get the new data. This is not good enough. We'd better push the data directly.

@abitmore
Copy link
Member

abitmore commented Sep 22, 2019

i was expecting a false by default.

It's true for backward compatibility, so that old clients would still work. It does affect your new code. Node running your new code will be "spamming" the (old) clients with ticker data if they called set_subscribe_callback then get_ticker without specifying whether to auto-subscribe. I think it's acceptable.

@abitmore abitmore added this to the Future Feature Release milestone Sep 29, 2019
pmconrad
pmconrad previously approved these changes Nov 1, 2019
Copy link
Contributor

@pmconrad pmconrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

@crazybits
Copy link
Contributor

possible to have this feature in v4.0? @abitmore @oxarbitrage
btw, exiting ticker does not return the bid/ask size, better to return the bid/ask size of base/quote asset in ticker as well, most of exchanges return bid/ask size in the ticker.

e.g refactoring the market_ticker object like below.

struct market_ticker
   {
      time_point_sec             time;
      string                     base;
      string                     quote;
      string                     latest;
      string                     lowest_ask;
      string                     lowest_ask_size;
      string                     highest_bid;
      string                     highest_bid_size;
      string                     percent_change;
      string                     base_volume;
      string                     quote_volume;
}

@abitmore
Copy link
Member

@crazybits thanks for the info. We'll consider it.

@oxarbitrage
Copy link
Member Author

I see what i can do. How do we compute lowest_ask_size and highest_bid_size ? Is the volume in that prices ?

@crazybits
Copy link
Contributor

crazybits commented Apr 14, 2020

I see what i can do. How do we compute lowest_ask_size and highest_bid_size ? Is the volume in that prices ?

yes, return the base or quote asset volume of lowest_ask and highest_bid price in the orderbook

@oxarbitrage
Copy link
Member Author

In regards to the subscription to tickers we were talking with @abitmore that this will need a refactor of the subscription system or some other medium to big refactor that we will not do right now. The approach of this pull will just get a raw ticker object that is not what we need. I think the PR can be closed but feel free to reopen if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants