TradeContext
struct TradeContext
Trade context
Examples
use std.io;
use longport.Config;
use longport.trade.TradeContext;
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
loop {
let quote = try! ctx.receiver.recv();
println(`${quote.detail.side as int} ${quote.detail.stock_name}`);
}
new
pub fn new(config: Config): TradeContext throws OpenApiError
[src]
pub fn new(config: Config): TradeContext throws OpenApiError {
let inner = try _TradeContext.new(config as _Config);
let receiver = channel::<PushEvent>();
spawn {
do {
loop {
try receiver.send(PushEvent.new(inner.receiver.recv()));
}
}
}
return TradeContext { inner, receiver };
}
Create a TradeContext
new
pub fn new(config: Config): TradeContext throws OpenApiError
[src]
pub fn new(config: Config): TradeContext throws OpenApiError {
let inner = try _TradeContext.new(config as _Config);
let receiver = channel::<PushEvent>();
spawn {
do {
loop {
try receiver.send(PushEvent.new(inner.receiver.recv()));
}
}
}
return TradeContext { inner, receiver };
}
Create a TradeContext
Create a TradeContext
Examples
use longport.Config;
use longport.trade.TradeContext;
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
subscribe
pub fn subscribe(self, topics: [TopicType]) throws OpenApiError
[src]
pub fn subscribe(self, topics: [TopicType]) throws OpenApiError {
let items_topics: [int] = [];
for (let topic in topics) {
items_topics.push(topic as int);
}
try self.inner.subscribe(items_topics);
}
Subscribe
subscribe
pub fn subscribe(self, topics: [TopicType]) throws OpenApiError
[src]
pub fn subscribe(self, topics: [TopicType]) throws OpenApiError {
let items_topics: [int] = [];
for (let topic in topics) {
items_topics.push(topic as int);
}
try self.inner.subscribe(items_topics);
}
Subscribe
Subscribe
See also: https://open.longportapp.com/en/docs/trade/trade-push#subscribe
Examples
use longport.Config;
use longport.trade.{TopicType, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
try! ctx.subscribe([TopicType.Private]);
unsubscribe
pub fn unsubscribe(self, topics: [TopicType]) throws OpenApiError
[src]
pub fn unsubscribe(self, topics: [TopicType]) throws OpenApiError {
let items_topics: [int] = [];
for (let topic in topics) {
items_topics.push(topic as int);
}
try self.inner.unsubscribe(items_topics);
}
Unsubscribe
unsubscribe
pub fn unsubscribe(self, topics: [TopicType]) throws OpenApiError
[src]
pub fn unsubscribe(self, topics: [TopicType]) throws OpenApiError {
let items_topics: [int] = [];
for (let topic in topics) {
items_topics.push(topic as int);
}
try self.inner.unsubscribe(items_topics);
}
Unsubscribe
Unsubscribe
See also: https://open.longportapp.com/en/docs/quote/subscribe/unsubscribe
Examples
use longport.Config;
use longport.trade.{TopicType, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
try! ctx.subscribe([TopicType.Private]);
try! ctx.unsubscribe([TopicType.Private]);
account_balance
pub fn account_balance(self, currency: string?): [AccountBalance] throws OpenApiError
[src]
pub fn account_balance(self, currency: string?): [AccountBalance] throws OpenApiError {
let _items = try self.inner.account_balance(currency);
let items: [AccountBalance] = [];
for (let _item in _items) {
items.push(AccountBalance.new(_item));
}
return items;
}
Get account balance
account_balance
pub fn account_balance(self, currency: string?): [AccountBalance] throws OpenApiError
[src]
pub fn account_balance(self, currency: string?): [AccountBalance] throws OpenApiError {
let _items = try self.inner.account_balance(currency);
let items: [AccountBalance] = [];
for (let _item in _items) {
items.push(AccountBalance.new(_item));
}
return items;
}
Get account balance
Get account balance
See also: https://open.longportapp.com/en/docs/trade/asset/account
Examples
use longport.Config;
use longport.trade.TradeContext;
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let infos = try! ctx.account_balance("CNH");
let infos = try! ctx.account_balance(nil);
submit_order
pub fn submit_order(self, symbol: string, order_type: OrderType, side: OrderSide, submitted_quantity: int, time_in_force: TimeInForceType, submitted_price: Decimal? = nil, trigger_price: Decimal? = nil, limit_offset: Decimal? = nil, trailing_amount: Decimal? = nil, trailing_percent: Decimal? = nil, expire_date: DateTime? = nil, outside_rth: OutsideRTH? = nil, remark: string? = nil): SubmitOrderResponse throws OpenApiError
[src]
pub fn submit_order(
self,
symbol: string,
order_type: OrderType,
side: OrderSide,
submitted_quantity: int,
time_in_force: TimeInForceType,
submitted_price: Decimal? = nil,
trigger_price: Decimal? = nil,
limit_offset: Decimal? = nil,
trailing_amount: Decimal? = nil,
trailing_percent: Decimal? = nil,
expire_date: DateTime? = nil,
outside_rth: OutsideRTH? = nil,
remark: string? = nil
): SubmitOrderResponse throws OpenApiError {
let items_outside_rth: int? = nil;
if (outside_rth != nil) {
items_outside_rth = outside_rth as int;
}
return SubmitOrderResponse
.new(try self
.inner
.submit_order(
symbol,
order_type as int,
side as int,
submitted_quantity,
time_in_force as int,
submitted_price: submitted_price,
trigger_price: trigger_price,
limit_offset: limit_offset,
trailing_amount: trailing_amount,
trailing_percent: trailing_percent,
expire_date: expire_date,
outside_rth: items_outside_rth,
remark: remark
));
}
Submit order
submit_order
pub fn submit_order(self, symbol: string, order_type: OrderType, side: OrderSide, submitted_quantity: int, time_in_force: TimeInForceType, submitted_price: Decimal? = nil, trigger_price: Decimal? = nil, limit_offset: Decimal? = nil, trailing_amount: Decimal? = nil, trailing_percent: Decimal? = nil, expire_date: DateTime? = nil, outside_rth: OutsideRTH? = nil, remark: string? = nil): SubmitOrderResponse throws OpenApiError
[src]
pub fn submit_order(
self,
symbol: string,
order_type: OrderType,
side: OrderSide,
submitted_quantity: int,
time_in_force: TimeInForceType,
submitted_price: Decimal? = nil,
trigger_price: Decimal? = nil,
limit_offset: Decimal? = nil,
trailing_amount: Decimal? = nil,
trailing_percent: Decimal? = nil,
expire_date: DateTime? = nil,
outside_rth: OutsideRTH? = nil,
remark: string? = nil
): SubmitOrderResponse throws OpenApiError {
let items_outside_rth: int? = nil;
if (outside_rth != nil) {
items_outside_rth = outside_rth as int;
}
return SubmitOrderResponse
.new(try self
.inner
.submit_order(
symbol,
order_type as int,
side as int,
submitted_quantity,
time_in_force as int,
submitted_price: submitted_price,
trigger_price: trigger_price,
limit_offset: limit_offset,
trailing_amount: trailing_amount,
trailing_percent: trailing_percent,
expire_date: expire_date,
outside_rth: items_outside_rth,
remark: remark
));
}
Submit order
Submit order
See also: https://open.longportapp.com/en/docs/trade/order/submit
Examples
use longport.Config;
use longport.trade.{OrderSide, OrderType, TimeInForceType, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.submit_order(
"700.HK",
OrderType.LO,
OrderSide.Buy,
200,
TimeInForceType.Day,
submitted_price: try! Decimal.parse("1.23"),
remark: "Hello from Navi SDK"
);
replace_order
pub fn replace_order(self, order_id: string, quantity: int, price: Decimal? = nil, trigger_price: Decimal? = nil, limit_offset: Decimal? = nil, trailing_amount: Decimal? = nil, trailing_percent: Decimal? = nil, remark: string? = nil) throws OpenApiError
[src]
pub fn replace_order(
self,
order_id: string,
quantity: int,
price: Decimal? = nil,
trigger_price: Decimal? = nil,
limit_offset: Decimal? = nil,
trailing_amount: Decimal? = nil,
trailing_percent: Decimal? = nil,
remark: string? = nil
) throws OpenApiError {
try self
.inner
.replace_order(
order_id,
quantity,
price: price,
trigger_price: trigger_price,
limit_offset: limit_offset,
trailing_amount: trailing_amount,
trailing_percent: trailing_percent,
remark: remark
);
}
Replace order
replace_order
pub fn replace_order(self, order_id: string, quantity: int, price: Decimal? = nil, trigger_price: Decimal? = nil, limit_offset: Decimal? = nil, trailing_amount: Decimal? = nil, trailing_percent: Decimal? = nil, remark: string? = nil) throws OpenApiError
[src]
pub fn replace_order(
self,
order_id: string,
quantity: int,
price: Decimal? = nil,
trigger_price: Decimal? = nil,
limit_offset: Decimal? = nil,
trailing_amount: Decimal? = nil,
trailing_percent: Decimal? = nil,
remark: string? = nil
) throws OpenApiError {
try self
.inner
.replace_order(
order_id,
quantity,
price: price,
trigger_price: trigger_price,
limit_offset: limit_offset,
trailing_amount: trailing_amount,
trailing_percent: trailing_percent,
remark: remark
);
}
Replace order
Replace order
See also: https://open.longportapp.com/en/docs/trade/order/replace
Examples
use longport.Config;
use longport.trade.{OrderSide, OrderType, TimeInForceType, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
try! ctx.replace_order(
"709043056541253632",
200,
price: try! Decimal.parse("3.45"),
remark: "Hello from Navi SDK and replaced"
);
today_orders
pub fn today_orders(self, symbol: string? = nil, status: [OrderStatus]? = nil, side: OrderSide? = nil, market: Market? = nil, order_id: string? = nil): [Order] throws OpenApiError
[src]
pub fn today_orders(
self,
symbol: string? = nil,
status: [OrderStatus]? = nil,
side: OrderSide? = nil,
market: Market? = nil,
order_id: string? = nil
): [Order] throws OpenApiError {
let items_status: [int] = [];
if (status != nil) {
for (let st in status!) {
items_status.push(st as int);
}
}
let items_side: int? = nil;
if (side != nil) {
items_side = side as int;
}
let items_market: int? = nil;
if (market != nil) {
items_market = market as int;
}
let _items = try self
.inner
.today_orders(
symbol: symbol,
status: items_status,
side: items_side,
market: items_market,
order_id: order_id
);
let items: [Order] = [];
for (let _item in _items) {
items.push(Order.new(_item));
}
return items;
}
Get today orders
today_orders
pub fn today_orders(self, symbol: string? = nil, status: [OrderStatus]? = nil, side: OrderSide? = nil, market: Market? = nil, order_id: string? = nil): [Order] throws OpenApiError
[src]
pub fn today_orders(
self,
symbol: string? = nil,
status: [OrderStatus]? = nil,
side: OrderSide? = nil,
market: Market? = nil,
order_id: string? = nil
): [Order] throws OpenApiError {
let items_status: [int] = [];
if (status != nil) {
for (let st in status!) {
items_status.push(st as int);
}
}
let items_side: int? = nil;
if (side != nil) {
items_side = side as int;
}
let items_market: int? = nil;
if (market != nil) {
items_market = market as int;
}
let _items = try self
.inner
.today_orders(
symbol: symbol,
status: items_status,
side: items_side,
market: items_market,
order_id: order_id
);
let items: [Order] = [];
for (let _item in _items) {
items.push(Order.new(_item));
}
return items;
}
Get today orders
Get today orders
See also: https://open.longportapp.com/en/docs/trade/order/today_orders
Examples
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.today_orders(
symbol: "700.HK",
status: [
OrderStatus.NotReported,
OrderStatus.Filled,
OrderStatus.New
],
side: OrderSide.Buy,
market: Market.HK
);
history_orders
pub fn history_orders(self, symbol: string? = nil, status: [OrderStatus]? = nil, side: OrderSide? = nil, market: Market? = nil, start_at: DateTime? = nil, end_at: DateTime? = nil): [Order] throws OpenApiError
[src]
pub fn history_orders(
self,
symbol: string? = nil,
status: [OrderStatus]? = nil,
side: OrderSide? = nil,
market: Market? = nil,
start_at: DateTime? = nil,
end_at: DateTime? = nil
): [Order] throws OpenApiError {
let items_status: [int] = [];
if (status != nil) {
for (let st in status!) {
items_status.push(st as int);
}
}
let items_side: int? = nil;
if (side != nil) {
items_side = side as int;
}
let items_market: int? = nil;
if (market != nil) {
items_market = market as int;
}
let _items = try self
.inner
.history_orders(
symbol: symbol,
status: items_status,
side: items_side,
market: items_market,
start_at: start_at,
end_at: end_at
);
let items: [Order] = [];
for (let _item in _items) {
items.push(Order.new(_item));
}
return items;
}
Get history orders
history_orders
pub fn history_orders(self, symbol: string? = nil, status: [OrderStatus]? = nil, side: OrderSide? = nil, market: Market? = nil, start_at: DateTime? = nil, end_at: DateTime? = nil): [Order] throws OpenApiError
[src]
pub fn history_orders(
self,
symbol: string? = nil,
status: [OrderStatus]? = nil,
side: OrderSide? = nil,
market: Market? = nil,
start_at: DateTime? = nil,
end_at: DateTime? = nil
): [Order] throws OpenApiError {
let items_status: [int] = [];
if (status != nil) {
for (let st in status!) {
items_status.push(st as int);
}
}
let items_side: int? = nil;
if (side != nil) {
items_side = side as int;
}
let items_market: int? = nil;
if (market != nil) {
items_market = market as int;
}
let _items = try self
.inner
.history_orders(
symbol: symbol,
status: items_status,
side: items_side,
market: items_market,
start_at: start_at,
end_at: end_at
);
let items: [Order] = [];
for (let _item in _items) {
items.push(Order.new(_item));
}
return items;
}
Get history orders
Get history orders
See also: https://open.longportapp.com/en/docs/trade/order/history_orders
Examples
use std.time.DateTime;
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.history_orders(
symbol: "700.HK",
status: [
OrderStatus.NotReported,
OrderStatus.Filled,
OrderStatus.New
],
side: OrderSide.Buy,
market: Market.HK,
start_at: try! DateTime.parse("2023-01-01 00:00:00.000 +08:00"),
end_at: try! DateTime.parse("2023-05-31 00:00:00.000 +08:00")
);
today_executions
pub fn today_executions(self, symbol: string? = nil, order_id: string? = nil): [Execution] throws OpenApiError
[src]
pub fn today_executions(
self, symbol: string? = nil, order_id: string? = nil
): [Execution] throws OpenApiError {
let _items = try self.inner.today_executions(symbol: symbol, order_id: order_id);
let items: [Execution] = [];
for (let _item in _items) {
items.push(Execution.new(_item));
}
return items;
}
Get today executions
today_executions
pub fn today_executions(self, symbol: string? = nil, order_id: string? = nil): [Execution] throws OpenApiError
[src]
pub fn today_executions(
self, symbol: string? = nil, order_id: string? = nil
): [Execution] throws OpenApiError {
let _items = try self.inner.today_executions(symbol: symbol, order_id: order_id);
let items: [Execution] = [];
for (let _item in _items) {
items.push(Execution.new(_item));
}
return items;
}
Get today executions
Get today executions
See also: https://open.longportapp.com/en/docs/trade/execution/today_executions
Examples
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.today_executions(symbol: "700.HK");
history_executions
pub fn history_executions(self, symbol: string? = nil, start_at: DateTime? = nil, end_at: DateTime? = nil): [Execution] throws OpenApiError
[src]
pub fn history_executions(
self, symbol: string? = nil, start_at: DateTime? = nil, end_at: DateTime? = nil
): [Execution] throws OpenApiError {
let _items = try self
.inner
.history_executions(symbol: symbol, start_at: start_at, end_at: end_at);
let items: [Execution] = [];
for (let _item in _items) {
items.push(Execution.new(_item));
}
return items;
}
Get history executions
history_executions
pub fn history_executions(self, symbol: string? = nil, start_at: DateTime? = nil, end_at: DateTime? = nil): [Execution] throws OpenApiError
[src]
pub fn history_executions(
self, symbol: string? = nil, start_at: DateTime? = nil, end_at: DateTime? = nil
): [Execution] throws OpenApiError {
let _items = try self
.inner
.history_executions(symbol: symbol, start_at: start_at, end_at: end_at);
let items: [Execution] = [];
for (let _item in _items) {
items.push(Execution.new(_item));
}
return items;
}
Get history executions
Get history executions
See also: https://open.longportapp.com/en/docs/trade/execution/history_executions
Examples
use std.time.DateTime;
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.history_executions(
symbol: "700.HK",
start_at: try! DateTime.parse("2023-01-01 00:00:00.000 +08:00"),
end_at: try! DateTime.parse("2023-05-31 00:00:00.000 +08:00")
);
cash_flow
pub fn cash_flow(self, start_at: DateTime, end_at: DateTime, business_type: BalanceType? = nil, symbol: string? = nil, page: int? = nil, size: int? = nil): [CashFlow] throws OpenApiError
[src]
pub fn cash_flow(
self,
start_at: DateTime,
end_at: DateTime,
business_type: BalanceType? = nil,
symbol: string? = nil,
page: int? = nil,
size: int? = nil
): [CashFlow] throws OpenApiError {
let items_business_type: int? = nil;
if (business_type != nil) {
items_business_type = business_type as int;
}
let _items = try self
.inner
.cash_flow(
start_at,
end_at,
business_type: items_business_type,
symbol: symbol,
page: page,
size: size
);
let items: [CashFlow] = [];
for (let _item in _items) {
items.push(CashFlow.new(_item));
}
return items;
}
Get cash flow
cash_flow
pub fn cash_flow(self, start_at: DateTime, end_at: DateTime, business_type: BalanceType? = nil, symbol: string? = nil, page: int? = nil, size: int? = nil): [CashFlow] throws OpenApiError
[src]
pub fn cash_flow(
self,
start_at: DateTime,
end_at: DateTime,
business_type: BalanceType? = nil,
symbol: string? = nil,
page: int? = nil,
size: int? = nil
): [CashFlow] throws OpenApiError {
let items_business_type: int? = nil;
if (business_type != nil) {
items_business_type = business_type as int;
}
let _items = try self
.inner
.cash_flow(
start_at,
end_at,
business_type: items_business_type,
symbol: symbol,
page: page,
size: size
);
let items: [CashFlow] = [];
for (let _item in _items) {
items.push(CashFlow.new(_item));
}
return items;
}
Get cash flow
Get cash flow
See also: https://open.longportapp.com/en/docs/trade/asset/cashflow
Examples
use std.time.DateTime;
use longport.Config;
use longport.trade.TradeContext;
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.cash_flow(
try! DateTime.parse("2023-01-01 00:00:00.000 +08:00"),
try! DateTime.parse("2023-03-31 00:00:00.000 +08:00")
);
fund_positions
pub fn fund_positions(self, symbols: [string]): FundPositionsResponse throws OpenApiError
[src]
pub fn fund_positions(self, symbols: [string]): FundPositionsResponse throws OpenApiError {
return FundPositionsResponse.new(try self.inner.fund_positions(symbols));
}
Get fund positions
fund_positions
pub fn fund_positions(self, symbols: [string]): FundPositionsResponse throws OpenApiError
[src]
pub fn fund_positions(self, symbols: [string]): FundPositionsResponse throws OpenApiError {
return FundPositionsResponse.new(try self.inner.fund_positions(symbols));
}
Get fund positions
Get fund positions
Examples
use longport.Config;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.fund_positions([]);
stock_positions
pub fn stock_positions(self, symbols: [string]): StockPositionsResponse throws OpenApiError
[src]
pub fn stock_positions(self, symbols: [string]): StockPositionsResponse throws OpenApiError {
return StockPositionsResponse.new(try self.inner.stock_positions(symbols));
}
Get stock positions
stock_positions
pub fn stock_positions(self, symbols: [string]): StockPositionsResponse throws OpenApiError
[src]
pub fn stock_positions(self, symbols: [string]): StockPositionsResponse throws OpenApiError {
return StockPositionsResponse.new(try self.inner.stock_positions(symbols));
}
Get stock positions
Get stock positions
See also: https://open.longportapp.com/en/docs/trade/asset/stock
Examples
use longport.Config;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.stock_positions(["700.HK"]);
margin_ratio
pub fn margin_ratio(self, symbol: string): MarginRatio throws OpenApiError
[src]
pub fn margin_ratio(self, symbol: string): MarginRatio throws OpenApiError {
return MarginRatio.new(try self.inner.margin_ratio(symbol));
}
Get margin ratio
margin_ratio
pub fn margin_ratio(self, symbol: string): MarginRatio throws OpenApiError
[src]
pub fn margin_ratio(self, symbol: string): MarginRatio throws OpenApiError {
return MarginRatio.new(try self.inner.margin_ratio(symbol));
}
Get margin ratio
Get margin ratio
See also: https://open.longportapp.com/en/docs/trade/asset/margin_ratio
Examples
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.margin_ratio("700.HK");
order_detail
pub fn order_detail(self, order_id: string): OrderDetail throws OpenApiError
[src]
pub fn order_detail(self, order_id: string): OrderDetail throws OpenApiError {
return OrderDetail.new(try self.inner.order_detail(order_id));
}
Get order detail
order_detail
pub fn order_detail(self, order_id: string): OrderDetail throws OpenApiError
[src]
pub fn order_detail(self, order_id: string): OrderDetail throws OpenApiError {
return OrderDetail.new(try self.inner.order_detail(order_id));
}
Get order detail
Get order detail
See also: https://open.longportapp.com/en/docs/trade/order/order_detail
Examples
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.order_detail("954635535729651712");
estimate_max_purchase_quantity
pub fn estimate_max_purchase_quantity(self, symbol: string, order_type: OrderType, side: OrderSide, price: Decimal? = nil, currency: string? = nil, order_id: string? = nil): EstimateMaxPurchaseQuantityResponse throws OpenApiError
[src]
pub fn estimate_max_purchase_quantity(
self,
symbol: string,
order_type: OrderType,
side: OrderSide,
price: Decimal? = nil,
currency: string? = nil,
order_id: string? = nil
): EstimateMaxPurchaseQuantityResponse throws OpenApiError {
return EstimateMaxPurchaseQuantityResponse
.new(try self
.inner
.estimate_max_purchase_quantity(
symbol,
order_type as int,
side as int,
price: price,
currency: currency,
order_id: order_id
));
}
Estimating the maximum purchase quantity for Hong Kong and US stocks,
warrants, and options
estimate_max_purchase_quantity
pub fn estimate_max_purchase_quantity(self, symbol: string, order_type: OrderType, side: OrderSide, price: Decimal? = nil, currency: string? = nil, order_id: string? = nil): EstimateMaxPurchaseQuantityResponse throws OpenApiError
[src]
pub fn estimate_max_purchase_quantity(
self,
symbol: string,
order_type: OrderType,
side: OrderSide,
price: Decimal? = nil,
currency: string? = nil,
order_id: string? = nil
): EstimateMaxPurchaseQuantityResponse throws OpenApiError {
return EstimateMaxPurchaseQuantityResponse
.new(try self
.inner
.estimate_max_purchase_quantity(
symbol,
order_type as int,
side as int,
price: price,
currency: currency,
order_id: order_id
));
}
Estimating the maximum purchase quantity for Hong Kong and US stocks, warrants, and options
Estimating the maximum purchase quantity for Hong Kong and US stocks, warrants, and options
See also: https://open.longportapp.com/en/docs/trade/order/estimate_available_buy_limit
Examples
use longport.Config;
use longport.Market;
use longport.trade.{OrderSide, OrderStatus, OrderType, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
let resp = try! ctx.estimate_max_purchase_quantity("700.HK", OrderType.LO, OrderSide.Buy);
cancel_order
pub fn cancel_order(self, order_id: string) throws OpenApiError
[src]
pub fn cancel_order(self, order_id: string) throws OpenApiError {
try self.inner.cancel_order(order_id);
}
Cancel order
cancel_order
pub fn cancel_order(self, order_id: string) throws OpenApiError
[src]
pub fn cancel_order(self, order_id: string) throws OpenApiError {
try self.inner.cancel_order(order_id);
}
Cancel order
Cancel order
Examples
use longport.Config;
use longport.trade.{TopicType, TradeContext};
let config = try! Config.from_env();
let ctx = try! TradeContext.new(config);
try! ctx.cancel_order("709043056541253632");