Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **All languages:** `Execution` gains a `side` field (`OrderSide`) — the buy/sell direction of the fill, now returned by the `today_executions`, `history_executions`, and `all_executions` responses

## [4.4.2] - 2026-07-30

### Added

- **All languages:** corrected `OptionVolumeStats` and `OptionVolumeDailyStat` to match the actual API response — fields now are `symbol`, `call_volume`, `put_volume`, `call_open_interest`, `put_open_interest`, `pc_vol` (f32/float), `pc_oi` (f32/float); `OptionVolumeDaily` gains a top-level `symbol` field; `OptionVolumeDailyStat` date field renamed from `timestamp` to `date` (YYYY-MM-DD string)
- **Python SDK:** added missing `option_volume` and `option_volume_daily` stub definitions to `openapi.pyi` — `QuoteContext` and `AsyncQuoteContext` now expose correct signatures and docstrings for these methods
- **All languages:** attached order (take-profit / stop-loss) support for `submit_order` and `replace_order`
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "3"
members = ["rust", "python", "nodejs", "java", "c"]

[workspace.package]
version = "4.4.1"
version = "4.4.2"
edition = "2024"

[profile.release]
Expand Down
40 changes: 40 additions & 0 deletions c/csrc/include/longbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -3466,6 +3466,32 @@ typedef struct lb_get_today_executions_options_t {
const char *order_id;
} lb_get_today_executions_options_t;

/**
* Options for get all executions request
*/
typedef struct lb_get_all_executions_options_t {
/**
* Security code (can be null)
*/
const char *symbol;
/**
* Order id (can be null)
*/
const char *order_id;
/**
* Start time (can be null)
*/
const int64_t *start_at;
/**
* End time (can be null)
*/
const int64_t *end_at;
/**
* Page number (can be null)
*/
const uint64_t *page;
} lb_get_all_executions_options_t;

/**
* Options for get history orders request
*/
Expand Down Expand Up @@ -4574,6 +4600,10 @@ typedef struct lb_execution_t {
* Executed price
*/
const struct lb_decimal_t *price;
/**
* Order side
*/
enum lb_order_side_t side;
} lb_execution_t;

/**
Expand Down Expand Up @@ -12232,6 +12262,16 @@ void lb_trade_context_today_executions(const struct lb_trade_context_t *ctx,
lb_async_callback_t callback,
void *userdata);

/**
* Get all executions
*
* @param[in] opts Options for get all executions request (can be null)
*/
void lb_trade_context_all_executions(const struct lb_trade_context_t *ctx,
const struct lb_get_all_executions_options_t *opts,
lb_async_callback_t callback,
void *userdata);

