Skip to content

Commit 4b05d93

Browse files
committed
new endpoints
1 parent c7e98e1 commit 4b05d93

File tree

3 files changed

+347
-10
lines changed

3 files changed

+347
-10
lines changed

include/Exchange_Client.h

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ class FuturesClient : public Client<FuturesClient<CT>>
465465
Json::Value users_force_orders(const Params* params_ptr = nullptr);
466466
Json::Value pos_adl_quantile_est(const Params* params_ptr = nullptr);
467467
Json::Value get_user_comission_rate(const Params* params_ptr);
468+
Json::Value api_quant_trading_rules(const Params* params_ptr = nullptr);
469+
Json::Value get_blvt_kline_history(const Params* params_ptr);
470+
Json::Value get_composite_index_symbol_info(const Params* params_ptr = nullptr);
468471

469472
// ------------------- inter-future crtp ONLY
470473

@@ -496,6 +499,15 @@ class FuturesClient : public Client<FuturesClient<CT>>
496499
template <typename FT>
497500
unsigned int stream_liquidation_orders_all(std::string& buffer, FT& functor);
498501

502+
template <typename FT>
503+
unsigned int stream_blvt_info(std::string& buffer, FT& functor, std::string token_name);
504+
505+
template <typename FT>
506+
unsigned int stream_blvt_klines(std::string& buffer, FT& functor, std::string token_name, std::string interval);
507+
508+
template <typename FT>
509+
unsigned int stream_composite_index_symbol(std::string& buffer, FT& functor, std::string token_name);
510+
499511
template <typename FT>
500512
unsigned int stream_markprice_all(const std::string& pair, std::string& buffer, FT& functor); // only USDT
501513

@@ -556,10 +568,9 @@ class FuturesClientUSDT : public FuturesClient<FuturesClientUSDT>
556568
Json::Value v_public_liquidation_orders(const Params* params_ptr);
557569
Json::Value v_open_interest(const Params* params_ptr);
558570
Json::Value v_composite_index_symbol_info(const Params* params_ptr = nullptr);
559-
560-
561-
// note that the following four might be only for coin margined market data
562571
Json::Value v_continues_klines(const Params* params_ptr);
572+
573+
// note that the following might be only for coin margined market data
563574
Json::Value v_index_klines(const Params* params_ptr);
564575
Json::Value v_mark_klines(const Params* params_ptr);
565576

@@ -600,7 +611,9 @@ class FuturesClientUSDT : public FuturesClient<FuturesClientUSDT>
600611
Json::Value v_users_force_orders(const Params* params_ptr = nullptr);
601612
Json::Value v_pos_adl_quantile_est(const Params* params_ptr = nullptr);
602613
Json::Value v_get_user_comission_rate(const Params* params_ptr);
603-
614+
Json::Value v_api_quant_trading_rules(const Params* params_ptr = nullptr);
615+
Json::Value v_get_blvt_kline_history(const Params* params_ptr);
616+
Json::Value v_get_composite_index_symbol_info(const Params* params_ptr = nullptr);
604617

605618
// WS Streams
606619

@@ -615,6 +628,15 @@ class FuturesClientUSDT : public FuturesClient<FuturesClientUSDT>
615628

616629
template <typename FT>
617630
unsigned int v_stream_markprice_by_pair(const std::string& pair, std::string& buffer, FT& functor, unsigned int interval); // only coin
631+
632+
template <typename FT>
633+
unsigned int v_stream_blvt_info(std::string& buffer, FT& functor, std::string token_name); // only USDT
634+
635+
template <typename FT>
636+
unsigned int v_stream_blvt_klines(std::string& buffer, FT& functor, std::string token_name, std::string interval); // only USDT
637+
638+
template <typename FT>
639+
unsigned int v_stream_composite_index_symbol(std::string& buffer, FT& functor, std::string token_name); // only USDT
618640

