Skip to content

Commit

Permalink
Merge pull request #3606 from steemit/3599-smt-market-history
Browse files Browse the repository at this point in the history
SMT Market History Updates
  • Loading branch information
sgerbino authored Feb 11, 2020
2 parents 14b7631 + 5b974a9 commit 693d6a8
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 102 deletions.
6 changes: 3 additions & 3 deletions contrib/config-for-ahnode.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ follow-max-feed-size = 500
# follow-start-feeds = 0

# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
market-history-bucket-size = [15,60,300,3600,21600]

# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# How far back in time to track market history, measure in seconds (default: 604800)
market-history-track-time = 604800

# The local IP address and port to listen for incoming connections.
# p2p-endpoint =
Expand Down
6 changes: 3 additions & 3 deletions contrib/config-for-broadcaster.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ follow-max-feed-size = 500
# follow-start-feeds = 0

# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
market-history-bucket-size = [15,60,300,3600,21600]

# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# How far back in time to track market history, measure in seconds (default: 604800)
market-history-track-time = 604800

# The local IP address and port to listen for incoming connections.
# p2p-endpoint =
Expand Down
6 changes: 3 additions & 3 deletions contrib/config-for-docker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ follow-max-feed-size = 500
# follow-start-feeds = 0

# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
market-history-bucket-size = [15,60,300,3600,21600]

# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# How far back in time to track market history, measure in seconds (default: 604800)
market-history-track-time = 604800

# The local IP address and port to listen for incoming connections.
# p2p-endpoint =
Expand Down
6 changes: 3 additions & 3 deletions contrib/fullnode.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ follow-max-feed-size = 500
# follow-start-feeds = 0

# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
market-history-bucket-size = [15,60,300,3600,21600]

# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# How far back in time to track market history, measure in seconds (default: 604800)
market-history-track-time = 604800

# The local IP address and port to listen for incoming connections.
# p2p-endpoint =
Expand Down
6 changes: 3 additions & 3 deletions contrib/fullnode.opswhitelist.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ follow-max-feed-size = 500
# follow-start-feeds = 0

# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
market-history-bucket-size = [15,60,300,3600,21600]

# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# How far back in time to track market history, measure in seconds (default: 604800)
market-history-track-time = 604800

# The local IP address and port to listen for incoming connections.
# p2p-endpoint =
Expand Down
6 changes: 3 additions & 3 deletions doc/example_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ follow-max-feed-size = 500
# follow-start-feeds = 0

# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
market-history-bucket-size = [15,60,300,3600,86400]
market-history-bucket-size = [15,60,300,3600,21600]

# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)
market-history-buckets-per-size = 5760
# How far back in time to track market history, measure in seconds (default: 604800)
market-history-track-time = 604800

