Skip to content

Commit 6f23e58

Browse files
committed
fix: binance client order id
1 parent e6553c6 commit 6f23e58

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/include/app/event_handler_base.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1314,20 +1314,20 @@ class EventHandlerBase : public EventHandler {
13141314
const std::string& quantity, const TimePoint& now) {
13151315
std::string clientOrderId;
13161316
if (this->tradingMode == TradingMode::BACKTEST || this->tradingMode == TradingMode::PAPER) {
1317-
clientOrderId += UtilTime::getISOTimestamp<std::chrono::seconds>(std::chrono::time_point_cast<std::chrono::seconds>(now));
1317+
clientOrderId += UtilTime::getISOTimestamp<std::chrono::milliseconds>(std::chrono::time_point_cast<std::chrono::milliseconds>(now));
13181318
clientOrderId += "_";
13191319
clientOrderId += side;
13201320
} else {
13211321
if (exchange == "coinbase") {
13221322
clientOrderId = AppUtil::generateUuidV4();
1323-
} else if (exchange == "kraken") {
1324-
clientOrderId = std::to_string(std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count());
1323+
} else if (exchange.rfind("binance", 0) == 0 || exchange == "kraken") {
1324+
clientOrderId = std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count());
13251325
} else if (exchange == "gateio") {
1326-
clientOrderId = "t-" + std::to_string(std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count());
1326+
clientOrderId = "t-" + std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count());
13271327
} else {
13281328
clientOrderId += instrument;
13291329
clientOrderId += "_";
1330-
clientOrderId += UtilTime::getISOTimestamp<std::chrono::seconds>(std::chrono::time_point_cast<std::chrono::seconds>(now));
1330+
clientOrderId += UtilTime::getISOTimestamp<std::chrono::milliseconds>(std::chrono::time_point_cast<std::chrono::milliseconds>(now));
13311331
clientOrderId += "_";
13321332
clientOrderId += side;
13331333
clientOrderId += "_";

0 commit comments

Comments
 (0)