619641
template <typename FT>
620642
unsigned int v_stream_kline_contract(const std::string& pair_and_type, std::string& buffer, FT& functor, std::string interval); // only coin
@@ -711,7 +733,9 @@ class FuturesClientCoin : public FuturesClient<FuturesClientCoin>
711733
Json::Value v_users_force_orders(const Params* params_ptr = nullptr);
712734
Json::Value v_pos_adl_quantile_est(const Params* params_ptr = nullptr);
713735
Json::Value v_get_user_comission_rate(const Params* params_ptr);
714-
736+
Json::Value v_api_quant_trading_rules(const Params* params_ptr = nullptr);
737+
Json::Value v_get_blvt_kline_history(const Params* params_ptr);
738+
Json::Value v_get_composite_index_symbol_info(const Params* params_ptr = nullptr);
715739

716740
// WS Streams
717741

@@ -726,6 +750,15 @@ class FuturesClientCoin : public FuturesClient<FuturesClientCoin>
726750

727751
template <typename FT>
728752
unsigned int v_stream_markprice_by_pair(const std::string& pair, std::string& buffer, FT& functor, unsigned int interval); // only coin
753+
754+
template <typename FT>
755+
unsigned int v_stream_blvt_info(std::string& buffer, FT& functor, std::string token_name); // only USDT
756+
757+
template <typename FT>
758+
unsigned int v_stream_blvt_klines(std::string& buffer, FT& functor, std::string token_name, std::string interval); // only USDT
759+
760+
template <typename FT>
761+
unsigned int v_stream_composite_index_symbol(std::string& buffer, FT& functor, std::string token_name); // only USDT
729762

730763
template <typename FT>
731764
unsigned int v_stream_kline_contract(const std::string& pair_and_type, std::string& buffer, FT& functor, std::string interval); // only coin

include/inl_files/Websocket_methods.inl

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,73 @@ unsigned int FuturesClient<CT>::stream_liquidation_orders_all(std::string& buffe
319319
}
320320
}
321321

322+
/**
323+
BLVT Info Streams
324+
@param buffer - a reference of the string buffer to load responses to
325+
@param functor - a reference to the functor object to be called as callback
326+
@param token_name - token name
327+
@return an unsigned int representing success
328+
*/
329+
template<typename CT>
330+
template <typename FT>
331+
unsigned int FuturesClient<CT>::stream_blvt_info(std::string& buffer, FT& functor, std::string token_name)
332+
{
333+
try
334+
{
335+
return static_cast<CT*>(this)->v_stream_blvt_info(buffer, functor, token_name);
336+
}
337+
catch (ClientException e)
338+
{
339+
e.append_to_traceback(std::string(__FUNCTION__));
340+
throw(e);
341+
}
342+
}
343+
344+
/**
345+
BLVT NAV Kline/Candlestick Streams
346+
@param buffer - a reference of the string buffer to load responses to
347+
@param functor - a reference to the functor object to be called as callback
348+
@param token_name - token name
349+
@param interval - interval of klines
350+
@return an unsigned int representing success
351+
*/
352+
template<typename CT>
353+
template <typename FT>
354+
unsigned int FuturesClient<CT>::stream_blvt_klines(std::string& buffer, FT& functor, std::string token_name, std::string interval)
355+
{
356+
try
357+
{
358+
return static_cast<CT*>(this)->v_stream_blvt_klines(buffer, functor, token_name, interval);
359+
}
360+
catch (ClientException e)
361+
{
362+
e.append_to_traceback(std::string(__FUNCTION__));
363+
throw(e);
364+
}
365+
}
366+
367+
/**
368+
BLVT NAV Kline/Candlestick Streams
369+
@param buffer - a reference of the string buffer to load responses to
370+
@param functor - a reference to the functor object to be called as callback
371+
@param token_name - token name
372+
@return an unsigned int representing success
373+
*/
374+
template<typename CT>
375+
template <typename FT>
376+
unsigned int FuturesClient<CT>::stream_composite_index_symbol(std::string& buffer, FT& functor, std::string token_name)
377+
{
378+
try
379+
{
380+
return static_cast<CT*>(this)->v_stream_composite_index_symbol(buffer, functor, token_name);
381+
}
382+
catch (ClientException e)
383+
{
384+
e.append_to_traceback(std::string(__FUNCTION__));
385+
throw(e);
386+
}
387+
}
388+
322389
/**
323390
CRTP of stream_userStream
324391
*/
@@ -445,6 +512,39 @@ unsigned int FuturesClientCoin::v_stream_markprice_by_pair(const std::string& pa
445512
return this->_ws_client->running_streams[stream_query];
446513
}
447514

