Skip to content
Open
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- **Rust:** `market::TradeStatus` models `/v1/quote/market-status` trade status codes, including engine-compatible normalization and display helpers.
- **All languages:** attached order (take-profit / stop-loss) support for `submit_order` and `replace_order`
- New types: `AttachedOrderType` (`ProfitTaker` / `StopLoss` / `Bracket`), `AttachedOrderDetail`, `SubmitAttachedParams`, `ReplaceAttachedParams`
- `SubmitOrderOptions` / `ReplaceOrderOptions`: new `attached_params` field
- `GetTodayOrdersOptions`: new `is_attached` flag — when combined with `order_id`, treats `order_id` as an attached sub-order ID for lookup (has no effect without `order_id`)
- `Order` / `OrderDetail`: new `attached_orders: Vec<AttachedOrderDetail>` field
- New method `order_detail_attached(order_id)` — queries detail for an attached order by its own ID
- `order_detail` now accepts `GetOrderDetailOptions` (with optional `is_attached` flag) in addition to a plain order ID string

### Fixed

- **All languages:** corrected market trade status documentation and aligned `market::TradeStatus` with the status definition table, including code `2001` and the `123`/`1009`/`1010` display names.

### Breaking changes

- **All languages:** `OrderDetail.charge_detail` is now `Option<OrderChargeDetail>` (previously non-optional). Attached orders return `null` for this field; callers must handle the absent case.
- **C SDK:** `lb_order_detail_t` gains a new `has_charge_detail: bool` field before `charge_detail`. Existing binaries must be recompiled; code that reads `charge_detail` directly should check `has_charge_detail` first.

## [4.3.2] - 2026-06-13

### Added
Expand Down
10 changes: 10 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ When you add, remove, or change any `#[pyclass]`/`#[pymethods]` definitions in
signatures, type annotations, and docstrings in sync with the Rust
implementation.

To build and install the Python SDK locally (from the `python/` directory):

```bash
maturin develop
```

`python/pyproject.toml` uses `dynamic = ["version"]` — maturin reads the
version from `python/Cargo.toml` automatically. Do **not** add a hardcoded
`version` field to `pyproject.toml`.

## After modifying the C SDK (`c/`)

`c/csrc/include/longbridge.h` is **auto-generated** by `cbindgen` during the
Expand Down
262 changes: 261 additions & 1 deletion c/csrc/include/longbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,28 @@ typedef enum lb_topic_type_t {
TopicPrivate,
} lb_topic_type_t;

/**
* Attached order type
*/
typedef enum CAttachedOrderType {
/**
* Unknown
*/
AttachedOrderTypeUnknown = 0,
/**
* Take profit
*/
AttachedOrderTypeProfitTaker = 1,
/**
* Stop loss
*/
AttachedOrderTypeStopLoss = 2,
/**
* Bracket order
*/
AttachedOrderTypeBracket = 3,
} CAttachedOrderType;

/**
* Time in force Type
*/
Expand Down Expand Up @@ -2319,8 +2341,78 @@ typedef struct lb_get_today_orders_options_t {
* Order id (can be null)
*/
const char *order_id;
/**
* Filter by attached order (can be null)
*/
const bool *is_attached;
} lb_get_today_orders_options_t;

/**
* Options for replace attached order params
*/
typedef struct CReplaceAttachedParams {
/**
* Attached order type
*/
enum CAttachedOrderType attached_order_type;
/**
* Take-profit trigger price (can be null)
*/
const struct lb_decimal_t *profit_taker_price;
/**
* Stop-loss trigger price (can be null)
*/
const struct lb_decimal_t *stop_loss_price;
/**
* Time in force type (can be null)
*/
const enum lb_time_in_force_type_t *time_in_force;
/**
* Expiry time unix timestamp (can be null)
*/
const int64_t *expire_time;
/**
* Order type to submit after trigger (can be null)
*/
const enum lb_order_type_t *activate_order_type;
/**
* Take-profit limit price (can be null)
*/
const struct lb_decimal_t *profit_taker_submit_price;
/**
* Stop-loss limit price (can be null)
*/
const struct lb_decimal_t *stop_loss_submit_price;
/**
* RTH setting for activated order (can be null)
*/
const enum lb_outside_rth_t *activate_rth;
/**
* Take-profit order ID (can be null)
*/
const int64_t *profit_taker_id;
/**
* Stop-loss order ID (can be null)
*/
const int64_t *stop_loss_id;
/**
* Cancel all attached orders flag (can be null)
*/
const bool *cancel_all_attached;
/**
* Main order ID (can be null)
*/
const int64_t *main_id;
/**
* Quantity (can be null)
*/
const struct lb_decimal_t *quantity;
/**
* Market price (can be null)
*/
const struct lb_decimal_t *market_price;
} CReplaceAttachedParams;

