adding wallet api to return the market history
This commit is contained in:
parent
e7ec05f545
commit
a518c37c9e
3 changed files with 16 additions and 1 deletions
|
|
@ -73,6 +73,7 @@ struct operation_process_fill_order
|
|||
|
||||
void operator()( const fill_order_operation& o )const
|
||||
{
|
||||
ilog( "processing ${o}", ("o",o) );
|
||||
const auto& buckets = _plugin.tracked_buckets();
|
||||
auto& db = _plugin.database();
|
||||
const auto& bucket_idx = db.get_index_type<bucket_index>();
|
||||
|
|
@ -91,7 +92,10 @@ struct operation_process_fill_order
|
|||
* the base > quote
|
||||
*/
|
||||
if( key.base > key.quote )
|
||||
{
|
||||
ilog( " skipping because base > quote" );
|
||||
continue;
|
||||
}
|
||||
|
||||
price trade_price = o.pays / o.receives;
|
||||
|
||||
|
|
@ -102,7 +106,7 @@ struct operation_process_fill_order
|
|||
auto itr = by_key_idx.find( key );
|
||||
if( itr == by_key_idx.end() )
|
||||
{ // create new bucket
|
||||
db.create<bucket_object>( [&]( bucket_object& b ){
|
||||
const auto& obj = db.create<bucket_object>( [&]( bucket_object& b ){
|
||||
b.key = key;
|
||||
b.quote_volume += trade_price.quote.amount;
|
||||
b.open_base = trade_price.base.amount;
|
||||
|
|
@ -114,9 +118,11 @@ struct operation_process_fill_order
|
|||
b.low_base = b.close_base;
|
||||
b.low_quote = b.close_quote;
|
||||
});
|
||||
wlog( " creating bucket ${b}", ("b",obj) );
|
||||
}
|
||||
else
|
||||
{ // update existing bucket
|
||||
wlog( " before updating bucket ${b}", ("b",*itr) );
|
||||
db.modify( *itr, [&]( bucket_object& b ){
|
||||
b.base_volume += trade_price.base.amount;
|
||||
b.quote_volume += trade_price.quote.amount;
|
||||
|
|
@ -133,6 +139,7 @@ struct operation_process_fill_order
|
|||
b.low_quote = b.close_quote;
|
||||
}
|
||||
});
|
||||
wlog( " after bucket bucket ${b}", ("b",*itr) );
|
||||
}
|
||||
|
||||
if( max_history != 0 )
|
||||
|
|
@ -146,6 +153,7 @@ struct operation_process_fill_order
|
|||
itr->key.seconds == bucket &&
|
||||
itr->key.open < cutoff )
|
||||
{
|
||||
elog( " removing old bucket ${b}", ("b", *itr) );
|
||||
auto old_itr = itr;
|
||||
++itr;
|
||||
db.remove( *old_itr );
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ class wallet_api
|
|||
vector<asset> list_account_balances(const string& id);
|
||||
vector<asset_object> list_assets(const string& lowerbound, uint32_t limit)const;
|
||||
vector<operation_history_object> get_account_history(string name, int limit)const;
|
||||
vector<bucket_object> get_market_history(string symbol, string symbol2, uint32_t bucket)const;
|
||||
vector<limit_order_object> get_limit_orders(string a, string b, uint32_t limit)const;
|
||||
vector<call_order_object> get_call_orders(string a, uint32_t limit)const;
|
||||
vector<force_settlement_object> get_settle_orders(string a, uint32_t limit)const;
|
||||
|
|
@ -362,6 +363,7 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(get_block)
|
||||
(get_account_count)
|
||||
(get_account_history)
|
||||
(get_market_history)
|
||||
(get_global_properties)
|
||||
(get_dynamic_global_properties)
|
||||
(get_object)
|
||||
|
|
|
|||
|
|
@ -1693,6 +1693,11 @@ vector<operation_history_object> wallet_api::get_account_history(string name, in
|
|||
return my->_remote_hist->get_account_history(get_account(name).get_id(), operation_history_id_type(), limit, operation_history_id_type());
|
||||
}
|
||||
|
||||
vector<bucket_object> wallet_api::get_market_history( string symbol1, string symbol2, uint32_t bucket )const
|
||||
{
|
||||
return my->_remote_hist->get_market_history( get_asset_id(symbol1), get_asset_id(symbol2), bucket, fc::time_point_sec(), fc::time_point::now() );
|
||||
}
|
||||
|
||||
vector<limit_order_object> wallet_api::get_limit_orders(string a, string b, uint32_t limit)const
|
||||
{
|
||||
return my->_remote_db->get_limit_orders(get_asset(a).id, get_asset(b).id, limit);
|
||||
|
|
|
|||
Loading…
Reference in a new issue