Skip to content

Commit c7e98e1

Browse files
committed
endpoints for coin margined
1 parent e85e3e3 commit c7e98e1

File tree

2 files changed

+143
-20
lines changed

2 files changed

+143
-20
lines changed

include/Exchange_Client.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,9 @@ class FuturesClient : public Client<FuturesClient<CT>>
462462
Json::Value position_info(const Params* params_ptr = nullptr);
463463
Json::Value get_income_history(const Params* params_ptr);
464464
Json::Value get_leverage_bracket(const Params* params_ptr = nullptr);
465-
466-
467-
// -- unique to USDT endpoint
468-
469-
Json::Value pos_adl_quantile_est(const Params* params_ptr = nullptr);
465+
Json::Value users_force_orders(const Params* params_ptr = nullptr);
466+
Json::Value pos_adl_quantile_est(const Params* params_ptr = nullptr);
467+
Json::Value get_user_comission_rate(const Params* params_ptr);
470468

471469
// ------------------- inter-future crtp ONLY
472470

@@ -475,6 +473,7 @@ class FuturesClient : public Client<FuturesClient<CT>>
475473
Json::Value mark_price(const Params* params_ptr = nullptr);
476474
Json::Value public_liquidation_orders(const Params* params_ptr);
477475
Json::Value open_interest(const Params* params_ptr);
476+
Json::Value composite_index_symbol_info(const Params* params_ptr);
478477

479478

480479
// note that the following four might be only for coin margined market data
@@ -556,6 +555,7 @@ class FuturesClientUSDT : public FuturesClient<FuturesClientUSDT>
556555
Json::Value v_mark_price(const Params* params_ptr);
557556
Json::Value v_public_liquidation_orders(const Params* params_ptr);
558557
Json::Value v_open_interest(const Params* params_ptr);
558+
Json::Value v_composite_index_symbol_info(const Params* params_ptr = nullptr);
559559

560560

561561
// note that the following four might be only for coin margined market data
@@ -597,11 +597,9 @@ class FuturesClientUSDT : public FuturesClient<FuturesClientUSDT>
597597
Json::Value v_position_info(const Params* params_ptr);
598598
Json::Value v_get_income_history(const Params* params_ptr);
599599
Json::Value v_get_leverage_bracket(const Params* params_ptr);
600-
601-
602-
// -- unique to USDT endpoint
603-
604-
Json::Value v_pos_adl_quantile_est(const Params* params_ptr);
600+
Json::Value v_users_force_orders(const Params* params_ptr = nullptr);
601+
Json::Value v_pos_adl_quantile_est(const Params* params_ptr = nullptr);
602+
Json::Value v_get_user_comission_rate(const Params* params_ptr);
605603

606604

607605
// WS Streams
@@ -670,7 +668,7 @@ class FuturesClientCoin : public FuturesClient<FuturesClientCoin>
670668
Json::Value v_mark_price(const Params* params_ptr);
671669
Json::Value v_public_liquidation_orders(const Params* params_ptr);
672670
Json::Value v_open_interest(const Params* params_ptr);
673-
671+
Json::Value v_composite_index_symbol_info(const Params* params_ptr = nullptr);
674672

675673
// note that the following four might be only for coin margined market data
676674
Json::Value v_continues_klines(const Params* params_ptr);
@@ -710,12 +708,11 @@ class FuturesClientCoin : public FuturesClient<FuturesClientCoin>
710708
Json::Value v_position_info(const Params* params_ptr);
711709
Json::Value v_get_income_history(const Params* params_ptr);
712710
Json::Value v_get_leverage_bracket(const Params* params_ptr);
711+
Json::Value v_users_force_orders(const Params* params_ptr = nullptr);
712+
Json::Value v_pos_adl_quantile_est(const Params* params_ptr = nullptr);
713+
Json::Value v_get_user_comission_rate(const Params* params_ptr);
713714

714715

715-
// -- unique to USDT endpoint
716-
717-
Json::Value v_pos_adl_quantile_est(const Params* params_ptr);
718-
719716
// WS Streams
720717

721718

src/Binance_Client.cpp

