TEST(KrxOrderEncoder, FutureCancelBody) { OrderManager om; KrxOrderEncoder encoder(&om); OrderInput oi; oi.account.account_name = "99903911450"; oi.account.password = "******"; oi.long_short = TradingDirection::kLong; oi.account.exchange_dest = ExchangeDest::kKospiFuture; oi.req_count = 887; oi.req_price = 242.15; oi.ticker = "101G9000"; MarketData md; Order* order = om.CreateOrder(oi, md, NULL); const int kOriginNumber = 127; order->set_origin_number(kOriginNumber); char out_buf[2048]; const int size = encoder.EncodeCancel(order, out_buf); out_buf[size] = 0; // std::cout << out_buf << std::endl; std::stringstream ss; ss << "00001"; ss << "40"; ss << "99903911450 "; ss << "1450 "; ss << "101G9000" << " "; ss << "00"; ss << "+000000127"; ss << "+000000000000887"; ss << "00"; ss << " "; ss << " "; ss << "+000000000"; ss << "+000000000"; ss << "+000000000"; ss << "+000000000"; ss << "+000000000"; ss << " "; ss << " "; ss << "+000000000"; ss << "+000000000"; // std::cout << ss.str().c_str() << std::endl; const int cmp_result = strncmp(ss.str().c_str(), out_buf + 163, size); EXPECT_EQ(0, cmp_result); }
TEST(KrxOrderEncoder, FutureRequestBody) { OrderManager om; KrxOrderEncoder encoder(&om); OrderInput oi; oi.account.account_name = "99903911450"; oi.account.password = "******"; oi.long_short = TradingDirection::kLong; oi.account.exchange_dest = ExchangeDest::kKospiFuture; oi.req_count = 887; oi.req_price = 242.15; oi.ticker = "101G9000"; MarketData md; Order* order = om.CreateOrder(oi, md, NULL); char out_buf[2048]; const int size = encoder.EncodeEnter(order, out_buf); out_buf[size] = 0; // std::cout << out_buf; std::stringstream ss; ss << "00001" << "40" << "99903911450" << " "; ss << "1450" << " " << "101G9000" << " "; ss << "2" << "00" << "00" << "03"; ss << "+000000242.15"; ss << "+000000000000887"; ss << "00" << " " << " "; ss << "+000000000"; //16 ss << "+000000000"; ss << "+000000000"; ss << "+000000000"; ss << "+000000000"; ss << " "; //21 ss << " "; ss << " "; ss << "+000000000"; //compare out_buf's body. const int cmp_result = strncmp(ss.str().c_str(), out_buf + 163, size); EXPECT_EQ(0, cmp_result); }