Skip to content

Commit 868d50a

Browse files
committed
fix order attr init
1 parent 2098be1 commit 868d50a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

include/tigerapi/model.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Contract {
4242
utility::string_t right;
4343
int multiplier = 0;
4444
utility::string_t contract_month;
45-
long contract_id;
45+
long contract_id = 0;
4646
utility::string_t identifier;
4747
utility::string_t market;
4848
};
@@ -63,21 +63,21 @@ class Order {
6363

6464
Contract contract;
6565
utility::string_t account;
66-
long id;
67-
long order_id;
66+
long id=0;
67+
long order_id=0;
6868
/** 订单类型, 'MKT' 市价单 / 'LMT' 限价单 / 'STP' 止损单 / 'STP_LMT' 止损限价单 / 'TRAIL' 跟踪止损单 **/
6969
utility::string_t order_type;
7070
/** 交易方向, 'BUY' / 'SELL' **/
7171
utility::string_t action;
7272
/** 下单数量 **/
73-
long total_quantity;
73+
long total_quantity=0;
7474
/** 限价单价格 **/
75-
double limit_price;
75+
double limit_price=0;
7676
/** 在止损单中, 表示触发止损单的价格, 在移动止损单中, 表示跟踪的价差 **/
77-
double aux_price;
78-
double trail_stop_price;
79-
double trailing_percent;
80-
double percent_offset;
77+
double aux_price=0;
78+
double trail_stop_price=0;
79+
double trailing_percent=0;
80+
double percent_offset=0;
8181
/** 有效期,'DAY' 日内有效 / 'GTC' good till cancel / 'GTD' good till date **/
8282
utility::string_t time_in_force;
8383
/** 是否允许盘前盘后交易(outside of regular trading hours 美股专属). True 允许, False 不允许 **/
@@ -88,7 +88,7 @@ class Order {
8888
*/
8989
bool adjust_limit;
9090
utility::string_t user_mark;
91-
long expire_time;
91+
long expire_time=0;
9292

9393
// 订单状态
9494
utility::string_t status;

src/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class TestTradeClient {
8989

9090

9191
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
92-
TestTradeClient::test_get_position(trade_client);
92+
TestTradeClient::test_place_order(trade_client);
9393
}
9494
};
9595

@@ -353,15 +353,15 @@ int main(int argc, char *args[]) {
353353
/**
354354
* 使用封装后的行情接口 QuoteClient
355355
*/
356-
std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
356+
// std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
357357
// quote_client->grab_quote_permission();
358-
TestQuoteClient::test_quote(quote_client);
358+
// TestQuoteClient::test_quote(quote_client);
359359

360360
/**
361361
* 使用封装后的交易接口 TradeClient
362362
*/
363-
// std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
364-
// TestTradeClient::test_trade(trade_client);
363+
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
364+
TestTradeClient::test_trade(trade_client);
365365

366366
/**
367367
* 直接使用未封装的 TigerApi

0 commit comments

Comments
 (0)