515+
/**
516+
CRTP of stream_blvt_info
517+
*/
518+
template <typename FT>
519+
unsigned int FuturesClientCoin::v_stream_blvt_info(std::string& buffer, FT& functor, std::string token_name)
520+
{
521+
MissingEndpoint e{};
522+
e.append_to_traceback(std::string(__FUNCTION__));
523+
throw(e);
524+
}
525+
526+
/**
527+
CRTP of stream_blvt_klines
528+
*/
529+
template <typename FT>
530+
unsigned int FuturesClientCoin::v_stream_blvt_klines(std::string& buffer, FT& functor, std::string token_name, std::string interval)
531+
{
532+
MissingEndpoint e{};
533+
e.append_to_traceback(std::string(__FUNCTION__));
534+
throw(e);
535+
}
536+
537+
/**
538+
CRTP of stream_composite_index_symbol
539+
*/
540+
template <typename FT>
541+
unsigned int FuturesClientCoin::v_stream_composite_index_symbol(std::string& buffer, FT& functor, std::string token_name)
542+
{
543+
MissingEndpoint e{};
544+
e.append_to_traceback(std::string(__FUNCTION__));
545+
throw(e);
546+
}
547+
448548
/**
449549
CRTP of stream_kline_contract
450550
*/
@@ -493,6 +593,79 @@ unsigned int FuturesClientCoin::v_stream_kline_markprice(const std::string& symb
493593
return this->_ws_client->running_streams[stream_query];
494594
}
495595

596+
597+
/**
598+
CRTP of stream_blvt_info
599+
*/
600+
template <typename FT>
601+
unsigned int FuturesClientUSDT::v_stream_blvt_info(std::string& buffer, FT& functor, std::string token_name)
602+
{
603+
try
604+
{
605+
std::string stream_name = token_name + "@nav_Kline_";
606+
std::string stream_query = "/ws/" + stream_name;
607+
if (this->_ws_client->is_open(stream_query))
608+
{
609+
this->_ws_client->close_stream(stream_query);
610+
}
611+
this->_ws_client->_stream_manager<FT>(stream_name, stream_query, buffer, functor);
612+
return this->_ws_client->running_streams[stream_query];
613+
}
614+
catch (ClientException e)
615+
{
616+
e.append_to_traceback(std::string(__FUNCTION__));
617+
throw(e);
618+
}
619+
}
620+
621+
/**
622+
CRTP of stream_blvt_klines
623+
*/
624+
template <typename FT>
625+
unsigned int FuturesClientUSDT::v_stream_blvt_klines(std::string& buffer, FT& functor, std::string token_name, std::string interval)
626+
{
627+
try
628+
{
629+
std::string stream_name = token_name + "@nav_Kline_" + interval;
630+
std::string stream_query = "/ws/" + stream_name;
631+
if (this->_ws_client->is_open(stream_query))
632+
{
633+
this->_ws_client->close_stream(stream_query);
634+
}
635+
this->_ws_client->_stream_manager<FT>(stream_name, stream_query, buffer, functor);
636+
return this->_ws_client->running_streams[stream_query];
637+
}
638+
catch (ClientException e)
639+
{
640+
e.append_to_traceback(std::string(__FUNCTION__));
641+
throw(e);
642+
}
643+
}
644+
645+
/**
646+
CRTP of stream_composite_index_symbol
647+
*/
648+
template <typename FT>
649+
unsigned int FuturesClientUSDT::v_stream_composite_index_symbol(std::string& buffer, FT& functor, std::string token_name)
650+
{
651+
try
652+
{
653+
std::string stream_name = token_name + "@compositeIndex";
654+
std::string stream_query = "/ws/" + stream_name;
655+
if (this->_ws_client->is_open(stream_query))
656+
{
657+
this->_ws_client->close_stream(stream_query);
658+
}
659+
this->_ws_client->_stream_manager<FT>(stream_name, stream_query, buffer, functor);
660+
return this->_ws_client->running_streams[stream_query];
661+
}
662+
catch (ClientException e)
663+
{
664+
e.append_to_traceback(std::string(__FUNCTION__));
665+
throw(e);
666+
}
667+
}
668+
496669
/**
497670
CRTP of v_stream_userStream
498671
*/

0 commit comments

Comments
 (0)