Merged from dev

This commit is contained in:
Pedro Pinto committed 2018-05-18 16:57:03 -04:00
1 parent ec7a4df5ee
commit ab950cba91
424 files changed
+31620 -4908

No files matched your search

@@ -441,37 +441,17 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) {
auto price_factor = pow(10, handle.security().display_factor);
auto n_bids = book.bids.size();
uint i = 0;
auto it = book.bids.begin();
for (; i < std::min(md::COCONUT_MAX_DEPTH, (uint32_t)n_bids); i++, it++) {
auto p = it->first.value() * price_factor;
auto sz = it->second.value();
auto psz = md::PriceSize::from_double<7>(p, sz);
LOG(ExSim, Diag, "Updating market data for {}. Depth: {} : Buy {}@{}",
sec_desc, i, sz, p);
handle.update_bid(utils::TimeStamp::now(), psz, i);
}
for (uint i = n_bids; i < md::COCONUT_MAX_DEPTH; i++) {
auto psz = md::PriceSize::from_double<7>(os::nan(), 0);
handle.update_bid(utils::TimeStamp::now(), psz, i);
}
auto n_asks = book.asks.size();
i = 0;
it = book.asks.begin();
for (; i < std::min(md::COCONUT_MAX_DEPTH, (uint32_t)n_asks); i++, it++) {
auto p = it->first.value() * price_factor;
auto sz = it->second.value();
auto psz = md::PriceSize::from_double<7>(p, sz);
LOG(ExSim, Diag, "Updating market data for {}. Depth: {} : Sell {}@{}",
sec_desc, i, sz, p);
handle.update_ask(utils::TimeStamp::now(), psz, i);
}
for (uint i = n_asks; i < md::COCONUT_MAX_DEPTH; i++) {
auto psz = md::PriceSize::from_double<7>(os::nan(), 0);
handle.update_ask(utils::TimeStamp::now(), psz, i);
}
const auto cmax = md::COCONUT_MAX_DEPTH;
std::array<md::PriceSize,cmax> bids_temp = { }, asks_temp = { };
auto bids_end = book.bids.size() > cmax ?
std::next(book.bids.begin(), cmax) : book.bids.end();
std::transform(book.bids.begin(), bids_end, bids_temp.begin(),
[&](const auto& bs) { return md::PriceSize::from_double<7>(bs.first.value()*price_factor, bs.second.value()); });
auto asks_end = book.asks.size() > cmax ?
std::next(book.asks.begin(), cmax) : book.asks.end();
std::transform(book.asks.begin(), asks_end, asks_temp.begin(),
[&](const auto& bs) { return md::PriceSize::from_double<7>(bs.first.value()*price_factor, bs.second.value()); });
handle.update_book(utils::TimeStamp::now(), bids_temp, asks_temp);
auto new_trades = matcher.get_new_trades();
for (auto &t : new_trades)