Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Oct 21, 2024
1 parent 8906bc0 commit de6f9a2
Show file tree
Hide file tree
Showing 41 changed files with 168 additions and 95 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-22.04, windows-latest, macos-13]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -109,6 +109,8 @@ jobs:
universal2: true
- version: "3.12"
universal2: true
- version: "3.13"
universal2: true
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -154,7 +156,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [x64, x86]
steps:
- name: Checkout
Expand Down Expand Up @@ -193,7 +195,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [x86_64, i686]
steps:
- name: Checkout
Expand Down Expand Up @@ -227,7 +229,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [aarch64]
steps:
- name: Checkout
Expand All @@ -240,11 +242,12 @@ jobs:
target: ${{ matrix.target }}
manylinux: 2_28
args: -i python${{ matrix.python-version }} --out dist -m python/Cargo.toml
- uses: uraimo/run-on-arch-action@v2.2.0
- uses: uraimo/run-on-arch-action@v2
name: Install built wheel
with:
arch: ${{ matrix.target }}
distro: ubuntu20.04
arch: none
distro: none
base_image: "--platform=linux/aarch64 ubuntu:20.04"
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/dist:/artifacts"
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
universal2: true
- version: "3.12"
universal2: true
- version: "3.13"
universal2: true
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -67,7 +69,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [x64, x86]
steps:
- name: Checkout
Expand Down Expand Up @@ -104,7 +106,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [x86_64, i686]
steps:
- name: Checkout
Expand Down Expand Up @@ -136,7 +138,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
target: [aarch64]
steps:
- name: Checkout
Expand All @@ -149,11 +151,12 @@ jobs:
target: ${{ matrix.target }}
manylinux: 2_28
args: -i python${{ matrix.python-version }} --release --out dist -m python/Cargo.toml
- uses: uraimo/run-on-arch-action@v2.2.0
- uses: uraimo/run-on-arch-action@v2
name: Install built wheel
with:
arch: ${{ matrix.target }}
distro: ubuntu20.04
arch: none
distro: none
base_image: "--platform=linux/aarch64 ubuntu:20.04"
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/dist:/artifacts"
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

# [2.0.0] 2024-10-09

### Added

- Print the opened quote packages when connected to the server.
- Add `EstimateMaxPurchaseQuantityOptions.fractional_shares` field, sets to `true` to get the maximum fractional share buying power.
- The quantity type in the trading API has changed from `int` to `Decimal`.
- Print the quote packages when connected to the server.

# [1.0.32] 2024-08-28

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ LongPort OpenAPI provides programmatic quote trading interfaces for investors wi

**This repo contains the following main components:**

