spark-577 get cash-per-point from market data feed.

This commit is contained in:
Eric Harding committed 2018-03-05 11:23:11 -05:00
1 parent 206f2d3c3c
commit 8d62eaf15e
5 files changed
+14 -3

No files matched your search

@@ -232,7 +232,7 @@ namespace mbts.co2
public readonly UInt16 sequence;
}
[StructLayout(LayoutKind.Sequential, Size = 432)]
[StructLayout(LayoutKind.Sequential, Size = 440)]
internal struct ColdEntry
{
public int exchange_status;
+1
View File
@@ -80,6 +80,7 @@ string dump_security(const FixedSecurity& security) {
res << "'price_break': " << security.price_break << ", ";
res << "'low_tick': " << security.low_tick << ", ";
res << "'high_tick': " << security.high_tick << ", ";
res << "'cpp': " << security.cash_per_point << ", ";
switch(security.type) {
case SECURITYTYPE_STOCK: break;
+3
View File
@@ -133,11 +133,13 @@ void get_contract_spec(const FixedSecurity& source, api::ContractSpecification&
spec.set_price_break(source.price_break);
spec.set_low_tick(source.low_tick);
spec.set_high_tick(source.high_tick);
spec.set_cash_per_point(source.cash_per_point);
// Account for price multiplier
spec.set_price_multiplier(pow10(source.display_factor));
spec.set_price_break(spec.price_break() * spec.price_multiplier());
spec.set_low_tick(spec.low_tick() * spec.price_multiplier());
spec.set_high_tick(spec.high_tick() * spec.price_multiplier());
spec.set_cash_per_point(spec.cash_per_point() * spec.price_multiplier());
}
Security convert_security(const FixedSecurity& security) {
@@ -268,6 +270,7 @@ void convert_security(const Security& src, FixedSecurity& dest, bool set_securit
dest.price_break = src.contract_spec().price_break() / src.contract_spec().price_multiplier();
dest.low_tick = src.contract_spec().low_tick() / src.contract_spec().price_multiplier();
dest.high_tick = src.contract_spec().high_tick() / src.contract_spec().price_multiplier();
dest.cash_per_point = src.contract_spec().cash_per_point();
switch(securitytype_of(src)) {
case SECURITYTYPE_FUTURE: {
+1
View File
@@ -51,6 +51,7 @@ public:
double price_break;
double low_tick;
double high_tick;
double cash_per_point;
private:
char _symbol[16]; // CME defines this as a char[6] but I'm padding
@@ -214,7 +214,11 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security& osec, co
set_security_common(sec, fsec);
fsec.price_break = 0;
// low/high tick are stored non-premultiplied and multiplied in conversion to api::Secutity
fsec.low_tick = fsec.high_tick = double_of_price(sec.minPriceIncrement(), 0);
double min_tick = double_of_price(sec.minPriceIncrement(), 0);
fsec.low_tick = fsec.high_tick = min_tick;
onixs::PRICE min_tick_amount;
sec.minPriceIncrementAmount(min_tick_amount);
fsec.cash_per_point = double_of_price(min_tick_amount, 0) / min_tick;
auto expiration = date_of_maturity(sec);
fsec.expiration_year = expiration.year;
fsec.expiration_month = expiration.month;
@@ -247,13 +251,15 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security&, const o
bts_assert(sec.strikePrice(strike_price));
fsec.strike = double_of_price(strike_price, fsec.display_factor);
onixs::PRICE min_tick;
onixs::PRICE min_tick, min_tick_amount;
sec.minPriceIncrement(min_tick);
sec.minPriceIncrementAmount(min_tick_amount);
int8_t tick_rule;
if (sec.tickRule(tick_rule)) {
decode_ticks(tick_rule, double_of_price(min_tick, 0), fsec);
}
fsec.cash_per_point = double_of_price(min_tick_amount, 0) / fsec.low_tick;
fsec.call_put = sec.putOrCall() == onixs::PutOrCall::Call ? api::PUTORCALL_CALL : api::PUTORCALL_PUT;