From be4df6705c1963166b4123097e49050426bb666a Mon Sep 17 00:00:00 2001 From: Sunli Date: Mon, 11 Dec 2023 19:27:04 +0800 Subject: [PATCH 1/3] Update openapi.pyi --- python/pysrc/longport/openapi.pyi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/pysrc/longport/openapi.pyi b/python/pysrc/longport/openapi.pyi index d9ffb1a91..39b838158 100644 --- a/python/pysrc/longport/openapi.pyi +++ b/python/pysrc/longport/openapi.pyi @@ -119,9 +119,12 @@ class Config: """ Gets a new `access_token` - `expired_at` - The expiration time of the access token, defaults to `90` days. - """ + Args: + expired_at: The expiration time of the access token, defaults to `90` days. + Returns: + Access token + """ class Language: """ From 9e1613efcc243b8fc15e6fa610477ea364c530cc Mon Sep 17 00:00:00 2001 From: Sunli Date: Thu, 14 Dec 2023 10:48:27 +0800 Subject: [PATCH 2/3] chore: support CN endpoints 2 --- rust/src/config.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rust/src/config.rs b/rust/src/config.rs index bbfdf1148..21d6d628f 100644 --- a/rust/src/config.rs +++ b/rust/src/config.rs @@ -52,8 +52,18 @@ impl Config { ) -> Self { Self { http_cli_config: HttpClientConfig::new(app_key, app_secret, access_token), - quote_ws_url: QUOTE_WS_URL.to_string(), - trade_ws_url: TRADE_WS_URL.to_string(), + quote_ws_url: if is_cn() { + CN_QUOTE_WS_URL + } else { + QUOTE_WS_URL + } + .to_string(), + trade_ws_url: if is_cn() { + CN_TRADE_WS_URL + } else { + TRADE_WS_URL + } + .to_string(), language: Language::EN, } } From 8e4f0340c9117e1cf54cdcbb67cf2fb4578f956d Mon Sep 17 00:00:00 2001 From: Sunli Date: Thu, 14 Dec 2023 10:51:20 +0800 Subject: [PATCH 3/3] Release 1.0.5 longport@1.0.5 longport-c@1.0.5 longport-c-macros@1.0.5 longport-candlesticks@1.0.5 longport-httpcli@1.0.5 longport-java@1.0.5 longport-java-macros@1.0.5 longport-nodejs@1.0.5 longport-nodejs-macros@1.0.5 longport-proto@1.0.5 longport-python@1.0.5 longport-python-macros@1.0.5 longport-wscli@1.0.5 Generated by cargo-workspaces --- c/Cargo.toml | 2 +- c/crates/macros/Cargo.toml | 2 +- c/src/quote_context/context.rs | 2 +- c/src/quote_context/enum_types.rs | 1 + java/Cargo.toml | 2 +- java/crates/macros/Cargo.toml | 2 +- nodejs/Cargo.toml | 6 +++--- nodejs/crates/macros/Cargo.toml | 2 +- nodejs/src/decimal.rs | 3 +-- nodejs/src/quote/types.rs | 1 - nodejs/src/trade/types.rs | 1 - nodejs/src/types.rs | 1 - nodejs/src/utils.rs | 2 +- python/Cargo.toml | 2 +- python/crates/macros/Cargo.toml | 2 +- rust/Cargo.toml | 10 +++++----- rust/crates/candlesticks/Cargo.toml | 2 +- rust/crates/httpclient/Cargo.toml | 2 +- rust/crates/proto/Cargo.toml | 2 +- rust/crates/wsclient/Cargo.toml | 4 ++-- 20 files changed, 24 insertions(+), 27 deletions(-) diff --git a/c/Cargo.toml b/c/Cargo.toml index 3671a8c06..001c32204 100644 --- a/c/Cargo.toml +++ b/c/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-c" -version = "1.0.4" +version = "1.0.5" description = "LongPort OpenAPI SDK for C" homepage = "https://open.longportapp.com/en/" readme = "README.md" diff --git a/c/crates/macros/Cargo.toml b/c/crates/macros/Cargo.toml index ebbb68fa6..0d3ade298 100644 --- a/c/crates/macros/Cargo.toml +++ b/c/crates/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "longport-c-macros" -version = "1.0.4" +version = "1.0.5" edition = "2021" [lib] diff --git a/c/src/quote_context/context.rs b/c/src/quote_context/context.rs index d16649b1f..ea28702aa 100644 --- a/c/src/quote_context/context.rs +++ b/c/src/quote_context/context.rs @@ -788,7 +788,7 @@ pub unsafe extern "C" fn lb_quote_context_calc_indexes( let ctx_inner = (*ctx).ctx.clone(); let symbols = cstr_array_to_rust(symbols, num_symbols); let indexes = std::slice::from_raw_parts(indexes, num_indexes) - .into_iter() + .iter() .map(|index| (*index).into()); execute_async(callback, ctx, userdata, async move { let resp: CVec = diff --git a/c/src/quote_context/enum_types.rs b/c/src/quote_context/enum_types.rs index 4a0702be8..e7cf3061e 100644 --- a/c/src/quote_context/enum_types.rs +++ b/c/src/quote_context/enum_types.rs @@ -290,6 +290,7 @@ pub enum CSecuritiesUpdateMode { /// Calc index #[derive(Debug, Copy, Clone, Eq, PartialEq, CEnum)] #[c(remote = "longport::quote::CalcIndex")] +#[allow(clippy::enum_variant_names)] #[repr(C)] pub enum CCalcIndex { /// Latest price diff --git a/java/Cargo.toml b/java/Cargo.toml index 392b520a6..2b10a2493 100644 --- a/java/Cargo.toml +++ b/java/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-java" -version = "1.0.4" +version = "1.0.5" [lib] crate-type = ["cdylib"] diff --git a/java/crates/macros/Cargo.toml b/java/crates/macros/Cargo.toml index 03fc77c37..bcb5d399a 100644 --- a/java/crates/macros/Cargo.toml +++ b/java/crates/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "longport-java-macros" -version = "1.0.4" +version = "1.0.5" edition = "2021" [lib] diff --git a/nodejs/Cargo.toml b/nodejs/Cargo.toml index fd4c0336d..b2fd6a1bd 100644 --- a/nodejs/Cargo.toml +++ b/nodejs/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-nodejs" -version = "1.0.4" +version = "1.0.5" [lib] crate-type = ["cdylib"] @@ -10,13 +10,13 @@ crate-type = ["cdylib"] longport = { path = "../rust" } longport-nodejs-macros = { path = "crates/macros" } -napi = { version = "2.12.3", default-features = false, features = [ +napi = { version = "2.14.1", default-features = false, features = [ "napi4", "chrono_date", "async", "serde-json", ] } -napi-derive = "2.12.3" +napi-derive = "2.14.1" rust_decimal = { version = "1.23.1", features = ["maths"] } chrono = "0.4.19" time = { version = "0.3.9", features = ["macros", "formatting"] } diff --git a/nodejs/crates/macros/Cargo.toml b/nodejs/crates/macros/Cargo.toml index 8dd8add59..ad1d6c7fc 100644 --- a/nodejs/crates/macros/Cargo.toml +++ b/nodejs/crates/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "longport-nodejs-macros" -version = "1.0.4" +version = "1.0.5" edition = "2021" [lib] diff --git a/nodejs/src/decimal.rs b/nodejs/src/decimal.rs index c1bad04cc..c593e989d 100644 --- a/nodejs/src/decimal.rs +++ b/nodejs/src/decimal.rs @@ -32,8 +32,7 @@ macro_rules! decimal_constants { #[napi_derive::napi] impl Decimal { $( - #[napi(factory)] - #[napi(js_name = $name)] + #[napi(factory, js_name = $name)] #[allow(non_snake_case)] #[inline] pub fn $id() -> Self { diff --git a/nodejs/src/quote/types.rs b/nodejs/src/quote/types.rs index 007f98d94..e1129de1c 100644 --- a/nodejs/src/quote/types.rs +++ b/nodejs/src/quote/types.rs @@ -1,7 +1,6 @@ use chrono::{DateTime, Utc}; use longport::quote::SubFlags; use longport_nodejs_macros::{JsEnum, JsObject}; -use napi::bindgen_prelude::*; use crate::{ decimal::Decimal, diff --git a/nodejs/src/trade/types.rs b/nodejs/src/trade/types.rs index 250746750..1ffa048a3 100644 --- a/nodejs/src/trade/types.rs +++ b/nodejs/src/trade/types.rs @@ -1,6 +1,5 @@ use chrono::{DateTime, Utc}; use longport_nodejs_macros::{JsEnum, JsObject}; -use napi::bindgen_prelude::*; use crate::{decimal::Decimal, time::NaiveDate, types::Market}; diff --git a/nodejs/src/types.rs b/nodejs/src/types.rs index 151ac8fc1..26f1ad283 100644 --- a/nodejs/src/types.rs +++ b/nodejs/src/types.rs @@ -1,5 +1,4 @@ use longport_nodejs_macros::JsEnum; -use napi::bindgen_prelude::*; #[napi_derive::napi] #[derive(Debug, JsEnum, Hash, Eq, PartialEq)] diff --git a/nodejs/src/utils.rs b/nodejs/src/utils.rs index d2e24c14c..5b940bc8c 100644 --- a/nodejs/src/utils.rs +++ b/nodejs/src/utils.rs @@ -5,7 +5,7 @@ use time::OffsetDateTime; pub(crate) type JsCallback = ThreadsafeFunction; pub(crate) fn to_datetime(time: OffsetDateTime) -> DateTime { - DateTime::from_utc( + DateTime::from_naive_utc_and_offset( NaiveDateTime::from_timestamp_opt(time.unix_timestamp(), 0).unwrap(), Utc, ) diff --git a/python/Cargo.toml b/python/Cargo.toml index 933b7d223..39dfdc463 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-python" -version = "1.0.4" +version = "1.0.5" description = "LongPort OpenAPI SDK for Python" homepage = "https://open.longportapp.com/en/" readme = "README.md" diff --git a/python/crates/macros/Cargo.toml b/python/crates/macros/Cargo.toml index 94c746f50..b44774f7e 100644 --- a/python/crates/macros/Cargo.toml +++ b/python/crates/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "longport-python-macros" -version = "1.0.4" +version = "1.0.5" edition = "2021" [lib] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index b8322acc4..568276e15 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport" -version = "1.0.4" +version = "1.0.5" description = "LongPort OpenAPI SDK for Rust" homepage = "https://open.longportapp.com/en/" readme = "README.md" @@ -14,10 +14,10 @@ categories = ["api-bindings"] blocking = ["flume"] [dependencies] -longport-wscli = { path = "crates/wsclient", version = "1.0.4" } -longport-httpcli = { path = "crates/httpclient", version = "1.0.4" } -longport-proto = { path = "crates/proto", version = "1.0.4" } -longport-candlesticks = { path = "crates/candlesticks", version = "1.0.4" } +longport-wscli = { path = "crates/wsclient", version = "1.0.5" } +longport-httpcli = { path = "crates/httpclient", version = "1.0.5" } +longport-proto = { path = "crates/proto", version = "1.0.5" } +longport-candlesticks = { path = "crates/candlesticks", version = "1.0.5" } tokio = { version = "1.18.2", features = [ "time", diff --git a/rust/crates/candlesticks/Cargo.toml b/rust/crates/candlesticks/Cargo.toml index 404f9c14f..25e09c96b 100644 --- a/rust/crates/candlesticks/Cargo.toml +++ b/rust/crates/candlesticks/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-candlesticks" -version = "1.0.4" +version = "1.0.5" description = "LongPort candlestick utils for Rust" license = "MIT OR Apache-2.0" diff --git a/rust/crates/httpclient/Cargo.toml b/rust/crates/httpclient/Cargo.toml index e5ce794f3..a0075d6e7 100644 --- a/rust/crates/httpclient/Cargo.toml +++ b/rust/crates/httpclient/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-httpcli" -version = "1.0.4" +version = "1.0.5" description = "LongPort HTTP SDK for Rust" license = "MIT OR Apache-2.0" diff --git a/rust/crates/proto/Cargo.toml b/rust/crates/proto/Cargo.toml index 803cf4f03..b559ee55f 100644 --- a/rust/crates/proto/Cargo.toml +++ b/rust/crates/proto/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "longport-proto" -version = "1.0.4" +version = "1.0.5" description = "LongPort Protocol" license = "MIT OR Apache-2.0" diff --git a/rust/crates/wsclient/Cargo.toml b/rust/crates/wsclient/Cargo.toml index 87e77e59a..e0df0286a 100644 --- a/rust/crates/wsclient/Cargo.toml +++ b/rust/crates/wsclient/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "longport-wscli" -version = "1.0.4" +version = "1.0.5" edition = "2021" description = "LongPort Websocket SDK for Rust" license = "MIT OR Apache-2.0" [dependencies] -longport-proto = { path = "../proto", version = "1.0.4" } +longport-proto = { path = "../proto", version = "1.0.5" } tokio = { version = "1.18.2", features = [ "time",