# The local IP address and port to listen for incoming connections.
# p2p-endpoint =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void blockchain_statistics_plugin_impl::on_block( const signed_block& b )
for( const auto& bucket : _tracked_buckets )
{
auto open = fc::time_point_sec( ( db.head_block_time().sec_since_epoch() / bucket ) * bucket );
auto itr = bucket_idx.find( boost::make_tuple( bucket, open ) );
auto itr = bucket_idx.find( boost::make_tuple( SBD_SYMBOL, bucket, open ) );

if( itr == bucket_idx.end() )
{
Expand Down
8 changes: 4 additions & 4 deletions libraries/plugins/apis/condenser_api/condenser_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,15 +1877,15 @@ namespace detail
FC_ASSERT( args.size() == 0 || args.size() == 1, "Expected 0-1 arguments, was ${n}", ("n", args.size()) );
FC_ASSERT( _market_history_api, "market_history_api_plugin not enabled." );
return get_order_book_return( _market_history_api->get_order_book( { args.size() == 1 ? args[0].as< uint32_t >() : 500 } ) );
return get_order_book_return( _market_history_api->get_order_book( { SBD_SYMBOL, args.size() == 1 ? args[0].as< uint32_t >() : 500 } ) );
}
DEFINE_API_IMPL( condenser_api_impl, get_trade_history )
{
FC_ASSERT( args.size() == 2 || args.size() == 3, "Expected 2-3 arguments, was ${n}", ("n", args.size()) );
FC_ASSERT( _market_history_api, "market_history_api_plugin not enabled." );
const auto& trades = _market_history_api->get_trade_history( { args[0].as< time_point_sec >(), args[1].as< time_point_sec >(), args.size() == 3 ? args[2].as< uint32_t >() : 1000 } ).trades;
const auto& trades = _market_history_api->get_trade_history( { SBD_SYMBOL, args[0].as< time_point_sec >(), args[1].as< time_point_sec >(), args.size() == 3 ? args[2].as< uint32_t >() : 1000 } ).trades;
get_trade_history_return result;
for( const auto& t : trades ) result.push_back( market_trade( t ) );
Expand All @@ -1898,7 +1898,7 @@ namespace detail
FC_ASSERT( args.size() == 0 || args.size() == 1, "Expected 0-1 arguments, was ${n}", ("n", args.size()) );
FC_ASSERT( _market_history_api, "market_history_api_plugin not enabled." );
const auto& trades = _market_history_api->get_recent_trades( { args.size() == 1 ? args[0].as< uint32_t >() : 1000 } ).trades;
const auto& trades = _market_history_api->get_recent_trades( { SBD_SYMBOL, args.size() == 1 ? args[0].as< uint32_t >() : 1000 } ).trades;
get_trade_history_return result;
for( const auto& t : trades ) result.push_back( market_trade( t ) );
Expand All @@ -1911,7 +1911,7 @@ namespace detail
CHECK_ARG_SIZE( 3 )
FC_ASSERT( _market_history_api, "market_history_api_plugin not enabled." );
return _market_history_api->get_market_history( { args[0].as< uint32_t >(), args[1].as< time_point_sec >(), args[2].as< time_point_sec >() } ).buckets;
return _market_history_api->get_market_history( { SBD_SYMBOL, args[0].as< uint32_t >(), args[1].as< time_point_sec >(), args[2].as< time_point_sec >() } ).buckets;
}
DEFINE_API_IMPL( condenser_api_impl, get_market_history_buckets )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ DEFINE_API_ARGS( get_order_book, vector< variant >, or
DEFINE_API_ARGS( get_trade_history, vector< variant >, vector< market_trade > )
DEFINE_API_ARGS( get_recent_trades, vector< variant >, vector< market_trade > )
DEFINE_API_ARGS( get_market_history, vector< variant >, vector< market_history::bucket_object > )
DEFINE_API_ARGS( get_market_history_buckets, vector< variant >, flat_set< uint32_t > )
DEFINE_API_ARGS( get_market_history_buckets, vector< variant >, vector< uint32_t > )
DEFINE_API_ARGS( list_proposals, vector< variant >, vector< api_proposal_object > )
DEFINE_API_ARGS( find_proposals, vector< variant >, vector< api_proposal_object > )
DEFINE_API_ARGS( list_proposal_votes, vector< variant >, vector< database_api::api_proposal_vote_object > )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ using fc::time_point_sec;
using json_rpc::void_type;


typedef void_type get_ticker_args;
struct get_ticker_args
{
asset_symbol_type market = SBD_SYMBOL;
};

struct get_ticker_return
{
Expand All @@ -30,7 +33,7 @@ struct get_ticker_return
asset sbd_volume = asset( 0, SBD_SYMBOL );
};

typedef void_type get_volume_args;
typedef get_ticker_args get_volume_args;

struct get_volume_return
{
Expand All @@ -49,7 +52,8 @@ struct order

struct get_order_book_args
{
uint32_t limit = 500;
asset_symbol_type market = SBD_SYMBOL;
uint32_t limit = 500;
};

struct get_order_book_return
Expand All @@ -67,9 +71,10 @@ struct market_trade

struct get_trade_history_args
{
time_point_sec start;
time_point_sec end;
uint32_t limit = 1000;
asset_symbol_type market = SBD_SYMBOL;
time_point_sec start;
time_point_sec end;
uint32_t limit = 1000;
};

struct get_trade_history_return
Expand All @@ -79,28 +84,30 @@ struct get_trade_history_return

struct get_recent_trades_args
{
uint32_t limit = 1000;
asset_symbol_type market = SBD_SYMBOL;
uint32_t limit = 1000;
};

typedef get_trade_history_return get_recent_trades_return;

struct get_market_history_args
{
uint32_t bucket_seconds;
time_point_sec start;
time_point_sec end;
asset_symbol_type market = SBD_SYMBOL;
uint32_t bucket_seconds;
time_point_sec start;
time_point_sec end;
};

struct get_market_history_return
{
std::vector< market_history::bucket_object > buckets;
};

typedef void_type get_market_history_buckets_args;
typedef get_ticker_args get_market_history_buckets_args;

struct get_market_history_buckets_return
{
flat_set< uint32_t > bucket_sizes;
vector< uint32_t > bucket_sizes;
};


Expand Down Expand Up @@ -129,6 +136,9 @@ class market_history_api

} } } // steem::plugins::market_history

FC_REFLECT( steem::plugins::market_history::get_ticker_args,
(market) )

FC_REFLECT( steem::plugins::market_history::get_ticker_return,
(latest)(lowest_ask)(highest_bid)(percent_change)(steem_volume)(sbd_volume) )

Expand All @@ -139,7 +149,7 @@ FC_REFLECT( steem::plugins::market_history::order,
(order_price)(real_price)(steem)(sbd)(created) )

FC_REFLECT( steem::plugins::market_history::get_order_book_args,
(limit) )
(market)(limit) )

FC_REFLECT( steem::plugins::market_history::get_order_book_return,
(bids)(asks) )
Expand All @@ -148,16 +158,16 @@ FC_REFLECT( steem::plugins::market_history::market_trade,
(date)(current_pays)(open_pays) )

FC_REFLECT( steem::plugins::market_history::get_trade_history_args,
(start)(end)(limit) )
(market)(start)(end)(limit) )

FC_REFLECT( steem::plugins::market_history::get_trade_history_return,
(trades) )

FC_REFLECT( steem::plugins::market_history::get_recent_trades_args,
(limit) )
(market)(limit) )

FC_REFLECT( steem::plugins::market_history::get_market_history_args,
(bucket_seconds)(start)(end) )
(market)(bucket_seconds)(start)(end) )

FC_REFLECT( steem::plugins::market_history::get_market_history_return,
(buckets) )
Expand Down
Loading

0 comments on commit 693d6a8

Please sign in to comment.