Skip to content

Commit

Permalink
upload a useable version
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhuangxinyu committed Nov 28, 2019
1 parent 3f221ed commit 8e9a82b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
Binary file modified external/common/lib/libcommontools.so
Binary file not shown.
Binary file modified external/common/libcommontools.so
Binary file not shown.
5 changes: 3 additions & 2 deletions src/simplearb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ int main() {
std::string time_config_path = default_path + "/hft/config/prod/time.config";
TimeController tc(time_config_path);

std::unique_ptr<Sender> sender(new Sender("*:33333", "bind", "tcp", "mid.dat"));
std::unique_ptr<Sender> ui_sender(new Sender("*:33333", "bind", "tcp", "mid.dat"));
std::unique_ptr<Sender> order_sender(new Sender("order_sub", "connect", "ipc", "order.dat"));

std::unordered_map<std::string, std::vector<BaseStrategy*> > ticker_strat_map;
std::string contract_config_path = default_path + "/hft/config/contract/contract.config";
Expand All @@ -47,7 +48,7 @@ int main() {
if (param_setting.exists("no_close_today")) {
no_close_today = param_setting["no_close_today"];
}
auto s = new Strategy(param_setting, contract_config_path, tc, &ticker_strat_map, sender.get(), "real", no_close_today);
auto s = new Strategy(param_setting, contract_config_path, tc, &ticker_strat_map, ui_sender.get(), order_sender.get(), "real", no_close_today);
s->Print();
}

Expand Down
7 changes: 4 additions & 3 deletions src/simplearb/strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "./strategy.h"

Strategy::Strategy(const libconfig::Setting & param_setting, const std::string & contract_config_path, const TimeController& tc, std::unordered_map<std::string, std::vector<BaseStrategy*> >*ticker_strat_map, Sender* sender, const std::string & mode, bool no_close_today)
Strategy::Strategy(const libconfig::Setting & param_setting, const std::string & contract_config_path, const TimeController& tc, std::unordered_map<std::string, std::vector<BaseStrategy*> >*ticker_strat_map, Sender* uisender, Sender* ordersender, const std::string & mode, bool no_close_today)
: BaseStrategy(contract_config_path),
this_tc(tc),
tsm(ticker_strat_map),
Expand Down Expand Up @@ -53,7 +53,8 @@ Strategy::Strategy(const libconfig::Setting & param_setting, const std::string &
printf("EXCEPTION: %s\n", ex.what());
exit(1);
}
ui_sender = sender;
ui_sender = uisender;
order_sender = ordersender;
(*ticker_strat_map)[main_ticker].emplace_back(this);
(*ticker_strat_map)[hedge_ticker].emplace_back(this);
(*ticker_strat_map)["positionend"].emplace_back(this);
Expand Down Expand Up @@ -549,7 +550,7 @@ void Strategy::DoOperationAfterFilled(Order* o, const ExchangeInfo& info) {
// get hedged right now
std::string a = o->tbd;
a.find("close") == string::npos ? open_count++ : close_count++;
Order* order = NewOrder(hedge_ticker, (o->side == OrderSide::Buy)?OrderSide::Sell : OrderSide::Buy, info.trade_size, false, false, "", no_close_today);
Order* order = NewOrder(hedge_ticker, (o->side == OrderSide::Buy) ? OrderSide::Sell : OrderSide::Buy, info.trade_size, false, false, "", no_close_today);
order->Show(stdout);
HandleTestOrder(order);
} else if (strcmp(o->ticker, hedge_ticker.c_str()) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/simplearb/strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class Strategy : public BaseStrategy {
public:
explicit Strategy(const libconfig::Setting & param_setting, const std::string& contract_config_path, const TimeController& tc, std::unordered_map<std::string, std::vector<BaseStrategy*> >*ticker_strat_map, Sender* sender, const std::string & mode = "real", bool no_close_today = false);
explicit Strategy(const libconfig::Setting & param_setting, const std::string& contract_config_path, const TimeController& tc, std::unordered_map<std::string, std::vector<BaseStrategy*> >*ticker_strat_map, Sender* uisender, Sender* ordersender, const std::string & mode = "real", bool no_close_today = false);
~Strategy();

void Start() override;
Expand Down

0 comments on commit 8e9a82b

Please sign in to comment.