@@ -7348,7 +7348,7 @@ Json::Value FuturesClientCoin::v_funding_rate_history(const Params* params_ptr)
7348
7348
A constructor - called directly by the user
7349
7349
Public client
7350
7350
*/
7351
- OpsClient::OpsClient () : Client(*this )
7351
+ OpsClient::OpsClient () : Client(*this ), _testnet_mode{ 0 }
7352
7352
{};
7353
7353
7354
7354
/* *
@@ -7358,7 +7358,7 @@ OpsClient::OpsClient() : Client(*this)
7358
7358
@param secret - API secret
7359
7359
*/
7360
7360
OpsClient::OpsClient (const std::string key, const std::string secret)
7361
- : Client(*this , key, secret)
7361
+ : Client(*this , key, secret), _testnet_mode{ 0 }
7362
7362
{}
7363
7363
7364
7364
/* *
@@ -7390,8 +7390,8 @@ void OpsClient::v_init_ws_session()
7390
7390
*/
7391
7391
void OpsClient::set_testnet_mode (const bool status)
7392
7392
{
7393
- if (status) this ->_ws_client ->set_host_port (_WS_BASE_FUTURES_USDT_TESTNET, _WS_PORT_FUTURES );
7394
- else this ->_ws_client ->set_host_port (_WS_BASE_FUTURES_USDT, _WS_PORT_FUTURES );
7393
+ if (status) this ->_ws_client ->set_host_port (_WS_BASE_OPS_TESTNET, _WS_PORT_OPS );
7394
+ else this ->_ws_client ->set_host_port (_WS_BASE_OPS, _WS_PORT_OPS );
7395
7395
this ->_testnet_mode = status;
7396
7396
}
7397
7397
@@ -7410,7 +7410,8 @@ bool OpsClient::get_testnet_mode()
7410
7410
*/
7411
7411
std::string OpsClient::v_get_listen_key ()
7412
7412
{
7413
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/userDataStream" ;
7413
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7414
+ full_path += _BASE_REST_OPS + " /vapi/v1/userDataStream" ;
7414
7415
Json::Value response = (this ->_rest_client )->_postreq (full_path);
7415
7416
7416
7417
return response[" response" ][" listenKey" ].asString ();
@@ -7423,7 +7424,8 @@ std::string OpsClient::v_get_listen_key()
7423
7424
*/
7424
7425
Json::Value OpsClient::v_ping_listen_key (const std::string& listen_key)
7425
7426
{
7426
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/userDataStream" + " ?listenKey=" + listen_key;
7427
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7428
+ full_path += (" /vapi/v1/userDataStream?listenKey=" + listen_key);
7427
7429
Json::Value response = listen_key.empty () ? (this ->_rest_client )->_putreq (full_path) : (this ->_rest_client )->_postreq (full_path);
7428
7430
7429
7431
return response;
@@ -7436,7 +7438,8 @@ Json::Value OpsClient::v_ping_listen_key(const std::string& listen_key)
7436
7438
*/
7437
7439
Json::Value OpsClient::v_revoke_listen_key (const std::string& listen_key)
7438
7440
{
7439
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/userDataStream" + " ?listenKey=" + listen_key;
7441
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7442
+ full_path += (" /vapi/v1/userDataStream?listenKey=" + listen_key);
7440
7443
Json::Value response = (this ->_rest_client )->_postreq (full_path);
7441
7444
7442
7445
return response;
@@ -7451,7 +7454,8 @@ Json::Value OpsClient::v_revoke_listen_key(const std::string& listen_key)
7451
7454
*/
7452
7455
bool OpsClient::v_ping_client ()
7453
7456
{
7454
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/ping" ;
7457
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7458
+ full_path += " /vapi/v1/ping" ;
7455
7459
Json::Value ping_response = (this ->_rest_client )->_getreq (full_path)[" response" ];
7456
7460
return (ping_response != Json::nullValue);
7457
7461
}
@@ -7461,7 +7465,8 @@ bool OpsClient::v_ping_client()
7461
7465
*/
7462
7466
unsigned long long OpsClient::v_exchange_time ()
7463
7467
{
7464
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/time" ;
7468
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7469
+ full_path += " /vapi/v1/time" ;
7465
7470
std::string ex_time = (this ->_rest_client )->_getreq (full_path)[" response" ][" serverTime" ].asString ();
7466
7471
7467
7472
return std::atoll (ex_time.c_str ());
@@ -7472,7 +7477,8 @@ unsigned long long OpsClient::v_exchange_time()
7472
7477
*/
7473
7478
Json::Value OpsClient::v_exchange_info ()
7474
7479
{
7475
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/exchangeInfo" ;
7480
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7481
+ full_path += " /vapi/v1/exchangeInfo" ;
7476
7482
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7477
7483
return response;
7478
7484
}
@@ -7483,7 +7489,8 @@ Json::Value OpsClient::v_exchange_info()
7483
7489
Json::Value OpsClient::v_get_ticker (const Params* params_ptr)
7484
7490
{
7485
7491
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7486
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/ticker" + query;
7492
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7493
+ full_path += " /vapi/v1/ticker" + query;
7487
7494
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7488
7495
return response;
7489
7496
}
@@ -7494,7 +7501,8 @@ Json::Value OpsClient::v_get_ticker(const Params* params_ptr)
7494
7501
Json::Value OpsClient::get_spot_index_price (const Params* params_ptr)
7495
7502
{
7496
7503
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7497
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/index" + query;
7504
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7505
+ full_path += " /vapi/v1/index" + query;
7498
7506
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7499
7507
return response;
7500
7508
}
@@ -7505,7 +7513,8 @@ Json::Value OpsClient::get_spot_index_price(const Params* params_ptr)
7505
7513
Json::Value OpsClient::get_mark_price (const Params* params_ptr)
7506
7514
{
7507
7515
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7508
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/mark" + query;
7516
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7517
+ full_path += " /vapi/v1/mark" + query;
7509
7518
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7510
7519
return response;
7511
7520
}
@@ -7518,7 +7527,8 @@ Json::Value OpsClient::get_mark_price(const Params* params_ptr)
7518
7527
Json::Value OpsClient::v_order_book (const Params* params_ptr)
7519
7528
{
7520
7529
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7521
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/depth" + query;
7530
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7531
+ full_path += " /vapi/v1/depth" + query;
7522
7532
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7523
7533
return response;
7524
7534
}
@@ -7529,7 +7539,8 @@ Json::Value OpsClient::v_order_book(const Params* params_ptr)
7529
7539
Json::Value OpsClient::v_klines (const Params* params_ptr)
7530
7540
{
7531
7541
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7532
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/klines" + query;
7542
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7543
+ full_path += " /vapi/v1/klines" + query;
7533
7544
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7534
7545
return response;
7535
7546
}
@@ -7540,7 +7551,8 @@ Json::Value OpsClient::v_klines(const Params* params_ptr)
7540
7551
Json::Value OpsClient::v_public_trades_recent (const Params* params_ptr)
7541
7552
{
7542
7553
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7543
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/trades" + query;
7554
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7555
+ full_path += " /vapi/v1/trades" + query;
7544
7556
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7545
7557
return response;
7546
7558
}
@@ -7551,7 +7563,8 @@ Json::Value OpsClient::v_public_trades_recent(const Params* params_ptr)
7551
7563
Json::Value OpsClient::v_public_trades_historical (const Params* params_ptr)
7552
7564
{
7553
7565
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7554
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/historicalTrades" + query;
7566
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7567
+ full_path += " /vapi/v1/historicalTrades" + query;
7555
7568
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7556
7569
return response;
7557
7570
}
@@ -7562,7 +7575,8 @@ Json::Value OpsClient::v_public_trades_historical(const Params* params_ptr)
7562
7575
Json::Value OpsClient::funds_transfer (const Params* params_ptr)
7563
7576
{
7564
7577
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7565
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/transfer" + query;
7578
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7579
+ full_path += " /vapi/v1/transfer" + query;
7566
7580
Json::Value response = (this ->_rest_client )->_postreq (full_path);
7567
7581
return response;
7568
7582
}
@@ -7573,7 +7587,8 @@ Json::Value OpsClient::funds_transfer(const Params* params_ptr)
7573
7587
Json::Value OpsClient::holding_info (const Params* params_ptr)
7574
7588
{
7575
7589
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7576
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/position" + query;
7590
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7591
+ full_path += " /vapi/v1/position" + query;
7577
7592
Json::Value response = (this ->_rest_client )->_getreq (full_path);
7578
7593
return response;
7579
7594
}
@@ -7583,7 +7598,8 @@ Json::Value OpsClient::holding_info(const Params* params_ptr)
7583
7598
Json::Value OpsClient::account_funding_flow (const Params* params_ptr)
7584
7599
{
7585
7600
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7586
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/bill" + query;
7601
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7602
+ full_path += " /vapi/v1/bill" + query;
7587
7603
Json::Value response = (this ->_rest_client )->_postreq (full_path);
7588
7604
return response;
7589
7605
}
@@ -7593,7 +7609,8 @@ Json::Value OpsClient::account_funding_flow(const Params* params_ptr)
7593
7609
Json::Value OpsClient::batch_orders (const Params* params_ptr)
7594
7610
{
7595
7611
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7596
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/batchOrders" + query;
7612
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7613
+ full_path += " /vapi/v1/batchOrders" + query;
7597
7614
Json::Value response = (this ->_rest_client )->_postreq (full_path);
7598
7615
return response;
7599
7616
}
@@ -7603,7 +7620,8 @@ Json::Value OpsClient::batch_orders(const Params* params_ptr)
7603
7620
Json::Value OpsClient::cancel_batch_orders (const Params* params_ptr)
7604
7621
{
7605
7622
std::string query = params_ptr ? this ->_generate_query (params_ptr) : " " ;
7606
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/batchOrders" + query;
7623
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7624
+ full_path += " /vapi/v1/batchOrders" + query;
7607
7625
Json::Value response = (this ->_rest_client )->_deletereq (full_path);
7608
7626
return response;
7609
7627
}
@@ -7621,9 +7639,10 @@ Json::Value OpsClient::cancel_batch_orders(const Params* params_ptr)
7621
7639
*/
7622
7640
Json::Value OpsClient::v_account_info (const Params* params_ptr)
7623
7641
{
7624
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/account" ;
7625
7642
std::string query = this ->_generate_query (params_ptr, 1 );
7626
- Json::Value response = (this ->_rest_client )->_getreq (full_path + query);
7643
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7644
+ full_path += " /vapi/v1/account" + query;
7645
+ Json::Value response = (this ->_rest_client )->_getreq (full_path);
7627
7646
7628
7647
return response;
7629
7648
}
@@ -7634,9 +7653,10 @@ Json::Value OpsClient::v_account_info(const Params* params_ptr)
7634
7653
*/
7635
7654
Json::Value OpsClient::v_test_new_order (const Params* params_ptr)
7636
7655
{
7637
- std::string full_path = _BASE_REST_OPS_TESTNET + " /vapi/v1/order" ;
7638
7656
std::string query = this ->_generate_query (params_ptr, 1 );
7639
- Json::Value response = (this ->_rest_client )->_postreq (full_path + query);
7657
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7658
+ full_path += " /vapi/v1/order" + query;
7659
+ Json::Value response = (this ->_rest_client )->_postreq (full_path);
7640
7660
7641
7661
return response;
7642
7662
}
@@ -7646,9 +7666,10 @@ Json::Value OpsClient::v_test_new_order(const Params* params_ptr)
7646
7666
*/
7647
7667
Json::Value OpsClient::v_new_order (const Params* params_ptr)
7648
7668
{
7649
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/order" ;
7650
7669
std::string query = this ->_generate_query (params_ptr, 1 );
7651
- Json::Value response = (this ->_rest_client )->_postreq (full_path + query);
7670
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7671
+ full_path += " /vapi/v1/order" + query;
7672
+ Json::Value response = (this ->_rest_client )->_postreq (full_path);
7652
7673
7653
7674
return response;
7654
7675
}
@@ -7658,9 +7679,10 @@ Json::Value OpsClient::v_new_order(const Params* params_ptr)
7658
7679
*/
7659
7680
Json::Value OpsClient::v_cancel_order (const Params* params_ptr)
7660
7681
{
7661
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/order" ;
7662
7682
std::string query = this ->_generate_query (params_ptr, 1 );
7663
- Json::Value response = (this ->_rest_client )->_deletereq (full_path + query);
7683
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7684
+ full_path += " /vapi/v1/order" + query;
7685
+ Json::Value response = (this ->_rest_client )->_deletereq (full_path);
7664
7686
7665
7687
return response;
7666
7688
}
@@ -7670,9 +7692,10 @@ Json::Value OpsClient::v_cancel_order(const Params* params_ptr)
7670
7692
*/
7671
7693
Json::Value OpsClient::v_cancel_all_orders (const Params* params_ptr)
7672
7694
{
7673
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/allOpenOrders" ;
7674
7695
std::string query = this ->_generate_query (params_ptr, 1 );
7675
- Json::Value response = (this ->_rest_client )->_deletereq (full_path + query);
7696
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7697
+ full_path += " /vapi/v1/allOpenOrders" + query;
7698
+ Json::Value response = (this ->_rest_client )->_deletereq (full_path);
7676
7699
7677
7700
return response;
7678
7701
}
@@ -7682,9 +7705,10 @@ Json::Value OpsClient::v_cancel_all_orders(const Params* params_ptr)
7682
7705
*/
7683
7706
Json::Value OpsClient::v_query_order (const Params* params_ptr)
7684
7707
{
7685
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/order" ;
7686
7708
std::string query = this ->_generate_query (params_ptr, 1 );
7687
- Json::Value response = (this ->_rest_client )->_getreq (full_path + query);
7709
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7710
+ full_path += " /vapi/v1/order" + query;
7711
+ Json::Value response = (this ->_rest_client )->_getreq (full_path);
7688
7712
7689
7713
return response;
7690
7714
}
@@ -7694,9 +7718,10 @@ Json::Value OpsClient::v_query_order(const Params* params_ptr)
7694
7718
*/
7695
7719
Json::Value OpsClient::v_open_orders (const Params* params_ptr)
7696
7720
{
7697
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/openOrders" ;
7698
7721
std::string query = this ->_generate_query (params_ptr, 1 );
7699
- Json::Value response = (this ->_rest_client )->_getreq (full_path + query);
7722
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7723
+ full_path += " /vapi/v1/openOrders" + query;
7724
+ Json::Value response = (this ->_rest_client )->_getreq (full_path);
7700
7725
7701
7726
return response;
7702
7727
}
@@ -7706,9 +7731,10 @@ Json::Value OpsClient::v_open_orders(const Params* params_ptr)
7706
7731
*/
7707
7732
Json::Value OpsClient::v_all_orders (const Params* params_ptr)
7708
7733
{
7709
- std::string full_path = _BASE_REST_OPS + " /vapi/v1/historyOrders" ;
7710
7734
std::string query = this ->_generate_query (params_ptr, 1 );
7711
- Json::Value response = (this ->_rest_client )->_getreq (full_path + query);
7735
+ std::string full_path = !this ->_testnet_mode ? _BASE_REST_OPS : _BASE_REST_OPS_TESTNET;
7736
+ full_path += " /vapi/v1/historyOrders" + query;
7737
+ Json::Value response = (this ->_rest_client )->_getreq (full_path);
7712
7738
7713
7739
return response;
7714
7740
}
0 commit comments