/**
* Get history orders
*
Expand Down
95 changes: 47 additions & 48 deletions c/src/trade_context/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ use crate::{
trade_context::{
enum_types::CTopicType,
types::{
CAccountBalanceOwned, CCashFlowOwned, CEstimateMaxPurchaseQuantityOptions,
CEstimateMaxPurchaseQuantityResponseOwned, CExecutionOwned,
CFundPositionsResponseOwned, CGetCashFlowOptions, CGetFundPositionsOptions,
CGetHistoryExecutionsOptions, CGetHistoryOrdersOptions, CGetStockPositionsOptions,
CGetTodayExecutionsOptions, CGetTodayOrdersOptions, CMarginRatioOwned,
COrderDetailOwned, COrderOwned, CPushOrderChanged, CPushOrderChangedOwned,
CReplaceOrderOptions, CStockPositionsResponseOwned, CSubmitOrderOptions,
CSubmitOrderResponseOwned,
CAccountBalanceOwned, CAllExecutionsResponseOwned, CCashFlowOwned,
CEstimateMaxPurchaseQuantityOptions, CEstimateMaxPurchaseQuantityResponseOwned,
CExecutionOwned, CFundPositionsResponseOwned, CGetAllExecutionsOptions,
CGetCashFlowOptions, CGetFundPositionsOptions, CGetHistoryExecutionsOptions,
CGetHistoryOrdersOptions, CGetStockPositionsOptions, CGetTodayExecutionsOptions,
CGetTodayOrdersOptions, CMarginRatioOwned, COrderDetailOwned, COrderOwned,
CPushOrderChanged, CPushOrderChangedOwned, CReplaceOrderOptions,
CStockPositionsResponseOwned, CSubmitOrderOptions, CSubmitOrderResponseOwned,
},
},
types::{CCow, CVec, ToFFI, cstr_array_to_rust, cstr_to_rust},
Expand Down Expand Up @@ -265,46 +265,45 @@ pub unsafe extern "C" fn lb_trade_context_today_executions(
});
}

// TODO: temporarily disabled — restore when API is available
// Get all executions
//
// @param[in] opts Options for get all executions request (can be null)
// #[unsafe(no_mangle)]
// pub unsafe extern "C" fn lb_trade_context_all_executions(
// ctx: *const CTradeContext,
// opts: *const CGetAllExecutionsOptions,
// callback: CAsyncCallback,
// userdata: *mut c_void,
// ) {
// let ctx_inner = (*ctx).ctx.clone();
// let mut opts2 = GetAllExecutionsOptions::new();
// if !opts.is_null() {
// if !(*opts).symbol.is_null() {
// opts2 = opts2.symbol(cstr_to_rust((*opts).symbol));
// }
// if !(*opts).order_id.is_null() {
// opts2 = opts2.order_id(cstr_to_rust((*opts).order_id));
// }
// if !(*opts).start_at.is_null() {
// opts2 = opts2.start_at(
// OffsetDateTime::from_unix_timestamp(*(*opts).start_at).expect("invalid start
// at"), );
// }
// if !(*opts).end_at.is_null() {
// opts2 = opts2.end_at(
// OffsetDateTime::from_unix_timestamp(*(*opts).end_at).expect("invalid end
// at"), );
// }
// if !(*opts).page.is_null() {
// opts2 = opts2.page(*(*opts).page);
// }
// }
// execute_async(callback, ctx, userdata, async move {
// let resp: CCow<CAllExecutionsResponseOwned> =
// CCow::new(ctx_inner.all_executions(opts2).await?);
// Ok(resp)
// });
// }
/// Get all executions
///
/// @param[in] opts Options for get all executions request (can be null)
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lb_trade_context_all_executions(
ctx: *const CTradeContext,
opts: *const CGetAllExecutionsOptions,
callback: CAsyncCallback,
userdata: *mut c_void,
) {
let ctx_inner = (*ctx).ctx.clone();
let mut opts2 = GetAllExecutionsOptions::new();
if !opts.is_null() {
if !(*opts).symbol.is_null() {
opts2 = opts2.symbol(cstr_to_rust((*opts).symbol));
}
if !(*opts).order_id.is_null() {
opts2 = opts2.order_id(cstr_to_rust((*opts).order_id));
}
if !(*opts).start_at.is_null() {
opts2 = opts2.start_at(
OffsetDateTime::from_unix_timestamp(*(*opts).start_at).expect("invalid start at"),
);
}
if !(*opts).end_at.is_null() {
opts2 = opts2.end_at(
OffsetDateTime::from_unix_timestamp(*(*opts).end_at).expect("invalid end at"),
);
}
if !(*opts).page.is_null() {
opts2 = opts2.page(*(*opts).page);
}
}
execute_async(callback, ctx, userdata, async move {
let resp: CCow<CAllExecutionsResponseOwned> =
CCow::new(ctx_inner.all_executions(opts2).await?);
Ok(resp)
});
}

/// Get history orders
///
Expand Down
7 changes: 7 additions & 0 deletions c/src/trade_context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ pub struct CExecution {
pub quantity: *const CDecimal,
/// Executed price
pub price: *const CDecimal,
/// Order side
pub side: COrderSide,
}

#[derive(Debug)]
Expand All @@ -573,6 +575,7 @@ pub(crate) struct CExecutionOwned {
trade_done_at: i64,
quantity: CDecimal,
price: CDecimal,
side: OrderSide,
}

impl From<Execution> for CExecutionOwned {
Expand All @@ -584,6 +587,7 @@ impl From<Execution> for CExecutionOwned {
trade_done_at,
quantity,
price,
side,
} = execution;
CExecutionOwned {
order_id: order_id.into(),
Expand All @@ -592,6 +596,7 @@ impl From<Execution> for CExecutionOwned {
trade_done_at: trade_done_at.unix_timestamp(),
quantity: quantity.into(),
price: price.into(),
side,
}
}
}
Expand All @@ -607,6 +612,7 @@ impl ToFFI for CExecutionOwned {
trade_done_at,
quantity,
price,
side,
} = self;
CExecution {
order_id: order_id.to_ffi_type(),
Expand All @@ -615,6 +621,7 @@ impl ToFFI for CExecutionOwned {
trade_done_at: *trade_done_at,
quantity: quantity.to_ffi_type(),
price: price.to_ffi_type(),
side: (*side).into(),
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions cpp/include/trade_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ class TradeContext
const std::optional<GetTodayExecutionsOptions>& opts,
AsyncCallback<TradeContext, std::vector<Execution>> callback) const;

// TODO: temporarily disabled — restore when API is available
/*
/// Get all executions
void all_executions(
const std::optional<GetAllExecutionsOptions>& opts,
AsyncCallback<TradeContext, AllExecutionsResponse> callback) const;
*/

