Skip to content

Commit

Permalink
Merge pull request #2166 from crazybits/hardfork
Browse files Browse the repository at this point in the history
return more useful data in market ticker
  • Loading branch information
abitmore authored May 3, 2020
2 parents b6785e0 + 22ab82c commit 68eebf1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
23 changes: 20 additions & 3 deletions libraries/app/api_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ market_ticker::market_ticker(const market_ticker_object& mto,
quote = asset_quote.symbol;
percent_change = "0";
lowest_ask = "0";
lowest_ask_base_size = "0";
lowest_ask_quote_size = "0";
highest_bid = "0";

highest_bid_base_size = "0";
highest_bid_quote_size = "0";
fc::uint128_t bv;
fc::uint128_t qv;
price latest_price = asset( mto.latest_base, mto.base ) / asset( mto.latest_quote, mto.quote );
Expand Down Expand Up @@ -68,9 +71,19 @@ market_ticker::market_ticker(const market_ticker_object& mto,
quote_volume = uint128_amount_to_string( qv, asset_quote.precision );

if(!orders.asks.empty())
lowest_ask = orders.asks[0].price;
{
lowest_ask = orders.asks[0].price;
lowest_ask_base_size = orders.asks[0].base;
lowest_ask_quote_size = orders.asks[0].quote;
}

if(!orders.bids.empty())
highest_bid = orders.bids[0].price;
{
highest_bid = orders.bids[0].price;
highest_bid_base_size = orders.bids[0].base;
highest_bid_quote_size = orders.bids[0].quote;
}

}

market_ticker::market_ticker(const fc::time_point_sec& now,
Expand All @@ -82,7 +95,11 @@ market_ticker::market_ticker(const fc::time_point_sec& now,
quote = asset_quote.symbol;
latest = "0";
lowest_ask = "0";
lowest_ask_base_size = "0";
lowest_ask_quote_size = "0";
highest_bid = "0";
highest_bid_base_size = "0";
highest_bid_quote_size = "0";
percent_change = "0";
base_volume = "0";
quote_volume = "0";
Expand Down
7 changes: 6 additions & 1 deletion libraries/app/include/graphene/app/api_objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ namespace graphene { namespace app {
string quote;
string latest;
string lowest_ask;
string lowest_ask_base_size;
string lowest_ask_quote_size;
string highest_bid;
string highest_bid_base_size;
string highest_bid_quote_size;
string percent_change;
string base_volume;
string quote_volume;
Expand Down Expand Up @@ -178,7 +182,8 @@ FC_REFLECT( graphene::app::full_account,
FC_REFLECT( graphene::app::order, (price)(quote)(base) );
FC_REFLECT( graphene::app::order_book, (base)(quote)(bids)(asks) );
FC_REFLECT( graphene::app::market_ticker,
(time)(base)(quote)(latest)(lowest_ask)(highest_bid)(percent_change)(base_volume)(quote_volume) );
(time)(base)(quote)(latest)(lowest_ask)(lowest_ask_base_size)(lowest_ask_quote_size)
(highest_bid)(highest_bid_base_size)(highest_bid_quote_size)(percent_change)(base_volume)(quote_volume) );
FC_REFLECT( graphene::app::market_volume, (time)(base)(quote)(base_volume)(quote_volume) );
FC_REFLECT( graphene::app::market_trade, (sequence)(date)(price)(amount)(value)(side1_account_id)(side2_account_id) );

Expand Down

0 comments on commit 68eebf1

Please sign in to comment.