Adding price multiplier to GMI_SymbolMap

This commit is contained in:
Taha Afzal committed 2019-08-19 16:17:49 -04:00
1 parent a053609cc9
commit d86e7c4ad2
3 files changed
+23 -13

No files matched your search

+5 -5
View File
@@ -1,9 +1,9 @@
GMI_SymbolMap {
value {
sym { gmi: "1" spark: "ZW" venue: VENUE_GLBX }
sym { gmi: "2" spark: "ZC" venue: VENUE_GLBX }
sym { gmi: "3" spark: "ZO" venue: VENUE_GLBX }
sym { gmi: "5" spark: "ZS" venue: VENUE_GLBX }
sym { gmi: "KW" spark: "KE" venue: VENUE_GLBX }
sym { gmi: "1" spark: "ZW" venue: VENUE_GLBX price_multiplier: 100.0}
sym { gmi: "2" spark: "ZC" venue: VENUE_GLBX price_multiplier: 100.0}
sym { gmi: "3" spark: "ZO" venue: VENUE_GLBX price_multiplier: 100.0}
sym { gmi: "5" spark: "ZS" venue: VENUE_GLBX price_multiplier: 100.0}
sym { gmi: "KW" spark: "KE" venue: VENUE_GLBX price_multiplier: 100.0}
}
}
+1
View File
@@ -24,6 +24,7 @@ message GMI_SymbolMap {
required string gmi = 1;
required string spark = 2;
required bts.api.Venue venue = 3;
required double price_multiplier = 4;
}
repeated SymbolMap sym = 4;
}
@@ -6,6 +6,7 @@
#include "lib/md/SecurityDB.h"
#include "lib/md/UserSymbol.h"
#include "lib/utils/PBUtils.h"
#include "lib/os/os.h"
#include "server/sparkd/position/import/parsing/parser_common.h"
#include <boost/algorithm/string.hpp>
@@ -15,17 +16,22 @@
namespace bts {
namespace position {
md::UserSymbol map_gmi_future_symbol(std::string const &cfc, api::Venue venue) {
std::pair<md::UserSymbol,double> map_gmi_future_symbol(
std::string const &cfc, api::Venue venue) {
auto map_glbx_to_sim = config::get<config::GMI_Parser>().map_glbx_to_sim();
for (auto const &m : config::get<config::GMI_SymbolMap>().sym())
if (m.gmi() == cfc && m.venue() == venue)
return {m.spark(), venue, api::SECURITYTYPE_FUTURE};
return std::pair<md::UserSymbol,double>(
{m.spark(), venue, api::SECURITYTYPE_FUTURE},
m.price_multiplier());
else if (map_glbx_to_sim && m.gmi() == cfc &&
venue == api::Venue::VENUE_SIM &&
m.venue() == api::Venue::VENUE_GLBX)
return {m.spark(), venue, api::SECURITYTYPE_FUTURE};
return {};
return std::pair<md::UserSymbol,double>(
{m.spark(), venue, api::SECURITYTYPE_FUTURE},
m.price_multiplier());
return std::pair<md::UserSymbol,double>({},os::nan());
}
api::Venue map_gmi_venue(std::string const &gmi_venue) {
@@ -223,7 +229,9 @@ parse_gmi(api::admin::AdminData const &admin_data, std::istream &in) {
}
auto gmi_cfc = values[column_idx["CFC"]];
auto spark_symbol = map_gmi_future_symbol(gmi_cfc, venue);
auto symbol_map = map_gmi_future_symbol(gmi_cfc, venue);
auto spark_symbol = symbol_map.first;
double price_multiplier = symbol_map.second;
if (spark_symbol == md::UserSymbol()) {
if (ignore_unknown_sec) {
LOG(OrderMan, Info,
@@ -299,18 +307,19 @@ parse_gmi(api::admin::AdminData const &admin_data, std::istream &in) {
this_line_position.set_quantity(qty.value());
// Quantity
auto gmi_price = values[column_idx["CPRICE"]];
auto gmi_price = values[column_idx["CTPRIC"]];
auto price = parse_price(gmi_price);
if (!price.has_value()) {
auto msg = fmt::format("Aborted parsing on line {} because "
"CPRICE {} is not a number",
"CTPRIC {} is not a number",
line_number, gmi_price);
LOG(OrderMan, Error, "{}", msg);
return msg;
}
// Price
this_line_position.set_avg_price(price.value());
auto avg_price = price.value() * price_multiplier;
this_line_position.set_avg_price(avg_price);
// Price
LOG(OrderMan, Info,