|
10 | 10 | #include "tigerapi/utils.h" |
11 | 11 | #include "cpprest/details/basic_types.h" |
12 | 12 | #include "tigerapi/price_util.h" |
13 | | -#include "tigerapi/easylogging++.h" |
14 | 13 | #include <chrono> |
15 | 14 | #include <thread> |
| 15 | +#include "tigerapi/logger.h" |
16 | 16 |
|
17 | 17 | using namespace std; |
18 | 18 | using namespace web; |
@@ -406,7 +406,7 @@ class TestQuoteClient { |
406 | 406 |
|
407 | 407 |
|
408 | 408 | static void test_quote(const std::shared_ptr<QuoteClient> quote_client) { |
409 | | - TestQuoteClient::test_get_kline_quota(quote_client); |
| 409 | + TestQuoteClient::test_get_quote_delay(quote_client); |
410 | 410 | } |
411 | 411 | }; |
412 | 412 |
|
@@ -469,6 +469,19 @@ class TestPushClient { |
469 | 469 | push_client->subscribe_tick(symbols); |
470 | 470 | } |
471 | 471 |
|
| 472 | + void error_callback(const tigeropen::push::pb::Response& data) { |
| 473 | + ucout << "Error callback: " << std::endl; |
| 474 | + ucout << "- code: " << data.code() << std::endl; |
| 475 | + ucout << "- msg: " << utility::conversions::to_string_t(data.msg()) << std::endl; |
| 476 | + } |
| 477 | + |
| 478 | + void kickout_callback(const tigeropen::push::pb::Response& data) { |
| 479 | + ucout << "Kickout callback: " << std::endl; |
| 480 | + ucout << "- code: " << data.code() << std::endl; |
| 481 | + ucout << "- msg: " << utility::conversions::to_string_t(data.msg()) << std::endl; |
| 482 | + |
| 483 | + } |
| 484 | + |
472 | 485 | void position_changed_callback(const tigeropen::push::pb::PositionData& data) { |
473 | 486 | ucout << "Position changed:" << std::endl; |
474 | 487 | ucout << "- symbol: " << utility::conversions::to_string_t(data.symbol()) << std::endl; |
@@ -542,6 +555,8 @@ class TestPushClient { |
542 | 555 |
|
543 | 556 | void start_test(ClientConfig config) { |
544 | 557 | push_client->set_connected_callback(std::bind(&TestPushClient::connected_callback, this)); |
| 558 | + push_client->set_error_callback(std::bind(&TestPushClient::error_callback, this, std::placeholders::_1)); |
| 559 | + push_client->set_kickout_callback(std::bind(&TestPushClient::kickout_callback, this, std::placeholders::_1)); |
545 | 560 | push_client->set_position_changed_callback(std::bind(&TestPushClient::position_changed_callback, this, std::placeholders::_1)); |
546 | 561 | push_client->set_order_changed_callback(std::bind(&TestPushClient::order_changed_callback, this, std::placeholders::_1)); |
547 | 562 | push_client->set_asset_changed_callback(std::bind(&TestPushClient::asset_changed_callback, this, std::placeholders::_1)); |
@@ -579,27 +594,31 @@ class TestPushClient { |
579 | 594 | } |
580 | 595 | }; |
581 | 596 |
|
582 | | -int main() |
583 | | -{ |
| 597 | +int main(int argc, char* argv[]) { |
| 598 | + LoggerConfig::set_log_level(el::Level::Debug); |
584 | 599 | //Set Tiger OpenAPI SDK configuration |
585 | 600 | bool sand_box = false; |
586 | | - ClientConfig config = ClientConfig(sand_box); |
587 | | - config.private_key = U(""); |
588 | | - config.tiger_id = U(""); |
589 | | - config.account = U(""); |
| 601 | + ClientConfig config = ClientConfig(false, U("../openapi_cpp_test/")); |
| 602 | + //config.set_server_url(U("http://127.0.0.1:8085/gateway")); |
| 603 | + //config.set_server_public_key(SANDBOX_TIGER_PUBLIC_KEY); |
| 604 | + //ClientConfig config = ClientConfig(false); |
| 605 | + |
| 606 | + // config.private_key = U(""); |
| 607 | + // config.tiger_id = U(""); |
| 608 | + // config.account = U(""); |
590 | 609 | config.use_full_tick = true; |
591 | 610 | //config.lang = U("en_US"); |
592 | 611 |
|
593 | 612 | //Create a push client instance |
594 | | - auto push_client = IPushClient::create_push_client(config); |
| 613 | +// auto push_client = IPushClient::create_push_client(config); |
595 | 614 | //Run some push test cases |
596 | | - TestPushClient::test_push_client(push_client, config); |
| 615 | +// TestPushClient::test_push_client(push_client, config); |
597 | 616 |
|
598 | 617 | /** |
599 | 618 | * QuoteClient |
600 | 619 | */ |
601 | | - //std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config); |
602 | | - //TestQuoteClient::test_quote(quote_client); |
| 620 | + std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config); |
| 621 | + TestQuoteClient::test_quote(quote_client); |
603 | 622 |
|
604 | 623 | /** |
605 | 624 | * TradeClient |
|
0 commit comments