LongPort OpenAPI C++ SDK
trade_context.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "async_result.hpp"
4 #include "callback.hpp"
5 #include "config.hpp"
6 #include "push.hpp"
7 #include "types.hpp"
8 
10 
11 namespace longport {
12 namespace trade {
13 
16 {
17 private:
18  const lb_trade_context_t* ctx_;
19 
20 public:
26 
28 
29  size_t ref_count() const;
30 
31  static void create(const Config& config,
33 
35  void subscribe(const std::vector<TopicType>& topics,
36  AsyncCallback<TradeContext, void> callback) const;
37 
39  void unsubscribe(const std::vector<TopicType>& topics,
40  AsyncCallback<TradeContext, void> callback) const;
41 
46 
49  const std::optional<GetHistoryExecutionsOptions>& opts,
50  AsyncCallback<TradeContext, std::vector<Execution>> callback) const;
51 
54  const std::optional<GetTodayExecutionsOptions>& opts,
55  AsyncCallback<TradeContext, std::vector<Execution>> callback) const;
56 
59  const std::optional<GetHistoryOrdersOptions>& opts,
60  AsyncCallback<TradeContext, std::vector<Order>> callback) const;
61 
64  const std::optional<GetTodayOrdersOptions>& opts,
65  AsyncCallback<TradeContext, std::vector<Order>> callback) const;
66 
69  AsyncCallback<TradeContext, void> callback) const;
70 
73  const SubmitOrderOptions& opts,
75 
77  void cancel_order(const std::string& order_id,
78  AsyncCallback<TradeContext, void> callback) const;
79 
82  const std::string& currency,
83  AsyncCallback<TradeContext, std::vector<AccountBalance>> callback) const;
84 
87  AsyncCallback<TradeContext, std::vector<AccountBalance>> callback) const;
88 
91  const GetCashFlowOptions& opts,
92  AsyncCallback<TradeContext, std::vector<CashFlow>> callback) const;
93 
96  const std::optional<GetFundPositionsOptions>& opts,
98 
101  const std::optional<GetStockPositionsOptions>& opts,
103 
105  void margin_ratio(const std::string& symbol,
107 
109  void order_detail(const std::string& order_id,
111 
117  const;
118 };
119 
120 } // namespace trade
121 } // namespace longport
Definition: config.hpp:16
Trade context.
Definition: trade_context.hpp:16
TradeContext & operator=(const TradeContext &ctx)
void history_executions(const std::optional< GetHistoryExecutionsOptions > &opts, AsyncCallback< TradeContext, std::vector< Execution >> callback) const
Get history executions.
void fund_positions(const std::optional< GetFundPositionsOptions > &opts, AsyncCallback< TradeContext, FundPositionsResponse > callback) const
Get fund positions.
void cancel_order(const std::string &order_id, AsyncCallback< TradeContext, void > callback) const
Cancel order.
void margin_ratio(const std::string &symbol, AsyncCallback< TradeContext, MarginRatio > callback) const
Get margin ratio.
void order_detail(const std::string &order_id, AsyncCallback< TradeContext, OrderDetail > callback) const
Get order detail.
void unsubscribe(const std::vector< TopicType > &topics, AsyncCallback< TradeContext, void > callback) const
Unsubscribe.
void today_orders(const std::optional< GetTodayOrdersOptions > &opts, AsyncCallback< TradeContext, std::vector< Order >> callback) const
Get history orders.
void set_on_order_changed(PushCallback< TradeContext, PushOrderChanged > callback) const
void subscribe(const std::vector< TopicType > &topics, AsyncCallback< TradeContext, void > callback) const
Subscribe.
void account_balance(AsyncCallback< TradeContext, std::vector< AccountBalance >> callback) const
Get account balance.
void history_orders(const std::optional< GetHistoryOrdersOptions > &opts, AsyncCallback< TradeContext, std::vector< Order >> callback) const
Get history orders.
void account_balance(const std::string &currency, AsyncCallback< TradeContext, std::vector< AccountBalance >> callback) const
Get account balance with currency.
void submit_order(const SubmitOrderOptions &opts, AsyncCallback< TradeContext, SubmitOrderResponse > callback) const
Submit order.
TradeContext(TradeContext &&ctx)
void stock_positions(const std::optional< GetStockPositionsOptions > &opts, AsyncCallback< TradeContext, StockPositionsResponse > callback) const
Get stock positions.
void account_balance(const GetCashFlowOptions &opts, AsyncCallback< TradeContext, std::vector< CashFlow >> callback) const
Get cash flow.
static void create(const Config &config, AsyncCallback< TradeContext, void > callback)
void estimate_max_purchase_quantity(const EstimateMaxPurchaseQuantityOptions &opts, AsyncCallback< TradeContext, EstimateMaxPurchaseQuantityResponse > callback) const
void today_executions(const std::optional< GetTodayExecutionsOptions > &opts, AsyncCallback< TradeContext, std::vector< Execution >> callback) const
Get today executions.
TradeContext(const lb_trade_context_t *ctx)
TradeContext(const TradeContext &ctx)
void replace_order(const ReplaceOrderOptions &opts, AsyncCallback< TradeContext, void > callback) const
Replace order.
Definition: async_result.hpp:7
std::function< void(AsyncResult< Ctx, T >)> AsyncCallback
Definition: async_result.hpp:39
std::function< void(PushEvent< Ctx, T >)> PushCallback
Definition: push.hpp:27
Options for estimate maximum purchase quantity.
Definition: types.hpp:1929
Options for submit order request.
Definition: types.hpp:1655
Options for replace order request.
Definition: types.hpp:1508
Options for submit order request.
Definition: types.hpp:1529
struct lb_trade_context_t lb_trade_context_t
Definition: trade_context.hpp:9