Lines changed: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,6 +4925,25 @@ Json::Value FuturesClient<CT>::open_interest(const Params* params_ptr)
49254925
}
49264926
}
49274927

4928+
/**
4929+
Composite Index Symbol Information
4930+
@param params_ptr - a pointer to the request Params object
4931+
@return json returned by the request
4932+
*/
4933+
template<typename CT>
4934+
Json::Value FuturesClient<CT>::composite_index_symbol_info(const Params* params_ptr)
4935+
{
4936+
try
4937+
{
4938+
return static_cast<CT*>(this)->v_open_interest(params_ptr);
4939+
}
4940+
catch (ClientException e)
4941+
{
4942+
e.append_to_traceback(std::string(__FUNCTION__));
4943+
throw(e);
4944+
}
4945+
}
4946+
49284947
/**
49294948
Continues Contract Kline/Candlestick Data
49304949
*If startTime and endTime are not sent, the most recent klines are returned
@@ -5352,6 +5371,25 @@ Json::Value FuturesClient<CT>::get_leverage_bracket(const Params* params_ptr)
53525371
}
53535372
}
53545373

5374+
/**
5375+
User's Force Orders (USER_DATA)
5376+
@param params_ptr - a pointer to the request Params object
5377+
@return json returned by the request
5378+
*/
5379+
template<typename CT>
5380+
Json::Value FuturesClient<CT>::users_force_orders(const Params* params_ptr)
5381+
{
5382+
try
5383+
{
5384+
return static_cast<CT*>(this)->v_users_force_orders(params_ptr);
5385+
}
5386+
catch (ClientException e)
5387+
{
5388+
e.append_to_traceback(std::string(__FUNCTION__));
5389+
throw(e);
5390+
}
5391+
}
5392+
53555393
/**
53565394
Position ADL Quantile Estimation
53575395
*Values update every 30s.
@@ -5380,6 +5418,24 @@ Json::Value FuturesClient<CT>::pos_adl_quantile_est(const Params* params_ptr)
53805418
}
53815419
}
53825420

5421+
/**
5422+
User Commission Rate
5423+
@param params_ptr - a pointer to the request Params object
5424+
@return json returned by the request
5425+
*/
5426+
template<typename CT>
5427+
Json::Value FuturesClient<CT>::get_user_comission_rate(const Params* params_ptr)
5428+
{
5429+
try
5430+
{
5431+
return static_cast<CT*>(this)->v_get_user_comission_rate(params_ptr);
5432+
}
5433+
catch (ClientException e)
5434+
{
5435+
e.append_to_traceback(std::string(__FUNCTION__));
5436+
throw(e);
5437+
}
5438+
}
53835439

53845440
// ------------------------------ End | FuturesClient CRTP methods - Trade Implementations
53855441

@@ -5739,6 +5795,18 @@ Json::Value FuturesClientUSDT::v_open_interest(const Params* params_ptr)
57395795
return response;
57405796
}
57415797

5798+
/**
5799+
CRTP of composite_index_symbol_info()
5800+
*/
5801+
Json::Value FuturesClientUSDT::v_composite_index_symbol_info(const Params* params_ptr)
5802+
{
5803+
std::string query = params_ptr ? this->_generate_query(params_ptr) : "";
5804+
std::string full_path = !this->_testnet_mode ? _BASE_REST_FUTURES_USDT : _BASE_REST_FUTURES_TESTNET;
5805+
full_path += ("/fapi/v1/indexInfo" + query);
5806+
Json::Value response = (this->_rest_client)->_getreq(full_path);
5807+
return response;
5808+
}
5809+
57425810
// ~~~ Do not exist for this client
57435811

57445812
/**
@@ -6083,6 +6151,16 @@ Json::Value FuturesClientUSDT::v_get_leverage_bracket(const Params* params_ptr)
60836151
return response;
60846152
}
60856153

6154+
/**
6155+
CRTP of users_force_orders()
6156+
*/
6157+
Json::Value FuturesClientUSDT::v_users_force_orders(const Params* params_ptr)
6158+
{
6159+
MissingEndpoint e{};
6160+
e.append_to_traceback(std::string(__FUNCTION__));
6161+
throw(e);
6162+
}
6163+
60866164
/**
60876165
CRTP of pos_adl_quantile_est()
60886166
*/
@@ -6096,6 +6174,16 @@ Json::Value FuturesClientUSDT::v_pos_adl_quantile_est(const Params* params_ptr)
60966174
return response;
60976175
}
60986176

