Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Jun 11, 2024
2 parents 0766117 + 5994ee4 commit 7b009df
Show file tree
Hide file tree
Showing 30 changed files with 239 additions and 126 deletions.
2 changes: 1 addition & 1 deletion c/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "longport-c"
version = "1.0.26"
version = "1.0.27"
description = "LongPort OpenAPI SDK for C"
homepage = "https://open.longportapp.com/en/"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion c/crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "longport-c-macros"
version = "1.0.26"
version = "1.0.27"
edition = "2021"

[lib]
Expand Down
12 changes: 12 additions & 0 deletions c/csrc/include/longport.h
Original file line number Diff line number Diff line change
Expand Up @@ -4351,6 +4351,13 @@ void lb_decimal_normalize(struct lb_decimal_t *value);
*/
void lb_decimal_round(struct lb_decimal_t *value);

/**
* Returns a new Decimal number with the specified number of decimal points for
* fractional portion. Rounding currently follows “Bankers Rounding” rules.
* e.g. 6.5 -> 6, 7.5 -> 8
*/
void lb_decimal_round_dp(struct lb_decimal_t *value, uint32_t dp);

/**
* Returns a new Decimal integral with no fractional portion. This is a
* true truncation whereby no rounding is performed.
Expand Down Expand Up @@ -4498,6 +4505,11 @@ void lb_decimal_normal_cdf(struct lb_decimal_t *value);
*/
void lb_decimal_norm_pdf(struct lb_decimal_t *value);

/**
* The Probability density function for a Normal distribution.
*/
const char *lb_decimal_to_string(const struct lb_decimal_t *value);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
Expand Down
22 changes: 11 additions & 11 deletions c/src/trade_context/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,19 @@ pub unsafe extern "C" fn lb_trade_context_replace_order(
let quantity = (*opts).quantity;
let mut opts2 = ReplaceOrderOptions::new(order_id, quantity);
if !(*opts).price.is_null() {
opts2 = opts2.price((*(*opts).price).0);
opts2 = opts2.price((*(*opts).price).value);
}
if !(*opts).trigger_price.is_null() {
opts2 = opts2.trigger_price((*(*opts).trigger_price).0);
opts2 = opts2.trigger_price((*(*opts).trigger_price).value);
}
if !(*opts).limit_offset.is_null() {
opts2 = opts2.limit_offset((*(*opts).limit_offset).0);
opts2 = opts2.limit_offset((*(*opts).limit_offset).value);
}
if !(*opts).trailing_amount.is_null() {
opts2 = opts2.trailing_amount((*(*opts).trailing_amount).0);
opts2 = opts2.trailing_amount((*(*opts).trailing_amount).value);
}
if !(*opts).trailing_percent.is_null() {
opts2 = opts2.trailing_percent((*(*opts).trailing_percent).0);
opts2 = opts2.trailing_percent((*(*opts).trailing_percent).value);
}
if !(*opts).remark.is_null() {
opts2 = opts2.remark(cstr_to_rust((*opts).remark));
Expand Down Expand Up @@ -408,19 +408,19 @@ pub unsafe extern "C" fn lb_trade_context_submit_order(
let mut opts2 =
SubmitOrderOptions::new(symbol, order_type, side, submitted_quantity, time_in_force);
if !(*opts).submitted_price.is_null() {
opts2 = opts2.submitted_price((*(*opts).submitted_price).0);
opts2 = opts2.submitted_price((*(*opts).submitted_price).value);
}
if !(*opts).trigger_price.is_null() {
opts2 = opts2.trigger_price((*(*opts).trigger_price).0);
opts2 = opts2.trigger_price((*(*opts).trigger_price).value);
}
if !(*opts).limit_offset.is_null() {
opts2 = opts2.limit_offset((*(*opts).limit_offset).0);
opts2 = opts2.limit_offset((*(*opts).limit_offset).value);
}
if !(*opts).trailing_amount.is_null() {
opts2 = opts2.trailing_amount((*(*opts).trailing_amount).0);
opts2 = opts2.trailing_amount((*(*opts).trailing_amount).value);
}
if !(*opts).trailing_percent.is_null() {
opts2 = opts2.trailing_percent((*(*opts).trailing_percent).0);
opts2 = opts2.trailing_percent((*(*opts).trailing_percent).value);
}
if !(*opts).expire_date.is_null() {
opts2 = opts2.expire_date((*(*opts).expire_date).into());
Expand Down Expand Up @@ -593,7 +593,7 @@ pub unsafe extern "C" fn lb_trade_context_estimate_max_purchase_quantity(
let side = (*opts).side.into();
let mut opts2 = EstimateMaxPurchaseQuantityOptions::new(symbol, order_type, side);
if !(*opts).price.is_null() {
opts2 = opts2.price((*(*opts).price).0);
opts2 = opts2.price((*(*opts).price).value);
}
if !(*opts).currency.is_null() {
opts2 = opts2.currency(cstr_to_rust((*opts).currency));
Expand Down
Loading

0 comments on commit 7b009df

Please sign in to comment.