Skip to content

Commit 3ed9121

Browse files
committed
add api
1 parent 740c050 commit 3ed9121

File tree

5 files changed

+76
-6
lines changed

5 files changed

+76
-6
lines changed

demo/openapi_cpp_test/openapi_cpp_test.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,24 @@ class TestQuoteClient {
378378
ucout << U("result: ") << result << endl;
379379
}
380380

381+
static void test_get_warrant_real_time_quote(std::shared_ptr<QuoteClient> quote_client) {
382+
value result = quote_client->get_warrant_real_time_quote(U("15792"));
383+
ucout << U("result: ") << result << endl;
384+
}
385+
386+
static void test_get_warrant_filter(std::shared_ptr<QuoteClient> quote_client) {
387+
value result = quote_client->get_warrant_filter("00700");
388+
ucout << U("result: ") << result << endl;
389+
}
390+
391+
static void test_get_kline_quota(std::shared_ptr<QuoteClient> quote_client) {
392+
value result = quote_client->get_kline_quota();
393+
ucout << U("result: ") << result << endl;
394+
}
395+
396+
381397
static void test_quote(const std::shared_ptr<QuoteClient> quote_client) {
382-
TestQuoteClient::test_get_quote_real_time(quote_client);
398+
TestQuoteClient::test_get_kline_quota(quote_client);
383399
}
384400
};
385401

@@ -412,7 +428,7 @@ class TestTigerApi {
412428
int main()
413429
{
414430
/************************** set config **********************/
415-
ClientConfig config = ClientConfig();
431+
ClientConfig config = ClientConfig(true);
416432
config.private_key = U("");
417433
config.tiger_id = U("");
418434
config.account = U("");
@@ -426,14 +442,14 @@ int main()
426442
/**
427443
* ʹ�÷�װ�������ӿ� QuoteClient
428444
*/
429-
//std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
430-
//TestQuoteClient::test_quote(quote_client);
445+
std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
446+
TestQuoteClient::test_quote(quote_client);
431447

432448
/**
433449
* ʹ�÷�װ��Ľ��׽ӿ� TradeClient
434450
*/
435-
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
436-
TestTradeClient::test_trade(trade_client);
451+
//std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
452+
//TestTradeClient::test_trade(trade_client);
437453

438454
/**
439455
* ֱ��ʹ��δ��װ�� TigerApi

include/tigerapi/constants.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ static utility::string_t P_CURRENCY = U("currency");
5151
static utility::string_t P_EXCHANGE = U("exchange");
5252
static utility::string_t P_TYPE = U("type");
5353
static utility::string_t P_EXCHANGE_CODE = U("exchange_code");
54+
static utility::string_t P_PAGE = U("page");
55+
static utility::string_t P_PAGE_SIZE = U("page_size");
56+
static utility::string_t P_SORT_DIR = U("sort_dir");
57+
static utility::string_t P_SORT_FIELD_NAME = U("sort_field_name");
58+
static utility::string_t P_WITH_DETAILS = U("with_details");
59+
5460

5561
static utility::string_t OPEN_API_SERVICE_VERSION = U("3.0");
5662

include/tigerapi/quote_client.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ namespace TIGER_API {
6262
value get_option_kline_value(value identifiers, time_t begin_time, time_t end_time=4070880000000);
6363
vector<Kline> get_option_kline(value identifiers, time_t begin_time, time_t end_time=4070880000000);
6464
value get_option_trade_tick(value identifiers);
65+
value get_warrant_real_time_quote(const value &symbols);
66+
value get_warrant_real_time_quote(const utility::string_t symbol);
67+
value get_warrant_filter(const utility::string_t symbol, int page_size = 100, int page = 0,
68+
utility::string_t sort_field_name = U(""), utility::string_t sort_dir = U("SortDir_Ascend"));
69+
6570

6671
/** 期货行情 Future quote related api **/
6772
value get_future_exchange(SecType sec_type=SecType::FUT);
@@ -91,6 +96,9 @@ namespace TIGER_API {
9196
// 选股
9297
value get_market_scanner();
9398

99+
// 通用
100+
value get_kline_quota(bool with_details = false);
101+
94102
};
95103
}
96104
#endif //TIGERAPI_QUOTE_CLIENT_H

include/tigerapi/service_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ static utility::string_t TRADING_CALENDAR = U("trading_calendar");
5858
static utility::string_t STOCK_BROKER = U("stock_broker"); // 港股股票实时经纪队列
5959
static utility::string_t CAPITAL_DISTRIBUTION = U("capital_distribution"); // 股票当日资金分布
6060
static utility::string_t CAPITAL_FLOW = U("capital_flow"); // 股票资金流向
61+
static utility::string_t KLINE_QUOTA = U("kline_quota"); // 历史k线额度
6162

6263
// 期权行情
6364
static utility::string_t OPTION_EXPIRATION = U("option_expiration");
6465
static utility::string_t OPTION_CHAIN = U("option_chain");
6566
static utility::string_t OPTION_BRIEF = U("option_brief");
6667
static utility::string_t OPTION_KLINE = U("option_kline");
6768
static utility::string_t OPTION_TRADE_TICK = U("option_trade_tick");
69+
static utility::string_t WARRANT_FILTER = U("warrant_filter");
70+
static utility::string_t WARRANT_REAL_TIME_QUOTE = U("warrant_real_time_quote");
6871

6972
// 期货行情
7073
static utility::string_t FUTURE_EXCHANGE = U("future_exchange");

src/quote_client.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,43 @@ namespace TIGER_API {
415415
return post(FUTURE_TRADING_DATE, obj);
416416
}
417417

418+
value QuoteClient::get_warrant_real_time_quote(const value &symbols) {
419+
value obj = value::object(true);
420+
obj[P_SYMBOLS] = symbols;
421+
return post(WARRANT_REAL_TIME_QUOTE, obj)[P_ITEMS];
422+
}
423+
424+
value QuoteClient::get_warrant_real_time_quote(const utility::string_t symbol) {
425+
value symbols = value::array();
426+
symbols[0] = value::string(symbol);
427+
return get_warrant_real_time_quote(symbols);
428+
}
429+
430+
value QuoteClient::get_warrant_filter(const utility::string_t symbol, int page_size, int page,
431+
utility::string_t sort_field_name, utility::string_t sort_dir) {
432+
value obj = value::object(true);
433+
obj[P_SYMBOL] = value::string(symbol);
434+
if (page > 0) {
435+
obj[P_PAGE] = page;
436+
}
437+
if (page_size > 0) {
438+
obj[P_PAGE_SIZE] = page_size;
439+
}
440+
if (!sort_field_name.empty()) {
441+
obj[P_SORT_FIELD_NAME] = value::string(sort_field_name);
442+
}
443+
if (!sort_dir.empty()) {
444+
obj[P_SORT_DIR] = value::string(sort_dir);
445+
}
446+
return post(WARRANT_FILTER, obj)[P_ITEMS];
447+
}
448+
449+
value QuoteClient::get_kline_quota(bool with_details) {
450+
value obj = value::object(true);
451+
obj[P_WITH_DETAILS] = with_details;
452+
return post(KLINE_QUOTA, obj);
453+
}
454+
418455

419456
}
420457

0 commit comments

Comments
 (0)