/**
* Options for replace order request
*/
Expand Down Expand Up @@ -2369,8 +2461,54 @@ typedef struct lb_replace_order_options_t {
* Remark (can be null)
*/
const char *remark;
/**
* Attached order parameters (can be null)
*/
const struct CReplaceAttachedParams *attached_params;
} lb_replace_order_options_t;

/**
* Options for submit attached order params
*/
typedef struct CSubmitAttachedParams {
/**
* Attached order type
*/
enum CAttachedOrderType attached_order_type;
/**
* Take-profit trigger price (can be null)
*/
const struct lb_decimal_t *profit_taker_price;
/**
* Stop-loss trigger price (can be null)
*/
const struct lb_decimal_t *stop_loss_price;
/**
* Time in force type (can be null)
*/
const enum lb_time_in_force_type_t *time_in_force;
/**
* Expiry time unix timestamp (can be null)
*/
const int64_t *expire_time;
/**
* Order type to submit after trigger (can be null)
*/
const enum lb_order_type_t *activate_order_type;
/**
* Take-profit limit price (can be null)
*/
const struct lb_decimal_t *profit_taker_submit_price;
/**
* Stop-loss limit price (can be null)
*/
const struct lb_decimal_t *stop_loss_submit_price;
/**
* RTH setting for activated order (can be null)
*/
const enum lb_outside_rth_t *activate_rth;
} CSubmitAttachedParams;

/**
* Options for submit order request
*/
Expand Down Expand Up @@ -2440,6 +2578,10 @@ typedef struct lb_submit_order_options_t {
* Remark (Maximum 64 characters) (can be null)
*/
const char *remark;
/**
* Attached order parameters (can be null)
*/
const struct CSubmitAttachedParams *attached_params;
} lb_submit_order_options_t;

/**
Expand Down Expand Up @@ -3241,6 +3383,96 @@ typedef struct lb_execution_t {
const struct lb_decimal_t *price;
} lb_execution_t;

/**
* Attached order detail
*/
typedef struct CAttachedOrderDetail {
/**
* Attached order ID
*/
const char *order_id;
/**
* Attached order type
*/
enum CAttachedOrderType attached_type_display;
/**
* Trigger price (maybe null)
*/
const struct lb_decimal_t *trigger_price;
/**
* Quantity
*/
const struct lb_decimal_t *quantity;
/**
* Executed quantity
*/
const struct lb_decimal_t *executed_qty;
/**
* Order status
*/
enum lb_order_status_t status;
/**
* Last updated time (unix timestamp)
*/
int64_t updated_at;
/**
* Whether withdrawn
*/
bool withdrawn;
/**
* GTD date (maybe null)
*/
const struct lb_date_t *gtd;
/**
* Time in force type
*/
enum lb_time_in_force_type_t time_in_force;
/**
* Counter order ID
*/
const char *counter_id;
/**
* Trigger status (maybe null)
*/
const enum lb_trigger_status_t *trigger_status;
/**
* Executed amount
*/
const struct lb_decimal_t *executed_amount;
/**
* Tag
*/
enum lb_order_tag_t tag;
/**
* Submitted time (unix timestamp)
*/
int64_t submitted_at;
/**
* Executed price
*/
const struct lb_decimal_t *executed_price;
/**
* Force RTH only (maybe null)
*/
const enum lb_outside_rth_t *force_only_rth;
/**
* Whether reviewed
*/
bool reviewed;
/**
* Order type to submit after trigger
*/
enum lb_order_type_t activate_order_type;
/**
* RTH setting for activated order (maybe null)
*/
const enum lb_outside_rth_t *activate_rth;
/**
* Submit price (maybe null)
*/
const struct lb_decimal_t *submit_price;
} CAttachedOrderDetail;

/**
* Order
*/
Expand Down Expand Up @@ -3361,6 +3593,14 @@ typedef struct lb_order_t {
* Remark
*/
const char *remark;
/**
* Attached orders
*/
const struct CAttachedOrderDetail *attached_orders;
/**
* Number of attached orders
*/
uintptr_t num_attached_orders;
} lb_order_t;

/**
Expand Down Expand Up @@ -3973,9 +4213,21 @@ typedef struct lb_order_detail_t {
*/
uintptr_t num_history;
/**
* Order charges
* Whether charge_detail is valid (false when the order has no charge info)
*/
bool has_charge_detail;
/**
* Order charges (only valid when has_charge_detail is true)
*/
struct lb_order_charge_detail_t charge_detail;
/**
* Attached orders
*/
const struct CAttachedOrderDetail *attached_orders;
/**
* Number of attached orders
*/
uintptr_t num_attached_orders;
} lb_order_detail_t;

/**
Expand Down Expand Up @@ -10626,6 +10878,14 @@ void lb_trade_context_order_detail(const struct lb_trade_context_t *ctx,
lb_async_callback_t callback,
void *userdata);

/**
* Get order detail for attached order
*/
void lb_trade_context_order_detail_attached(const struct lb_trade_context_t *ctx,
const char *order_id,
lb_async_callback_t callback,
void *userdata);

/**
* Get order detail
*/
Expand Down
Loading
Loading