Handle possibility of a missing LegSpreaderParams
This commit is contained in:
1 parent
0ed884a5ab
commit
d6fafee64c
1 file changed
+18
-1
@@ -173,7 +173,14 @@ TimeStamp copy_depth(const SyntheticStrategy& synth, size_t count, PriceSize* bi
|
||||
for (size_t x = 0; x < synth.legs.size(); ++x) {
|
||||
std::array<PriceSize, COCONUT_MAX_DEPTH> bids, asks;
|
||||
TimeStamp t;
|
||||
auto mdtype = synth.strategy.leg_params_map().at(synth.legs[x].key()).market_data_type();
|
||||
auto key = synth.legs[x].key();
|
||||
auto iter = synth.strategy.leg_params_map().find(key);
|
||||
const spark::LegSpreaderParams& leg_params =
|
||||
iter == synth.strategy.leg_params_map().end() ?
|
||||
spark::LegSpreaderParams::default_instance() :
|
||||
iter->second;
|
||||
|
||||
auto mdtype = leg_params.market_data_type();
|
||||
HandleReadResult r;
|
||||
if (mdtype == spark::LegSpreaderParams::DIRECT) {
|
||||
r = synth.legs[x].get_direct_book(t, count, &bids[0], &asks[0]);
|
||||
@@ -182,6 +189,16 @@ TimeStamp copy_depth(const SyntheticStrategy& synth, size_t count, PriceSize* bi
|
||||
r = synth.legs[x].get_book(t, count, &bids[0], &asks[0]);
|
||||
}
|
||||
if (r == HandleReadResult::BUSY || t == TimeStamp::invalid()) return TimeStamp::invalid();
|
||||
|
||||
// NET Change
|
||||
if (leg_params.leg_md_calc() == spark::LegSpreaderParams::NET_CHANGE) {
|
||||
auto settle = synth.legs[x].settlement_price();
|
||||
for (size_t d = 0; d < COCONUT_MAX_DEPTH; ++d) {
|
||||
bids[x] = bids[x] - settle;
|
||||
asks[x] = asks[x] - settle;
|
||||
}
|
||||
}
|
||||
|
||||
rv = std::max(rv, t);
|
||||
const auto& leg = synth.security.synthetic().legs(x);
|
||||
const auto& eff_bid = leg.side() == api::SIDE_BUY ? bids : asks;
|
||||
|
||||
Reference in new issue
Block a user