6177+
/**
6178+
CRTP of get_user_comission_rate() - Does not exist for USDT
6179+
*/
6180+
Json::Value FuturesClientUSDT::v_get_user_comission_rate(const Params* params_ptr)
6181+
{
6182+
MissingEndpoint e{};
6183+
e.append_to_traceback(std::string(__FUNCTION__));
6184+
throw(e);
6185+
}
6186+
60996187
// ------------------------------ End | FuturesClientUSDT CRTP methods - Trade Implementations
61006188

61016189
// ------------------------------ Start | FuturesClientUSDT CRTP methods - WS Streams
@@ -6627,19 +6715,48 @@ Json::Value FuturesClientCoin::v_get_leverage_bracket(const Params* params_ptr)
66276715
return response;
66286716
}
66296717

6718+
/**
6719+
CRTP of users_force_orders()
6720+
*/
6721+
Json::Value FuturesClientCoin::v_users_force_orders(const Params* params_ptr)
6722+
{
6723+
std::string query = this->_generate_query(params_ptr, 1);
6724+
std::string full_path = !this->_testnet_mode ? _BASE_REST_FUTURES_COIN : _BASE_REST_FUTURES_TESTNET;
6725+
full_path += ("/dapi/v1/forceOrders" + query);
6726+
Json::Value response = (this->_rest_client)->_getreq(full_path);
6727+
6728+
return response;
6729+
}
6730+
66306731
/**
66316732
CRTP of pos_adl_quantile_est()
66326733
*/
66336734
Json::Value FuturesClientCoin::v_pos_adl_quantile_est(const Params* params_ptr)
66346735
{
6635-
MissingEndpoint e{};
6636-
e.append_to_traceback(std::string(__FUNCTION__));
6637-
throw(e);
6736+
std::string query = this->_generate_query(params_ptr, 1);
6737+
std::string full_path = !this->_testnet_mode ? _BASE_REST_FUTURES_COIN : _BASE_REST_FUTURES_TESTNET;
6738+
full_path += ("/dapi/v1/adlQuantile" + query);
6739+
Json::Value response = (this->_rest_client)->_getreq(full_path);
6740+
6741+
return response;
66386742
}
66396743

6640-
// ------------------------------ End | FuturesClientUSDT CRTP methods - Trade Implementations
6744+
/**
6745+
CRTP of get_user_comission_rate()
6746+
*/
6747+
Json::Value FuturesClientCoin::v_get_user_comission_rate(const Params* params_ptr)
6748+
{
6749+
std::string query = this->_generate_query(params_ptr, 1);
6750+
std::string full_path = !this->_testnet_mode ? _BASE_REST_FUTURES_COIN : _BASE_REST_FUTURES_TESTNET;
6751+
full_path += ("/dapi/v1/commissionRate" + query);
6752+
Json::Value response = (this->_rest_client)->_getreq(full_path);
66416753

6642-
// ------------------------------ Start | FuturesClientUSDT CRTP methods - WS Streams
6754+
return response;
6755+
}
6756+
6757+
// ------------------------------ End | FuturesClientCoin CRTP methods - Trade Implementations
6758+
6759+
// ------------------------------ Start | FuturesClientCoin CRTP methods - WS Streams
66436760

66446761

66456762
/**
@@ -6734,6 +6851,15 @@ Json::Value FuturesClientCoin::v_open_interest(const Params* params_ptr)
67346851
return response;
67356852
}
67366853

6854+
/**
6855+
CRTP of composite_index_symbol_info() - Missing endpoint for Coin margined
6856+
*/
6857+
Json::Value FuturesClientCoin::v_composite_index_symbol_info(const Params* params_ptr)
6858+
{
6859+
MissingEndpoint e{};
6860+
e.append_to_traceback(std::string(__FUNCTION__));
6861+
throw(e);
6862+
}
67376863

67386864
// ~~~ Unique for this Client
67396865

0 commit comments

Comments
 (0)