77#include " tigerapi/order_util.h"
88#include " tigerapi/utils.h"
99#include " cpprest/details/basic_types.h"
10+ #include " tigerapi/price_util.h"
1011
1112using namespace std ;
1213using namespace web ;
@@ -104,11 +105,12 @@ class TestTradeClient {
104105 }
105106
106107 static void test_place_option_order (const std::shared_ptr<TradeClient>& trade_client) {
107- Contract contract = ContractUtil::option_contract (U (" AAPL " ), U (" 20230721 " ), U (" 185 .0" ), U (" CALL" ), U (" USD" ));
108+ Contract contract = ContractUtil::option_contract (U (" TQQQ " ), U (" 20230915 " ), U (" 43 .0" ), U (" CALL" ), U (" USD" ));
108109 // Contract contract = ContractUtil::option_contract(U("AAPL"), U("20230721"), U("185.0"), U("PUT"), U("USD"));
109110 // Contract contract = ContractUtil::option_contract(U("AAPL 230721C00185000"));
110111 // Contract contract = ContractUtil::option_contract(U("AAPL 230721P00185000"));
111- Order order = OrderUtil::limit_order (contract, U (" BUY" ), 1 , 1.5 );
112+ Order order = OrderUtil::limit_order (contract, U (" BUY" ), 3 , U (" 0.18" ));
113+ // order.adjust_limit = 0.01;
112114 value res = trade_client->place_order (order);
113115 // unsigned long long id = res[U("id")].as_number().to_uint64();
114116 ucout << U (" order id: " ) << order.id << endl;
@@ -166,10 +168,17 @@ class TestTradeClient {
166168 ucout << U (" place forex order: " ) << res << endl;
167169 }
168170
171+ static void test_price_util (const std::shared_ptr<TradeClient>& trade_client) {
172+ value contract = trade_client->get_contract (U (" AAPL" ));
173+ value tick_sizes = contract.at ( U (" tickSizes" ) );
174+ double res = PriceUtil::fix_price_by_tick_size (1.111 , tick_sizes);
175+ ucout << U (" fix price by tick size: " ) << res << endl;
176+ }
169177
170178 static void test_trade (const std::shared_ptr<TradeClient>& trade_client) {
171- TestTradeClient::test_get_contract (trade_client);
179+ TestTradeClient::test_price_util (trade_client);
172180 }
181+
173182};
174183
175184
@@ -191,7 +200,7 @@ class TestQuoteClient {
191200
192201 static void test_get_symbols_names (const std::shared_ptr<QuoteClient> quote_client) {
193202 // value result = quote_client->get_all_symbol_names(U("HK"));
194- value result = quote_client->get_all_symbol_names (Market::HK);
203+ value result = quote_client->get_all_symbol_names (Market::HK, false );
195204 ucout << U (" result: " ) << result << endl;
196205 }
197206
@@ -227,7 +236,8 @@ class TestQuoteClient {
227236 value symbols = value::array ();
228237 symbols[0 ] = value::string (U (" AAPL" ));
229238 symbols[1 ] = value::string (U (" JD" ));
230- auto result = quote_client->get_quote_real_time (symbols);
239+ auto result = quote_client->get_quote_real_time_value (symbols);
240+ vector<RealtimeQuote> result1 = quote_client->get_quote_real_time (symbols);
231241 ucout << U (" result: " ) << result.at (0 ).to_string () << endl;
232242 }
233243
@@ -428,10 +438,11 @@ class TestTigerApi {
428438int main ()
429439{
430440 /* ************************* set config **********************/
431- ClientConfig config = ClientConfig (true );
432- config.private_key = U (" MIICXQIBAAKBgQC1amZa5YsGTklry7DAsUBOwXJCgrsZZtB21PImw/yLmrbqRfsS3vawvMigLWcCwIDnHa+hpdpeze0eHIwbZzJzUDGvRALYK9t3D8pwPVxpwX1OF8RfHCM7YQvSOvPPnHHuVQvKaR7NNm1/WmvGXC9kVJdkYQ7kCmh52siFoy1MLQIDAQABAoGAVabcmIHTt7ByncBXvUJymDxhE+HhMEcImXJEueTCca8kOUu9FNXMJvmax3VoMzZsJbIwX+OMTEJxd0wHIlEA0gECjDwFK4Q42q+ptO4QABJQVSC6I+dOt2OIY28uvT3rkenOO8KRIDt4F52PFd71ZdB1aaXixORORq1MdSLi8EkCQQDiviAB+L5R/HVxwxvqZfJ530OtFd5IipZC9YZlY1CtXWCmu89LK7UUlEuNXyGsOxyz5jLqFuNRsie5AC23tfEPAkEAzNMCa8axJWfPZIH4tGrbZ1F3I41BQdgp2zBmR7AyUMBDkli86OzmJ7QUCJA/PJxK43/IYUWm4OU5Q+SvXCr3AwJBAJTBj1Y7zwES1CpSitn5EF+MbmX71t1YrsQ3OHkD80YJ4QMCbDkw75gUwox5QSoxjd8ow3Z4laJfc1gYGeZQ41kCQQCCiQwm8cceBq3W6To+iUdw7itWngRz2Ta7uXnFwFYgvpeR4jnq3GfF7+9AkeWrVBQqLtrem0xCUfQP/+N+gudPAkBFLbt78/MpQGEDc7jyu/KE5Mp4wMMDQQwch9VLvsAZwWLysB6rZWpo3jIfp9zZ7c3zOYGNMWAZjtMmNkRJ8COH" );
433- config.tiger_id = U (" 1" );
434- config.account = U (" 402901" );
441+ ClientConfig config = ClientConfig ();
442+ config.private_key = U (" " );
443+ config.tiger_id = U (" " );
444+ config.account = U (" " );
445+
435446
436447
437448
0 commit comments