Skip to content

Commit

Permalink
Make subscriber use Order::precision_, rather than hard-code it.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtheschmitzer committed May 22, 2013
1 parent 526be7c commit 3028427
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/depth_feed_publisher/depth_feed_publisher.mpc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ project(depth_feed_subscriber) : QuickFASTApplication, liquibook_book, liquibook
depth_feed_connection.cpp
depth_feed_subscriber.cpp
template_consumer.cpp
order.cpp
}
exename = *
}
Expand Down
7 changes: 4 additions & 3 deletions examples/depth_feed_publisher/depth_feed_subscriber.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include "order.h"
#include <boost/scoped_ptr.hpp>
#include "depth_feed_subscriber.h"
#include <Codecs/DataSourceBuffer.h>
Expand Down Expand Up @@ -89,7 +90,7 @@ DepthFeedSubscriber::log_depth(book::Depth<5>& depth)
while (bid || ask) {
if (bid && bid->order_count()) {
printf("%8.2f %9d [%2d]",
(double)bid->price() / 100.0,
(double)bid->price() / Order::precision_,
bid->aggregate_qty(), bid->order_count());
if (bid == depth.last_bid_level()) {
bid = NULL;
Expand All @@ -104,7 +105,7 @@ DepthFeedSubscriber::log_depth(book::Depth<5>& depth)

if (ask && ask->order_count()) {
printf(" %8.2f %9d [%2d]\n",
(double)ask->price() / 100.0,
(double)ask->price() / Order::precision_,
ask->aggregate_qty(), ask->order_count());
if (ask == depth.last_ask_level()) {
ask = NULL;
Expand Down Expand Up @@ -230,7 +231,7 @@ DepthFeedSubscriber::handle_trade_message(
return false;
}

double price = (double) cost / (qty * 100);
double price = (double) cost / (qty * Order::precision_);
std::cout << timestamp
<< " Got trade msg " << seq_num
<< " for symbol " << symbol
Expand Down
4 changes: 2 additions & 2 deletions examples/depth_feed_publisher/order.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class Order : public book::Order {
virtual bool is_buy() const;
virtual book::Quantity order_qty() const;
virtual book::Price price() const;

static const uint8_t precision_;
private:
bool is_buy_;
double price_;
book::Quantity qty_;

static const uint8_t precision_;
};

} }
Expand Down

0 comments on commit 3028427

Please sign in to comment.