1414#include < chrono>
1515#include < thread>
1616
17-
1817using namespace std ;
1918using namespace web ;
2019using namespace web ::json;
@@ -116,18 +115,17 @@ class TestTradeClient {
116115 // Contract contract = ContractUtil::option_contract(U("AAPL 230721C00185000"));
117116 // Contract contract = ContractUtil::option_contract(U("AAPL 230721P00185000"));
118117 Order order = OrderUtil::limit_order (contract, U (" BUY" ), 3 , U (" 0.18" ));
119- // order.adjust_limit = 0.01;
118+ // order.adjust_limit = 0.01;
120119 value res = trade_client->place_order (order);
121120 // unsigned long long id = res[U("id")].as_number().to_uint64();
122121 ucout << U (" order id: " ) << order.id << endl;
123122 ucout << U (" place order result: " ) << res << endl;
124123 }
125-
126-
124+
127125 static void test_get_order (const std::shared_ptr<TradeClient>& trade_client) {
128- // Contract contract = stock_contract(U("AAPL"), U("USD"));
129- // Order order = OrderUtil::limit_order(contract, U("BUY"), 1, 100.0);
130- // trade_client->place_order(order);
126+ // Contract contract = stock_contract(U("AAPL"), U("USD"));
127+ // Order order = OrderUtil::limit_order(contract, U("BUY"), 1, 100.0);
128+ // trade_client->place_order(order);
131129 Order my_order = trade_client->get_order (31318009878020096 );
132130 ucout << U (" order id " ) << my_order.id << endl;
133131 ucout << U (" order : " ) << my_order.to_string () << endl;
@@ -187,11 +185,9 @@ class TestTradeClient {
187185
188186};
189187
190-
191188/* *
192189 * Test Quote Client
193190 */
194-
195191class TestQuoteClient {
196192public:
197193 static void test_grab_quote_permission (std::shared_ptr<QuoteClient> quote_client) {
@@ -236,8 +232,7 @@ class TestQuoteClient {
236232 value result = quote_client->get_history_timeline (symbols, U (" 2023-01-10" ));
237233 ucout << U (" result: " ) << result << endl;
238234 }
239-
240-
235+
241236 static void test_get_quote_real_time (const std::shared_ptr<QuoteClient> quote_client) {
242237 value symbols = value::array ();
243238 symbols[0 ] = value::string (U (" AAPL" ));
@@ -276,7 +271,7 @@ class TestQuoteClient {
276271 symbols[0 ] = value::string (U (" AAPL" ));
277272 symbols[1 ] = value::string (U (" JD" ));
278273 // ucout << U("symbols ") << symbols << endl;
279- // value result = quote_client->get_kline(symbols, U("day"), -1, -1, U("br"), 5);
274+ // value result = quote_client->get_kline(symbols, U("day"), -1, -1, U("br"), 5);
280275 vector<Kline> result = quote_client->get_kline (symbols, U (" day" ), -1 , -1 , 5 );
281276 ucout << result.at (0 ).to_string () << endl;
282277 }
@@ -355,7 +350,7 @@ class TestQuoteClient {
355350 value symbols = value::array ();
356351 symbols[0 ] = value::string (U (" CL2303" ));
357352 ucout << U (" symbols " ) << symbols << endl;
358- // value result = quote_client->get_future_real_time_quote(symbols);
353+ // value result = quote_client->get_future_real_time_quote(symbols);
359354 auto result = quote_client->get_future_real_time_quote (symbols);
360355 ucout << U (" result: " ) << result.at (0 ).to_string () << endl;
361356 }
@@ -382,7 +377,7 @@ class TestQuoteClient {
382377 static void test_get_option_kline (std::shared_ptr<QuoteClient> quote_client) {
383378 value identifiers = value::array ();
384379 identifiers[0 ] = value::string (U (" AAPL 230224C000150000" ));
385- // value result = quote_client->get_option_kline(identifiers, 1639026000000, 1649026000000);
380+ // value result = quote_client->get_option_kline(identifiers, 1639026000000, 1649026000000);
386381 vector<Kline> result = quote_client->get_option_kline (identifiers, 1639026000000 , 1649026000000 );
387382 ucout << U (" result: " ) << result.at (0 ).to_string () << endl;
388383 }
@@ -441,9 +436,7 @@ class TestTigerApi {
441436 }
442437};
443438
444-
445439std::atomic<bool > keep_running (true );
446-
447440void signal_handler (int signal)
448441{
449442 if (signal == SIGINT || signal == SIGTERM)
@@ -452,7 +445,6 @@ void signal_handler(int signal)
452445 }
453446}
454447
455-
456448class TestPushClient {
457449private:
458450 std::shared_ptr<IPushClient> push_client;
@@ -587,27 +579,22 @@ class TestPushClient {
587579 }
588580};
589581
590-
591582int main ()
592583{
593- /* ************************* set config **********************/
594- ClientConfig config = ClientConfig ();
595- #if 1
596- // config.private_key = U("");
597- // config.tiger_id = U("");
598- // config.account = U("");
599- config.use_full_tick = true ;
600-
601- #else
584+ // Set Tiger OpenAPI SDK configuration
585+ bool sand_box = false ;
586+ ClientConfig config = ClientConfig (sand_box);
602587 config.private_key = U (" " );
603588 config.tiger_id = U (" " );
604589 config.account = U (" " );
605- #endif
606-
590+ config.use_full_tick = true ;
607591 // config.lang = U("en_US");
608592
593+ // Create a push client instance
609594 auto push_client = IPushClient::create_push_client (config);
595+ // Run some push test cases
610596 TestPushClient::test_push_client (push_client, config);
597+
611598 /* *
612599 * QuoteClient
613600 */
@@ -617,16 +604,14 @@ int main()
617604 /* *
618605 * TradeClient
619606 */
620- // std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
621- // TestTradeClient::test_trade(trade_client);
622-
623- /* *
624- * TigerApi
625- */
626- // std::shared_ptr<TigerClient> tigerapi = std::make_shared<TigerClient>(config);
627- // TestTigerApi::test_grab_quote_permission(tigerapi);
628-
607+ // std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
608+ // TestTradeClient::test_trade(trade_client);
629609
610+ /* *
611+ * TigerApi
612+ */
613+ // std::shared_ptr<TigerClient> tigerapi = std::make_shared<TigerClient>(config);
614+ // TestTigerApi::test_grab_quote_permission(tigerapi);
630615
631616 return 0 ;
632617}
0 commit comments