@@ -278,6 +278,48 @@ namespace TIGER_API {
278278 parent_id, enum_to_str (sort_by), enum_to_str (seg_type));
279279 }
280280
281+ value TradeClient::get_transactions (utility::string_t account, long order_id) {
282+ value obj = value::object (true );
283+ obj[P_ACCOUNT] = get_account_param (account);
284+ obj[U (" order_id" )] = (long long ) order_id;
285+ return post (ORDER_TRANSACTIONS, obj)[P_ITEMS];
286+ }
287+
288+ value TradeClient::get_transactions (utility::string_t account, utility::string_t symbol, utility::string_t sec_type,
289+ long start_time, time_t end_time,
290+ int limit, utility::string_t expiry, utility::string_t strike, utility::string_t right,
291+ long order_id) {
292+ value obj = value::object (true );
293+ obj[P_ACCOUNT] = get_account_param (account);
294+ if (order_id != 0 ) {
295+ obj[U (" order_id" )] = (long long ) order_id;
296+ }
297+ if (!sec_type.empty ()) {
298+ obj[U (" sec_type" )] = value::string (sec_type);
299+ }
300+ if (!symbol.empty ()) {
301+ obj[U (" symbol" )] = value::string (symbol);
302+ }
303+ if (!expiry.empty ()) {
304+ obj[U (" expiry" )] = value::string (expiry);
305+ }
306+ if (!strike.empty ()) {
307+ obj[U (" strike" )] = value::string (strike);
308+ }
309+ if (!right.empty ()) {
310+ obj[U (" right" )] = value::string (right);
311+ }
312+ if (start_time != 0 ) {
313+ obj[U (" start_time" )] = (long long ) start_time;
314+ }
315+ if (end_time != 0 ) {
316+ obj[U (" end_time" )] = (long long ) end_time;
317+ }
318+ if (limit != 0 ) {
319+ obj[U (" limit" )] = (long long ) limit;
320+ }
321+ return post (ORDER_TRANSACTIONS, obj)[P_ITEMS];
322+ }
281323
282324 value TradeClient::get_contract (utility::string_t symbol, utility::string_t sec_type, utility::string_t currency, utility::string_t exchange, time_t expiry,
283325 utility::string_t strike, utility::string_t right) {
@@ -313,8 +355,50 @@ namespace TIGER_API {
313355 enum_to_str (right));
314356 }
315357
316- value TradeClient::place_order (value &order) {
358+ value TradeClient::get_contracts (const value &symbols, utility::string_t sec_type, utility::string_t currency,
359+ utility::string_t exchange, time_t expiry, utility::string_t strike,
360+ utility::string_t right) {
361+ value obj = value::object (true );
362+ obj[P_ACCOUNT] = get_account_param ();
363+ obj[P_SYMBOLS] = symbols;
364+ if (!sec_type.empty ()) {
365+ obj[P_SEC_TYPE] = value::string (sec_type);
366+ }
367+ if (!currency.empty ()) {
368+ obj[P_CURRENCY] = value::string (currency);
369+ }
370+ if (!exchange.empty ()) {
371+ obj[P_EXCHANGE] = value::string (exchange);
372+ }
373+ if (expiry != -1 && expiry != 0 ) {
374+ obj[P_EXPIRY] = (long long ) expiry;
375+ }
376+ if (!strike.empty ()) {
377+ obj[P_STRIKE] = value::string (strike);
378+ }
379+ if (!right.empty ()) {
380+ obj[P_RIGHT] = value::string (right);
381+ }
382+ return post (CONTRACTS, obj)[P_ITEMS];
383+ }
317384
385+ value
386+ TradeClient::get_quote_contract (utility::string_t symbol, utility::string_t sec_type, utility::string_t expiry) {
387+ value obj = value::object (true );
388+ obj[P_ACCOUNT] = get_account_param ();
389+ if (!symbol.empty ()) {
390+ obj[P_SYMBOL] = value::string (symbol);
391+ }
392+ if (!sec_type.empty ()) {
393+ obj[P_SEC_TYPE] = value::string (sec_type);
394+ }
395+ if (!expiry.empty ()) {
396+ obj[P_EXPIRY] = value::string (expiry);
397+ }
398+ return post (QUOTE_CONTRACT, obj)[P_ITEMS];
399+ }
400+
401+ value TradeClient::place_order (value &order) {
318402 value obj = value::object (true );
319403 for (const auto &kvp: order.as_object ()) {
320404 obj[kvp.first ] = kvp.second ;
@@ -535,5 +619,125 @@ namespace TIGER_API {
535619 return res;
536620 }
537621
622+ value TradeClient::get_estimate_tradable_quantity (Order &order, utility::string_t seg_type) {
623+ value obj = value::object (true );
624+ obj[P_ACCOUNT] = get_account_param (order.account );
625+ obj[U (" seg_type" )] = value::string (seg_type);
626+ Contract contract = order.contract ;
627+ if (!contract.symbol .empty ()) {
628+ obj[U (" symbol" )] = value::string (contract.symbol );
629+ }
630+ if (!contract.sec_type .empty ()) {
631+ obj[U (" sec_type" )] = value::string (contract.sec_type );
632+ }
633+ if (!contract.expiry .empty ()) {
634+ obj[U (" expiry" )] = value::string (contract.expiry );
635+ }
636+ if (!contract.strike .empty ()) {
637+ obj[U (" strike" )] = value::string (contract.strike );
638+ }
639+ if (!contract.right .empty ()) {
640+ obj[U (" right" )] = value::string (contract.right );
641+ }
642+ if (!order.order_type .empty ()) {
643+ obj[U (" order_type" )] = value::string (order.order_type );
644+ }
645+ if (!order.action .empty ()) {
646+ obj[U (" action" )] = value::string (order.action );
647+ }
648+ if (order.total_quantity ) {
649+ obj[U (" total_quantity" )] = order.total_quantity ;
650+ }
651+ if (order.limit_price != 0 ) {
652+ obj[U (" limit_price" )] = order.limit_price ;
653+ }
654+ if (order.aux_price != 0 ) {
655+ obj[U (" stop_price" )] = order.aux_price ;
656+ }
657+ return post (ESTIMATE_TRADABLE_QUANTITY, obj);
658+ }
659+
660+ value TradeClient::get_analytics_asset (utility::string_t account, utility::string_t start_date,
661+ utility::string_t end_date, utility::string_t seg_type,
662+ utility::string_t currency, utility::string_t sub_account) {
663+ value obj = value::object (true );
664+ obj[P_ACCOUNT] = get_account_param (account);
665+ if (!start_date.empty ()) {
666+ obj[U (" start_date" )] = value::string (start_date);
667+ }
668+ if (!end_date.empty ()) {
669+ obj[U (" end_date" )] = value::string (end_date);
670+ }
671+ if (!seg_type.empty ()) {
672+ obj[U (" seg_type" )] = value::string (seg_type);
673+ }
674+ if (!currency.empty ()) {
675+ obj[U (" currency" )] = value::string (currency);
676+ }
677+ if (!sub_account.empty ()) {
678+ obj[U (" sub_account" )] = value::string (sub_account);
679+ }
680+ return post (ANALYTICS_ASSET, obj);
681+ }
682+
683+ value TradeClient::get_segment_fund_history (int limit) {
684+ value obj = value::object (true );
685+ obj[P_ACCOUNT] = get_account_param ();
686+ if (limit > 0 ) {
687+ obj[U (" limit" )] = limit;
688+ }
689+ return post (SEGMENT_FUND_HISTORY, obj);
690+ }
691+
692+ value TradeClient::get_segment_fund_available (utility::string_t from_segment, utility::string_t currency) {
693+ value obj = value::object (true );
694+ obj[P_ACCOUNT] = get_account_param ();
695+ if (!from_segment.empty ()) {
696+ obj[U (" from_segment" )] = value::string (from_segment);
697+ }
698+ if (!currency.empty ()) {
699+ obj[U (" currency" )] = value::string (currency);
700+ }
701+ return post (SEGMENT_FUND_AVAILABLE, obj);
702+ }
703+
704+ value
705+ TradeClient::transfer_segment_fund (utility::string_t from_segment, utility::string_t to_segment, double amount,
706+ utility::string_t currency) {
707+ value obj = value::object (true );
708+ obj[P_ACCOUNT] = get_account_param ();
709+ if (!from_segment.empty ()) {
710+ obj[U (" from_segment" )] = value::string (from_segment);
711+ }
712+ if (!to_segment.empty ()) {
713+ obj[U (" to_segment" )] = value::string (to_segment);
714+ }
715+ if (!currency.empty ()) {
716+ obj[U (" currency" )] = value::string (currency);
717+ }
718+ if (amount != 0 ) {
719+ obj[U (" amount" )] = amount;
720+ }
721+ return post (TRANSFER_SEGMENT_FUND, obj);
722+ }
723+
724+ value TradeClient::place_forex_order (utility::string_t seg_type, utility::string_t source_currency,
725+ utility::string_t target_currency, double source_amount) {
726+ value obj = value::object (true );
727+ obj[P_ACCOUNT] = get_account_param ();
728+ if (!seg_type.empty ()) {
729+ obj[U (" seg_type" )] = value::string (seg_type);
730+ }
731+ if (!source_currency.empty ()) {
732+ obj[U (" source_currency" )] = value::string (source_currency);
733+ }
734+ if (!target_currency.empty ()) {
735+ obj[U (" target_currency" )] = value::string (target_currency);
736+ }
737+ if (source_amount != 0 ) {
738+ obj[U (" source_amount" )] = source_amount;
739+ }
740+ return post (PLACE_FOREX_ORDER, obj);
741+ }
538742
539743}
0 commit comments