| Name | Document | Description |
|-----------------------------|---------------------------------------------------------------------------|-------------------------------------------|
| [Rust](rust/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/rust/longport/index.html) | LongPort OpenAPI for Rust `(>= 1.56.1)` |
| [Python](python/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/python/index.html) | LongPort OpenAPI for Python 3 `(>= 3.7)` |
| [Node.js](nodejs/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/nodejs/index.html) | LongPort OpenAPI for Node.js `(>= 10)` |
| [Java](java/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/java/index.html) | LongPort OpenAPI for Java `(>= 1.8)` |
| [C](c/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/c/index.html) | LongPort OpenAPI for C `(>= C99)` |
| [C++](cpp/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/cpp/index.html) | LongPort OpenAPI for C++`(>= C++17)` |
| Go | | https://github.com/longportapp/openapi-go |
| Name | Document | Description |
|-----------------------------|------------------------------------------------------------------------------|-------------------------------------------|
| [Rust](rust/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/v2/rust/longport/index.html) | LongPort OpenAPI for Rust `(>= 1.56.1)` |
| [Python](python/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/v2/python/index.html) | LongPort OpenAPI for Python 3 `(>= 3.7)` |
| [Node.js](nodejs/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/v2/nodejs/index.html) | LongPort OpenAPI for Node.js `(>= 10)` |
| [Java](java/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/v2/java/index.html) | LongPort OpenAPI for Java `(>= 1.8)` |
| [C](c/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/v2/c/index.html) | LongPort OpenAPI for C `(>= C99)` |
| [C++](cpp/README.md) | [Doc](https://longportapp.github.io/openapi-sdk/v2/cpp/index.html) | LongPort OpenAPI for C++`(>= C++17)` |
| Go | | https://github.com/longportapp/openapi-go |

## SDK Documenation

Expand Down
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.42"
version = "2.0.0"
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.42"
version = "2.0.0"
edition = "2021"

[lib]
Expand Down
1 change: 1 addition & 0 deletions c/csrc/include/longport.h
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,7 @@ typedef struct lb_estimate_max_purchase_quantity_options_t {
enum lb_order_side_t side;
const char *currency;
const char *order_id;
bool fractional_shares;
} lb_estimate_max_purchase_quantity_options_t;

typedef struct lb_subscription_t {
Expand Down
3 changes: 3 additions & 0 deletions c/src/trade_context/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ pub unsafe extern "C" fn lb_trade_context_estimate_max_purchase_quantity(
if !(*opts).order_id.is_null() {
opts2 = opts2.order_id(cstr_to_rust((*opts).order_id));
}
if (*opts).fractional_shares {
opts2 = opts2.fractional_shares();
}
execute_async(callback, ctx, userdata, async move {
let resp: CCow<CEstimateMaxPurchaseQuantityResponseOwned> =
CCow::new(ctx_inner.estimate_max_purchase_quantity(opts2).await?);
Expand Down
1 change: 1 addition & 0 deletions c/src/trade_context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,7 @@ pub struct CEstimateMaxPurchaseQuantityOptions {
pub side: COrderSide,
pub currency: *const c_char,
pub order_id: *const c_char,
pub fractional_shares: bool,
}

/// Options for estimate maximum purchase quantity
Expand Down
1 change: 1 addition & 0 deletions cpp/include/decimal.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <ostream>
#include <stdint.h>
#include <string>
#include <utility>

Expand Down
2 changes: 2 additions & 0 deletions cpp/include/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,8 @@ struct EstimateMaxPurchaseQuantityOptions
/// Order ID, required when estimating the maximum purchase quantity for a
/// modified order
std::optional<std::string> order_id;
/// Get the maximum fractional share buying power
bool fractional_shares;
};

/// Response for estimate maximum purchase quantity
Expand Down
1 change: 1 addition & 0 deletions cpp/src/trade_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ TradeContext::estimate_max_purchase_quantity(
convert(opts.side),
opts.currency ? opts.currency->c_str() : nullptr,
opts.order_id ? opts.order_id->c_str() : nullptr,
opts.fractional_shares,
};

lb_trade_context_estimate_max_purchase_quantity(
Expand Down
2 changes: 1 addition & 1 deletion java/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "longport-java"
version = "1.0.42"
version = "2.0.0"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion java/crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "longport-java-macros"
version = "1.0.42"
version = "2.0.0"
edition = "2021"

[lib]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class EstimateMaxPurchaseQuantityOptions {
private BigDecimal price;
private String currency;
private String orderId;
private boolean fractionalShares;

public EstimateMaxPurchaseQuantityOptions(String symbol, OrderType orderType, OrderSide side) {
this.symbol = symbol;
Expand All @@ -31,4 +32,9 @@ public EstimateMaxPurchaseQuantityOptions setOrderId(String orderId) {
this.orderId = orderId;
return this;
}

public EstimateMaxPurchaseQuantityOptions fractionalShares() {
this.fractionalShares = true;
return this;
}
}
4 changes: 4 additions & 0 deletions java/src/trade_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,10 @@ pub unsafe extern "system" fn Java_com_longport_SdkNative_tradeContextEstimateMa
if let Some(order_id) = order_id {
new_opts = new_opts.order_id(order_id);
}
let fractional_shares: bool = get_field(env, &opts, "fractionalShares")?;
if fractional_shares {
new_opts = new_opts.fractional_shares();
}
async_util::execute(env, callback, async move {
Ok(context.ctx.estimate_max_purchase_quantity(new_opts).await?)
})?;
Expand Down
2 changes: 1 addition & 1 deletion nodejs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "longport-nodejs"
version = "1.0.42"
version = "2.0.0"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion nodejs/crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "longport-nodejs-macros"
version = "1.0.42"
version = "2.0.0"
edition = "2021"

[lib]
Expand Down
1 change: 1 addition & 0 deletions nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export interface EstimateMaxPurchaseQuantityOptions {
price?: Decimal
currency?: string
orderId?: string
fractionalShares: boolean
}
/** Options for get cash flow request */
export interface GetCashFlowOptions {
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/quote/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl QuoteContext {
pub fn quote_package_details(&self) -> Result<Vec<QuotePackageDetail>> {
self.ctx
.quote_package_details()
.into_iter()
.iter()
.cloned()
.map(TryInto::try_into)
.collect()
Expand Down
4 changes: 4 additions & 0 deletions nodejs/src/trade/requests/estimate_max_purchase_quantity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct EstimateMaxPurchaseQuantityOptions {
pub price: Option<ClassInstance<Decimal>>,
pub currency: Option<String>,
pub order_id: Option<String>,
pub fractional_shares: bool,
}

impl From<EstimateMaxPurchaseQuantityOptions>
Expand All @@ -35,6 +36,9 @@ impl From<EstimateMaxPurchaseQuantityOptions>
if let Some(order_id) = opts.order_id {
opts2 = opts2.order_id(order_id);
}
if opts.fractional_shares {
opts2 = opts2.fractional_shares();
}
opts2
}
}
6 changes: 3 additions & 3 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "longport-python"
version = "1.0.42"
version = "2.0.0"
description = "LongPort OpenAPI SDK for Python"
homepage = "https://open.longportapp.com/en/"
readme = "README.md"
Expand All @@ -20,8 +20,8 @@ longport-python-macros = { path = "crates/macros" }

once_cell = "1.11.0"
parking_lot = "0.12.1"
pyo3 = { version = "0.21.2", features = ["extension-module"] }
pythonize = "0.21.1"
pyo3 = { version = "0.22.5", features = ["extension-module"] }
pythonize = "0.22.0"
rust_decimal = "1.23.1"
serde_json = "1.0.93"
time = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion python/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ args = ["install", "maturin>=1.0,<2.0"]
command = "pip"
args = [
"install",
"target/wheels/longport-1.0.39-cp311-none-win_amd64.whl",
"target/wheels/longport-2.0.0-cp311-none-win_amd64.whl",
"-I",
]
dependencies = ["python"]
2 changes: 1 addition & 1 deletion python/crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "longport-python-macros"
version = "1.0.42"
version = "2.0.0"
edition = "2021"

[lib]
Expand Down
3 changes: 2 additions & 1 deletion python/pysrc/longport/openapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5128,7 +5128,7 @@ class TradeContext:
print(resp)
"""

def estimate_max_purchase_quantity(self, symbol: str, order_type: Type[OrderType], side: Type[OrderSide], price: Optional[Decimal] = None, currency: Optional[str] = None, order_id: Optional[str] = None) -> EstimateMaxPurchaseQuantityResponse:
def estimate_max_purchase_quantity(self, symbol: str, order_type: Type[OrderType], side: Type[OrderSide], price: Optional[Decimal] = None, currency: Optional[str] = None, order_id: Optional[str] = None, fractional_shares: bool = False) -> EstimateMaxPurchaseQuantityResponse:
"""
Estimating the maximum purchase quantity for Hong Kong and US stocks, warrants, and options
Expand All @@ -5139,6 +5139,7 @@ class TradeContext:
price: Estimated order price,
currency: Settlement currency
order_id: Order ID, required when estimating the maximum purchase quantity for a modified order
fractional_shares: Get the maximum fractional share buying power
Returns:
Response
Expand Down
1 change: 1 addition & 0 deletions python/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl Config {
///
/// `expired_at` - The expiration time of the access token, defaults to `90`
/// days.
#[pyo3(signature = (expired_at = None))]
pub fn refresh_access_token(
&self,
expired_at: Option<PyOffsetDateTimeWrapper>,
Expand Down
Loading

0 comments on commit de6f9a2

Please sign in to comment.