/// Get history orders
void history_orders(
Expand Down
24 changes: 13 additions & 11 deletions cpp/include/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,17 @@ enum class TopicType
Private,
};

/// Order side
enum class OrderSide
{
/// Unknown
Unknown,
/// Buy
Buy,
/// Sell
Sell,
};

/// Exexution
struct Execution
{
Expand All @@ -1369,6 +1380,8 @@ struct Execution
int64_t trade_done_at;
Decimal quantity;
Decimal price;
/// Order side
OrderSide side;
};

/// Options for get history executions request
Expand Down Expand Up @@ -1456,17 +1469,6 @@ enum class OrderStatus
PartialWithdrawal,
};

/// Order side
enum class OrderSide
{
/// Unknown
Unknown,
/// Buy
Buy,
/// Sell
Sell,
};

/// Order type
enum class OrderType
{
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,16 @@ convert(TopicType ty)
}
}

inline OrderSide
convert(lb_order_side_t side);

inline Execution
convert(const lb_execution_t* info)
{
return Execution{
info->order_id, info->trade_id, info->symbol,
info->trade_done_at, info->quantity, Decimal(info->price),
convert(info->side),
};
}

Expand Down
3 changes: 0 additions & 3 deletions cpp/src/trade_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ TradeContext::today_executions(
new AsyncCallback<TradeContext, std::vector<Execution>>(callback));
}

// TODO: temporarily disabled — restore when API is available
/*
/// Get all executions
void
TradeContext::all_executions(
Expand Down Expand Up @@ -261,7 +259,6 @@ TradeContext::all_executions(
},
new AsyncCallback<TradeContext, AllExecutionsResponse>(callback));
}
*/

/// Get history orders
void
Expand Down
14 changes: 12 additions & 2 deletions java/javasrc/src/main/java/com/longbridge/trade/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Execution {
private OffsetDateTime tradeDoneAt;
private BigDecimal quantity;
private BigDecimal price;
private OrderSide side;

/**
* Returns the order ID.
Expand Down Expand Up @@ -68,9 +69,18 @@ public BigDecimal getPrice() {
return price;
}

/**
* Returns the order side.
*
* @return order side
*/
public OrderSide getSide() {
return side;
}

@Override
public String toString() {
return "Execution [orderId=" + orderId + ", price=" + price + ", quantity=" + quantity + ", symbol=" + symbol
+ ", tradeDoneAt=" + tradeDoneAt + ", tradeId=" + tradeId + "]";
return "Execution [orderId=" + orderId + ", price=" + price + ", quantity=" + quantity + ", side=" + side
+ ", symbol=" + symbol + ", tradeDoneAt=" + tradeDoneAt + ", tradeId=" + tradeId + "]";
}
}
Loading
Loading