Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f48b648b7 | ||
|
|
f0376843db | ||
|
|
cb52c14db1 | ||
|
|
2b53a051d3 | ||
|
|
768853bbe5 | ||
|
|
cc40c523f9 | ||
|
|
c7fd8deabe | ||
|
|
6a896586ce |
No files matched your search
@@ -22,6 +22,7 @@ insert_anchor_links = "right"
|
||||
### Internal Changes
|
||||
- Changed how we packaged certain third-party components
|
||||
- Added logging of entitlement status
|
||||
- Tagged outgoing orders with sequence number of marketdata or FIX event that triggered them
|
||||
## 2.8.3
|
||||
### Bug Fixes
|
||||
- Fixed a bug that could cause an OrderBook's Security column filter to be blank
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
MC1 KTima1GzuuXgmAd5LWnN bAFTi2XyMDBxX5S2-BC-k8Ti-5GmENer8Vtv4zmyCXM 2019-04-09 2020-04-09 CERT
|
||||
MC5 tnoschzeeYyQEcUFLYBp uA4xXSggo3-hwRJdD35v0CTKpx6_HmpAock0CHgmZ4A 2019-04-09 2020-04-09 CERT
|
||||
MC7 8ArA8FSwuoeTzMhkoQlW Zi1egeOWG3phGx4qZYjhOTtptcmA3t7ty_7if7qwO4c 2019-04-09 2020-04-09 CERT
|
||||
MC8 grWHZk3dCz8wtRPYTQR9 OPIIFk1orwBLu4IBJVcNAVvRb8Db1-VRD0qyQClYHl8 2019-04-09 2020-04-09 CERT
|
||||
V06 jw4KHsh6FqXIGK7ejJKp s_Cqv1o1rPhWTUWgY8mvHXJudzBYBUYS1rlMzwjMMT8 2019-04-09 2020-04-09 NEWRELEASE
|
||||
Session ID Access ID Secret Key Creation Date Expiration Date Environment
|
||||
|
||||
M4D lLtjH74y1Kh5XUJTLyH2 f1K_tROQp2lTIplVp34WxKa7xDUgfFnIteolfik061o 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC1 VEMlkDuLz74OVHSuacQB IuHyYT3b-9KUo3WsuXykt-fXsjzp7L-JOrdCSQZLNl0 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC5 77lzSUwPLlM9obaXh2mK z6aA9qfASDKfZkYTVKFqJd-78i0HZ2Q9ec3CKCYIqHg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC7 RphzI3rn71oGUEiYnX9e y6OvvPPyoyj2S8YAnE1gFduXT8v29HIMjO5EngYxSNg 2019-09-03 2020-09-03 CERT
|
||||
|
||||
MC8 PYBIm2TI9gFPIxmHbuYl 6o-ZolGH2DdeQOlGtJ5Zqoh_kg7VdbxkmjeOHmigKwU 2019-09-03 2020-09-03 CERT
|
||||
|
||||
@@ -77,6 +77,29 @@ void PositionUtilities::apply_fill (PositionEntry& pos,
|
||||
}
|
||||
}
|
||||
|
||||
void PositionUtilities::apply_fill (PositionEntry& pos,
|
||||
const Fill& f,
|
||||
bool is_add){
|
||||
PositionUtilities::apply_fill(pos,
|
||||
f.side(),
|
||||
f.last_price(),
|
||||
f.last_shares(),
|
||||
f.fill_key(),
|
||||
is_add);
|
||||
}
|
||||
|
||||
void PositionUtilities::apply_manual_fill (
|
||||
PositionEntry& pos,
|
||||
const ManualFill& mf,
|
||||
bool is_add){
|
||||
PositionUtilities::apply_fill(pos,
|
||||
mf.side(),
|
||||
mf.price(),
|
||||
mf.quantity(),
|
||||
"",
|
||||
is_add);
|
||||
}
|
||||
|
||||
void PositionUtilities::total_position(const PositionUnit& p,
|
||||
uint32_t& total_long,
|
||||
uint32_t& total_short){
|
||||
|
||||
@@ -18,15 +18,21 @@ public:
|
||||
const std::string& fill_id,
|
||||
double& avg_price,
|
||||
double& tot_qty);
|
||||
|
||||
|
||||
|
||||
static void apply_fill (bts::api::position::PositionEntry& pos,
|
||||
api::Side side,
|
||||
double price,
|
||||
double qty,
|
||||
const std::string& fill_id,
|
||||
bool is_add);
|
||||
bool is_add);
|
||||
|
||||
static void apply_fill (bts::api::position::PositionEntry& pos,
|
||||
const bts::api::orderman::Fill& fill,
|
||||
bool is_add);
|
||||
|
||||
static void apply_manual_fill (bts::api::position::PositionEntry& pos,
|
||||
const bts::api::position::ManualFill& mf,
|
||||
bool is_add);
|
||||
|
||||
// subsumes p2 into p1
|
||||
static void total_position(const bts::api::position::PositionUnit& p,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
SpanMargin {
|
||||
value {
|
||||
enabled: true
|
||||
enabled: false
|
||||
login: 'api_bts1'
|
||||
password: 'Summer123'
|
||||
url: 'https://cmecorenr.cmegroup.com/MarginServiceApi/1.4/'
|
||||
|
||||
@@ -164,6 +164,7 @@ class OrderServices {
|
||||
// i.e. caller will attach to an existing order.
|
||||
void attach(OrderKey attach_target, AttachCallback const &);
|
||||
|
||||
trace::CorID corid() { return _data->cor_id; }
|
||||
private:
|
||||
friend class OrderBuilder;
|
||||
|
||||
@@ -269,7 +270,6 @@ class OrderServices {
|
||||
|
||||
void warm_up_activate_child(Order &o) { o.warm_up_activate(*_data, *this); }
|
||||
|
||||
trace::CorID corid() { return _data->cor_id; }
|
||||
|
||||
OrderOpResult check_is_attachable();
|
||||
bool has_reported_state() const;
|
||||
|
||||
@@ -1,50 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "orderman_common.h"
|
||||
#include "lib/jetfix/codec/i32_toa.h"
|
||||
#include "lib/jetfix/codec/MessageDefinitions.h"
|
||||
#include "lib/jetfix/codec/i32_toa.h"
|
||||
#include "lib/utils/bts_assert.h"
|
||||
#include "orderman_common.h"
|
||||
|
||||
namespace bts {
|
||||
namespace api {class Security;}
|
||||
namespace api {
|
||||
class Security;
|
||||
}
|
||||
|
||||
namespace orderman {
|
||||
|
||||
constexpr int clordid_sz() {return 20;}
|
||||
constexpr int price_sz() {return 17;}
|
||||
constexpr int quantity_sz() {return 6;}
|
||||
constexpr int max_show_sz() {return 6;}
|
||||
constexpr int clordid_sz() { return 20; }
|
||||
constexpr int price_sz() { return 17; }
|
||||
constexpr int quantity_sz() { return 6; }
|
||||
constexpr int max_show_sz() { return 6; }
|
||||
constexpr uint32_t corid_sz() {
|
||||
return 16;
|
||||
} // 5 for channel, 1 separator, 10 sn
|
||||
|
||||
inline void encode_clorid(OrderKey ok, SecurityKey sk,std::string *out) {
|
||||
u32_toa(sk.value(),&((*out)[0]),clordid_sz()/2);
|
||||
u32_toa(ok.value(),&((*out)[clordid_sz()/2]),clordid_sz()/2);
|
||||
inline void encode_clorid(OrderKey ok, SecurityKey sk, std::string *out) {
|
||||
u32_toa(sk.value(), &((*out)[0]), clordid_sz() / 2);
|
||||
u32_toa(ok.value(), &((*out)[clordid_sz() / 2]), clordid_sz() / 2);
|
||||
}
|
||||
|
||||
inline void decode_clorid(std::string const&in, OrderKey *ok, SecurityKey *sk)
|
||||
{
|
||||
inline void decode_clorid(std::string const &in, OrderKey *ok,
|
||||
SecurityKey *sk) {
|
||||
bts_assert(in.size() == clordid_sz());
|
||||
char buffer[clordid_sz()/2+1];
|
||||
buffer[clordid_sz()/2] = 0;
|
||||
char buffer[clordid_sz() / 2 + 1];
|
||||
buffer[clordid_sz() / 2] = 0;
|
||||
|
||||
std::memcpy(buffer,&in[0],clordid_sz()/2);
|
||||
std::memcpy(buffer, &in[0], clordid_sz() / 2);
|
||||
*sk = SecurityKey(std::atoi(buffer));
|
||||
|
||||
std::memcpy(buffer,&in[clordid_sz()/2],clordid_sz()/2);
|
||||
std::memcpy(buffer, &in[clordid_sz() / 2], clordid_sz() / 2);
|
||||
*ok = OrderKey(std::atoi(buffer));
|
||||
}
|
||||
|
||||
template <class MSG>
|
||||
OrderKey get_order_key(MSG const &msg)
|
||||
{
|
||||
|
||||
bts_assert(msg.template has<jetfix::fix::ClOrdID> ());
|
||||
template <class MSG> OrderKey get_order_key(MSG const &msg) {
|
||||
|
||||
bts_assert(msg.template has<jetfix::fix::ClOrdID>());
|
||||
OrderKey result;
|
||||
SecurityKey dummy;
|
||||
decode_clorid(msg.template get<jetfix::fix::ClOrdID>(),&result,&dummy);
|
||||
decode_clorid(msg.template get<jetfix::fix::ClOrdID>(), &result, &dummy);
|
||||
return result;
|
||||
}
|
||||
|
||||
}}
|
||||
inline void encode_corid(const char *channel, uint32_t sn, std::array<char, 17> &out) {
|
||||
memset(&out[0], ' ', out.size());
|
||||
auto ch_sz = std::min(strlen(channel), (size_t)5);
|
||||
strncpy(&out[0], channel, ch_sz);
|
||||
out[ch_sz] = ':';
|
||||
auto sz_written = u32_toa(sn, &out[ch_sz + 1]);
|
||||
out[ch_sz+1+sz_written]=' ';
|
||||
}
|
||||
|
||||
} // namespace orderman
|
||||
} // namespace bts
|
||||
@@ -54,12 +54,14 @@ struct NativeOrder::PImpl {
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::StopPx> update_stop_px_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::TransactTimeStr>
|
||||
update_transact_time_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Text> update_corid_bm;
|
||||
|
||||
jetfix::FIXFragment create_encoding;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Price> create_price_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::OrderQty> create_quantity_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::TransactTimeStr>
|
||||
create_transact_time_bm;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Text> create_corid_bm;
|
||||
|
||||
jetfix::FIXFragment cancel_encoding;
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::TransactTimeStr>
|
||||
@@ -72,6 +74,14 @@ struct NativeOrder::PImpl {
|
||||
std::optional<std::pair<Price, Quantity>> buffered_update;
|
||||
};
|
||||
|
||||
jetfix::FIXFragment::Bookmark<jetfix::fix::Text>
|
||||
update_corid(jetfix::FIXFragment::Bookmark<jetfix::fix::Text> const &bm,
|
||||
jetfix::FIXFragment &encoding, trace::CorID const &cid) {
|
||||
std::array<char, corid_sz()+1> buffer;
|
||||
encode_corid(cid.channel, cid.sn, buffer);
|
||||
return encoding.overwrite(bm, &buffer[0], corid_sz());
|
||||
}
|
||||
|
||||
NativeOrder::NativeOrder() : me(new PImpl()) {}
|
||||
|
||||
OrderDefinition const &NativeOrder::definition() const {
|
||||
@@ -464,6 +474,10 @@ NativeOrder::_on_activate(log::Level reject_level, log::Level transition_level,
|
||||
auto const &ts = services.get_time_str();
|
||||
me->create_transact_time_bm = encoding.overwrite(
|
||||
me->create_transact_time_bm, &ts.value()[0], ts.value().size());
|
||||
|
||||
me->create_corid_bm =
|
||||
update_corid(me->create_corid_bm,encoding, services.corid());
|
||||
|
||||
return OrderOpResult{};
|
||||
}
|
||||
|
||||
@@ -670,6 +684,9 @@ OrderOpResult NativeOrder::on_update(api::orderman::Update const &update) {
|
||||
me->update_transact_time_bm = encoding.overwrite(
|
||||
me->update_transact_time_bm, &ts.value()[0], ts.value().size());
|
||||
|
||||
me->update_corid_bm =
|
||||
update_corid(me->update_corid_bm,encoding, me->services->corid());
|
||||
|
||||
me->services->queue_fix(*me->session_services,
|
||||
jetfix::MessageTypes::CancelReplace,
|
||||
me->update_encoding);
|
||||
@@ -909,7 +926,7 @@ void NativeOrder::on_exe_report(const NewExecutionReportEvent &er) {
|
||||
state.set_price(er.data->price.value());
|
||||
state.set_quantity(er.data->quantity.value());
|
||||
}
|
||||
|
||||
|
||||
switch (me->state.status()) {
|
||||
// terminal states, nothing can change them
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
@@ -975,7 +992,7 @@ void NativeOrder::on_cancel_reject(const orderman::CancelRejectEvent &cr) {
|
||||
switch (me->state.status()) {
|
||||
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
case ORDER_STATUS_CANCELED:
|
||||
case ORDER_STATUS_CANCELED:
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_DISCONNECTED:
|
||||
@@ -1123,6 +1140,9 @@ void NativeOrder::init_fix() {
|
||||
datetime::FIX_timestamp(datetime::now()));
|
||||
me->create_quantity_bm =
|
||||
create_encoding.add<fix::OrderQty>(0, quantity_sz());
|
||||
me->create_corid_bm =
|
||||
create_encoding.add<fix::Text>(std::string(corid_sz(), ' '));
|
||||
|
||||
// initialize update FIX
|
||||
auto &update_encoding = me->update_encoding;
|
||||
update_encoding.add<fix::SenderSubID>(rr.operator_id());
|
||||
@@ -1149,6 +1169,8 @@ void NativeOrder::init_fix() {
|
||||
datetime::FIX_timestamp(datetime::now()));
|
||||
me->update_quantity_bm =
|
||||
update_encoding.add<fix::OrderQty>(0, quantity_sz());
|
||||
me->update_corid_bm =
|
||||
update_encoding.add<fix::Text>(std::string(corid_sz(), ' '));
|
||||
|
||||
// initialize cancel FIX
|
||||
auto &cancel_encoding = me->cancel_encoding;
|
||||
|
||||
@@ -52,11 +52,14 @@ std::tuple<string, string> load_session_keys(const string& session) {
|
||||
|
||||
// we try to make it easier to run cert by copying the cert secure
|
||||
// logon file to the right place if in dev
|
||||
if (!is_directory(path) && config::get<config::DeploymentType>().type()=="dev") {
|
||||
if (config::get<config::DeploymentType>().type()=="dev") {
|
||||
auto cert_file=os::sparkd_wd() + "/data_files/cert_secure_logon.txt" ;
|
||||
if (exists(cert_file)) {
|
||||
create_directories(path);
|
||||
copy_file(cert_file, path+"/cert_secure_logon.txt");
|
||||
auto target = path+"cert_secure_logon.txt";
|
||||
if (exists(target))
|
||||
remove(target);
|
||||
copy_file(cert_file,target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources algo/AlgoDefinitionServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/KeyCode.cpp;cmds/Md.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/Web.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/MultipartFormDecoder.cpp;http/WebServer.cpp;http/tests/MultiPartFormTests.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/IMDPlatform.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/ice_onixs/ICEListener.cpp;md/platforms/ice_onixs/ICEMain.cpp;md/platforms/ice_onixs/tests/ice_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/MarginServiceServer.cpp;position/PositionAggregator.cpp;position/PositionMap.cpp;position/PositionServicePNLHelper.cpp;position/PositionServiceServer.cpp;position/import/BasePositionServiceServer.cpp;position/import/DownloadCommonStateMachine.cpp;position/import/DownloadWindow.cpp;position/import/MoneyFileServiceServer.cpp;position/import/parsing/gmi_parser.cpp;position/import/parsing/money_parser.cpp;position/import/parsing/parser_common.cpp;position/tests/PositionTests.cpp;position/tests/position_tests_internal.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp)
|
||||
set(sources algo/AlgoDefinitionServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/FIXSim.cpp;cmds/Help.cpp;cmds/KeyCode.cpp;cmds/Md.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/Web.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/MultipartFormDecoder.cpp;http/WebServer.cpp;http/tests/MultiPartFormTests.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/IMDPlatform.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/ice_onixs/ICEListener.cpp;md/platforms/ice_onixs/ICEMain.cpp;md/platforms/ice_onixs/tests/ice_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/MarginServiceServer.cpp;position/PositionAggregator.cpp;position/PositionMap.cpp;position/PositionServicePNLHelper.cpp;position/PositionServiceServer.cpp;position/import/BasePositionServiceServer.cpp;position/import/DownloadCommonStateMachine.cpp;position/import/DownloadWindow.cpp;position/import/MoneyFileServiceServer.cpp;position/import/parsing/gmi_parser.cpp;position/import/parsing/money_parser.cpp;position/import/parsing/parser_common.cpp;position/tests/PositionTests.cpp;position/tests/position_tests_internal.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp)
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "server/sparkd/cmds/FIXSim.h"
|
||||
#include "server/sparkd/exchange_sim/ExchangeSim.h"
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
int FIXSim::execute(std::vector<std::string> const &) {
|
||||
bts::sim::start_exchange_sim();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
std::string FIXSim::help() {
|
||||
return "FIXSim - Starts a standalone FIX simulator ";
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
} // namespace bts
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "ICmd.h"
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
class FIXSim : public ICmd
|
||||
{
|
||||
public:
|
||||
int execute(std::vector<std::string> const &args);
|
||||
std::string help ();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace bts {
|
||||
namespace md { class MBOWriter; }
|
||||
namespace sim {
|
||||
|
||||
int start_exchange_sim(md::MBOWriter*);
|
||||
int start_exchange_sim(md::MBOWriter* = nullptr);
|
||||
|
||||
}}
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
// to add a command add the header here and the the REGISTER call below
|
||||
// don't touch this file except to add commands.
|
||||
#include "server/sparkd/cmds/AdminReport.h"
|
||||
#include "server/sparkd/cmds/AutoCert.h"
|
||||
#include "server/sparkd/cmds/Benchmark.h"
|
||||
#include "server/sparkd/cmds/ConfigCheck.h"
|
||||
#include "server/sparkd/cmds/KeyCode.h"
|
||||
#include "server/sparkd/cmds/FIXSim.h"
|
||||
#include "server/sparkd/cmds/Help.h"
|
||||
#include "server/sparkd/cmds/KeyCode.h"
|
||||
#include "server/sparkd/cmds/Md.h"
|
||||
#include "server/sparkd/cmds/PrintHedgeOrders.h"
|
||||
#include "server/sparkd/cmds/QuickTest.h"
|
||||
@@ -17,7 +19,6 @@
|
||||
#include "server/sparkd/cmds/Span.h"
|
||||
#include "server/sparkd/cmds/Test.h"
|
||||
#include "server/sparkd/cmds/TestCeloxica.h"
|
||||
#include "server/sparkd/cmds/AdminReport.h"
|
||||
#include "server/sparkd/cmds/Web.h"
|
||||
|
||||
using namespace bts;
|
||||
@@ -37,6 +38,7 @@ int main(int argc, char **argv) {
|
||||
REGISTER(Benchmark);
|
||||
REGISTER(QuickTest);
|
||||
REGISTER(AutoCert);
|
||||
REGISTER(FIXSim);
|
||||
REGISTER(Span);
|
||||
REGISTER(Web);
|
||||
REGISTER(PrintHedgeOrders);
|
||||
|
||||
@@ -44,32 +44,17 @@ const PositionUnit& PositionMap::on_fill (const Fill& f,
|
||||
_fill_map[f.fill_key()] = f;
|
||||
PositionUnit &pu = _get_or_add(f.internal_account_id(),
|
||||
f.security_key());
|
||||
auto fill_type = _fill_type(f);
|
||||
auto fill_type = _fill_type(f.timestamp());
|
||||
switch (fill_type){
|
||||
case FillType::BASE:
|
||||
break;
|
||||
case FillType::SOD:
|
||||
PositionUtilities::apply_fill(*(pu.mutable_sod()),
|
||||
f.side(),
|
||||
f.last_price(),
|
||||
f.last_shares(),
|
||||
f.fill_key(),
|
||||
is_add);
|
||||
PositionUtilities::apply_fill(*(pu.mutable_sod()),f,is_add);
|
||||
break;
|
||||
case FillType::DAY:
|
||||
PositionUtilities::apply_fill(*(pu.mutable_day()),
|
||||
f.side(),
|
||||
f.last_price(),
|
||||
f.last_shares(),
|
||||
f.fill_key(),
|
||||
is_add);
|
||||
PositionUtilities::apply_fill(*(pu.mutable_day()),f,is_add);
|
||||
if (f.fill_kind() == Fill::FILL_KIND_STANDARD)
|
||||
PositionUtilities::apply_fill(*(pu.mutable_raw_day()),
|
||||
f.side(),
|
||||
f.last_price(),
|
||||
f.last_shares(),
|
||||
f.fill_key(),
|
||||
is_add);
|
||||
PositionUtilities::apply_fill(*(pu.mutable_raw_day()),f,is_add);
|
||||
break;
|
||||
}
|
||||
PositionUtilities::backwards_compat(pu);
|
||||
@@ -87,26 +72,11 @@ const PositionUnit& PositionMap::on_fill (const Fill& f,
|
||||
mf.security_key());
|
||||
switch (mf.fill_type()) {
|
||||
case ManualFill::LOCAL:
|
||||
PositionUtilities::apply_fill(*(pu.mutable_local()),
|
||||
mf.side(),
|
||||
mf.price(),
|
||||
mf.quantity(),
|
||||
"",
|
||||
is_add);
|
||||
_on_manual_local_fill(mf, is_add);
|
||||
break;
|
||||
case ManualFill::ADMIN_DAY:
|
||||
PositionUtilities::apply_fill(*(pu.mutable_admin_day()),
|
||||
mf.side(),
|
||||
mf.price(),
|
||||
mf.quantity(),
|
||||
"",
|
||||
is_add);
|
||||
PositionUtilities::apply_fill(*(pu.mutable_raw_day()),
|
||||
mf.side(),
|
||||
mf.price(),
|
||||
mf.quantity(),
|
||||
"",
|
||||
is_add);
|
||||
_on_manual_admin_fill(mf, is_add);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -159,6 +129,10 @@ ManualFill const* PositionMap::get_manual_fill (int rec_id) const{
|
||||
else
|
||||
return &(it->second);
|
||||
}
|
||||
|
||||
bool PositionMap::is_sod (google::protobuf::Timestamp fill_time) const{
|
||||
return _sod_helper.is_sod(fill_time);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// helpers ////////////////////////////////////////////////////////////////////
|
||||
PositionUnit& PositionMap::_get_or_add(uint32_t account_id, uint32_t seckey){
|
||||
@@ -175,11 +149,12 @@ PositionUnit& PositionMap::_get_or_add(uint32_t account_id, uint32_t seckey){
|
||||
return pu;
|
||||
}
|
||||
|
||||
PositionMap::FillType PositionMap::_fill_type(const Fill& f) const{
|
||||
if(f.timestamp().seconds() <= _base_pos_ts.seconds())
|
||||
PositionMap::FillType PositionMap::_fill_type(
|
||||
google::protobuf::Timestamp fill_time) const{
|
||||
if(fill_time.seconds() <= _base_pos_ts.seconds())
|
||||
return FillType::BASE;
|
||||
else
|
||||
return _sod_helper.is_sod(f.timestamp()) ? FillType::SOD : FillType::DAY;
|
||||
return _sod_helper.is_sod(fill_time) ? FillType::SOD : FillType::DAY;
|
||||
}
|
||||
|
||||
void PositionMap::_reset_sod(){
|
||||
@@ -242,6 +217,41 @@ void PositionMap::_zero_out_pos_entry (bts::api::position::PositionEntry& p){
|
||||
p.set_short_avg_price(0);
|
||||
}
|
||||
|
||||
void PositionMap::_on_manual_admin_fill (const ManualFill& mf,
|
||||
bool is_add){
|
||||
PositionUnit &pu =_get_or_add(mf.account_id(),
|
||||
mf.security_key());
|
||||
auto fill_type = _fill_type(mf.timestamp());
|
||||
switch (fill_type){
|
||||
case FillType::BASE:
|
||||
break;
|
||||
case FillType::SOD:
|
||||
PositionUtilities::apply_manual_fill(*(pu.mutable_admin_sod()),mf,is_add);
|
||||
break;
|
||||
case FillType::DAY:
|
||||
PositionUtilities::apply_manual_fill(*(pu.mutable_admin_day()),mf,is_add);
|
||||
PositionUtilities::apply_manual_fill(*(pu.mutable_raw_day()),mf,is_add);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PositionMap::_on_manual_local_fill (const ManualFill& mf,
|
||||
bool is_add){
|
||||
PositionUnit &pu =_get_or_add(mf.account_id(),
|
||||
mf.security_key());
|
||||
auto fill_type = _fill_type(mf.timestamp());
|
||||
switch (fill_type){
|
||||
case FillType::BASE:
|
||||
case FillType::SOD:
|
||||
// local fills only apply to DAY
|
||||
break;
|
||||
case FillType::DAY:
|
||||
PositionUtilities::apply_manual_fill(*(pu.mutable_local()),mf,is_add);
|
||||
PositionUtilities::apply_manual_fill(*(pu.mutable_raw_day()),mf,is_add);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// test only //////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PositionUnit const* PositionMap::test_only_pos (uint32_t account_id,
|
||||
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
google::protobuf::Timestamp _base_pos_ts;
|
||||
std::map<uint32_t, std::map<uint32_t, bts::api::position::PositionEntry>> _base_pos_map;
|
||||
private:
|
||||
FillType _fill_type(google::protobuf::Timestamp fill_time) const;
|
||||
FillType _fill_type(const bts::api::orderman::Fill &fill) const;
|
||||
bts::api::position::PositionUnit& _get_or_add(uint32_t account_id,
|
||||
uint32_t seckey);
|
||||
@@ -46,6 +47,10 @@ private:
|
||||
void _fill_account (bts::api::position::PositionUnit&);
|
||||
void _zero_out_pos_unit (bts::api::position::PositionUnit&);
|
||||
void _zero_out_pos_entry (bts::api::position::PositionEntry&);
|
||||
void _on_manual_admin_fill (const bts::api::position::ManualFill& mf,
|
||||
bool is_add);
|
||||
void _on_manual_local_fill (const bts::api::position::ManualFill& mf,
|
||||
bool is_add);
|
||||
public:
|
||||
PositionMap();
|
||||
PositionMap(timeval sod_time);
|
||||
@@ -59,6 +64,7 @@ public:
|
||||
void set_admin_data (const bts::api::admin::AdminData&);
|
||||
void get_pos (std::map<int, bts::api::position::PositionUnit const*>&) const;
|
||||
bts::api::position::ManualFill const* get_manual_fill (int rec_id) const;
|
||||
bool is_sod (google::protobuf::Timestamp fill_time) const;
|
||||
public:
|
||||
bts::api::position::PositionUnit const* test_only_pos (uint32_t account_id,
|
||||
uint32_t sec_key) const;
|
||||
|
||||
@@ -83,7 +83,8 @@ PositionServiceServer::PositionServiceServer(bts::api::ServiceContext &context,
|
||||
make_pnl_data_stateful_publisher(),
|
||||
make_pnl_account_data_stateful_publisher(),
|
||||
make_manual_fills_stateful_publisher(), md_client)) {
|
||||
// incremental fill update
|
||||
_delete_presod_local_on_start();
|
||||
// incremental fill update
|
||||
me->order_service.subscribe_fills() |
|
||||
rxcpp::operators::subscribe<api::orderman::FillsUpdate>(
|
||||
[this](auto const &update) {
|
||||
@@ -127,6 +128,30 @@ PositionServiceServer::PositionServiceServer(bts::api::ServiceContext &context,
|
||||
me->context.post([this]() { _periodic_poll(); }, me->poll_period_ms);
|
||||
}
|
||||
|
||||
void PositionServiceServer::_delete_presod_local_on_start() const{
|
||||
std::set<std::string> rm_ids;
|
||||
auto all = me->manual_fills_store->retrieve_all()[manual_fills_ns];
|
||||
ManualFill rec;
|
||||
for (auto const &kvp : all){
|
||||
if (utils::pb::from_string<ManualFill>(kvp.second, &rec)) {
|
||||
if(rec.fill_type() == ManualFill::LOCAL &&
|
||||
me->state.is_sod(rec.timestamp())){
|
||||
LOG(OrderMan, Info,
|
||||
"PositionServiceServer::_delete_presod_local_on_start "
|
||||
"fill: {}", kvp.second);
|
||||
auto id = std::to_string(rec.record_id());
|
||||
rm_ids.insert(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
LOG(OrderMan, Error,
|
||||
"Could not recover manual fill {} from storage. "
|
||||
"This should be investigated",
|
||||
kvp.first);
|
||||
}
|
||||
me->manual_fills_store->remove(manual_fills_ns, rm_ids);
|
||||
}
|
||||
|
||||
const PositionUnit &PositionServiceServer::_on_fill(const Fill &f,
|
||||
bool is_add) {
|
||||
return me->state.on_fill(f,is_add);
|
||||
@@ -134,7 +159,7 @@ const PositionUnit &PositionServiceServer::_on_fill(const Fill &f,
|
||||
|
||||
const PositionUnit &PositionServiceServer::_on_manual_fill(const ManualFill &mf,
|
||||
bool is_add) {
|
||||
return me->state.on_manual_fill(mf,is_add);
|
||||
return me->state.on_manual_fill(mf,is_add);
|
||||
}
|
||||
|
||||
void PositionServiceServer::_set_admin_data(
|
||||
|
||||
@@ -35,11 +35,14 @@ class PositionServiceServer : public bts::api::position::PositionServiceBase {
|
||||
private:
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
// this function deleted all local fills with
|
||||
// a timestamp less than SOD
|
||||
void _delete_presod_local_on_start() const;
|
||||
// this is the function that aggrgates the
|
||||
// position. is_add is to indicate if a row
|
||||
// is added or removed
|
||||
const bts::api::position::PositionUnit &
|
||||
_on_fill(const bts::api::orderman::Fill &fill, bool is_add);
|
||||
_on_fill(const bts::api::orderman::Fill &fill, bool is_add);
|
||||
// analogous to the above, for manual fills (this inclused
|
||||
// both client(local) and server(admin) fills)
|
||||
const bts::api::position::PositionUnit &
|
||||
|
||||
@@ -16,6 +16,9 @@ Open up the PNL and make sure the Day Long and Day Short positions match what yo
|
||||
The Start Net Pos should be 0. (The Total Net Pos in the PNL should match the pos button
|
||||
in the ladder)
|
||||
|
||||
2. Enter admin fills (from risk admin) and local fills. Make sure they reflect correctly in the PNL
|
||||
(local fills apply to the PNL, but are not used to enforce limits)
|
||||
|
||||
2. Now comes the SOD part. The SOD is what demarcates a day. Find the most recent time on your fills, select 1 minute past that override the SOD time in your spark.conf
|
||||
|
||||
Here's an example of what the key looks like, assuming your last fill was say at 10:29 and its now 10:35
|
||||
@@ -27,10 +30,16 @@ SODTime{
|
||||
}
|
||||
}
|
||||
|
||||
3. Now restart the server. Verify that all rows in the fills have a Fill Kind 'Sod'
|
||||
(Enter this in the timezone on your server, which you can check with "date")
|
||||
|
||||
4. Verify that the ladder is displaying the correct position (it should be the same as before the server start)
|
||||
3. Now restart the server. Verify that all fill rows in the fills have a Fill Kind 'Sod'
|
||||
|
||||
5. Verify that the PNL is displaying the correct Start Net Pos and the Day part is 0.
|
||||
4. The pre SOD local fills should be all gone (they are deleted by the system at startup)
|
||||
|
||||
5 Verify that the ladder is displaying the correct position (it should be the same as before the server start)
|
||||
|
||||
6. Verify that the PNL is displaying the correct Start Net Pos and the Day part is 0.
|
||||
|
||||
7. Now force a few more fills (trade fills as well as admin/local). Verify that the ladder position box and the PNL is
|
||||
correctly counting them.
|
||||
|
||||
6. Now force a few more fills. Verify that the ladder position box and the PNL is correctly counting them.
|
||||
Reference in new issue
Block a user