Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Oct 18, 2024
1 parent 338caff commit e8b2399
Show file tree
Hide file tree
Showing 32 changed files with 251 additions and 201 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ slug: changelog
sidebar_position: 7
---

## 2024-10-09

### SDK 2.0.0

- 连接到服务器时打印已开通的行情包
- 交易 API 中的数量类型从 `int` 更改为 `Decimal`

## 2024-08-28

- SDK 中 `Depth.price` 字段从 `Decimal` 类型改为 `Optional[Decimal]` 类型
Expand Down
20 changes: 10 additions & 10 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ go get github.com/longportapp/openapi-go
请注意保护好您的 **Access Token** 信息,任何人获得到它,都可以通过 OpenAPI 来交易你的账户!
:::

| 环境变量 | 说明 | 值范围 |
| --------------------------- | ------------------------------------------------------------ | --------------- |
| `LONGPORT_APP_KEY` | 从页面上获取到的 App Key | |
| `LONGPORT_APP_SECRET` | 从页面上获取到的 App Secret | |
| `LONGPORT_ACCESS_TOKEN` | 从页面上获取到的 Access Token | |
| 环境变量 | 说明 | 值范围 |
|-----------------------------|----------------------------------------------------------|-----------------|
| `LONGPORT_APP_KEY` | 从页面上获取到的 App Key | |
| `LONGPORT_APP_SECRET` | 从页面上获取到的 App Secret | |
| `LONGPORT_ACCESS_TOKEN` | 从页面上获取到的 Access Token | |
| `LONGPORT_REGION` | API 服务器接入点,请根据你所在地区设置,以获得更好的连接速度 | `hk`, `cn` |
| `LONGPORT_ENABLE_OVERNIGHT` | 是否开启夜盘行情,设置 `true` 开启,`false` 关闭 | `true`, `false` |

Expand Down Expand Up @@ -666,8 +666,8 @@ resp = ctx.submit_order(
side=OrderSide.Buy,
symbol="700.HK",
order_type=OrderType.LO,
submitted_price=Decimal("50"),
submitted_quantity=200,
submitted_price=Decimal(50),
submitted_quantity=Decimal(200),
time_in_force=TimeInForceType.Day,
remark="Hello from Python SDK",
)
Expand Down Expand Up @@ -696,7 +696,7 @@ TradeContext.new(config)
orderType: OrderType.LO,
side: OrderSide.Buy,
timeInForce: TimeInForceType.Day,
submittedQuantity: 200,
submittedQuantity: new Decimal(200),
submittedPrice: new Decimal('300'),
})
)
Expand Down Expand Up @@ -732,7 +732,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
"700.HK",
OrderType::LO,
OrderSide::Buy,
200,
decimal!(200i32),
TimeInForceType::Day,
)
.submitted_price(decimal!(50i32));
Expand Down Expand Up @@ -764,7 +764,7 @@ public class Main {
SubmitOrderOptions opts = new SubmitOrderOptions("700.HK",
OrderType.LO,
OrderSide.Buy,
200,
new BigDecimal(200),
TimeInForceType.Day).setSubmittedPrice(new BigDecimal(50));
SubmitOrderResponse resp = ctx.submitOrder(opts).get();
System.out.println(resp);
Expand Down
28 changes: 14 additions & 14 deletions docs/trade/order/submit.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ headingLevel: 3

> Content-Type: application/json; charset=utf-8
| Name | Type | Required | Description |
| ------------------ | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| symbol | string | YES | 股票代码,使用 `ticker.region` 格式,例如:`AAPL.US` |
| order_type | string | YES | [订单类型](../trade-definition#ordertype) |
| Name | Type | Required | Description |
|--------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------------|
| symbol | string | YES | 股票代码,使用 `ticker.region` 格式,例如:`AAPL.US` |
| order_type | string | YES | [订单类型](../trade-definition#ordertype) |
| submitted_price | string | NO | 下单价格,例如:`388.5`<br/><br/> `LO` / `ELO` / `ALO` / `ODD` / `LIT` 订单必填 |
| submitted_quantity | string | YES | 下单数量,例如:`100` |
| trigger_price | string | NO | 触发价格,例如:`388.5`<br/><br/> `LIT` / `MIT` 订单必填 |
| limit_offset | string | NO | 指定价差,例如 "1.2" 表示价差 1.2 USD (如果是美股)<br/><br/> `TSLPAMT` / `TSLPPCT` 订单必填 |
| trailing_amount | string | NO | 跟踪金额<br/><br/> `TSLPAMT` 订单必填 |
| limit_offset | string | NO | 指定价差,例如 "1.2" 表示价差 1.2 USD (如果是美股)<br/><br/> `TSLPAMT` / `TSLPPCT` 订单必填 |
| trailing_amount | string | NO | 跟踪金额<br/><br/> `TSLPAMT` 订单必填 |
| trailing_percent | string | NO | 跟踪涨跌幅,单位为百分比,例如 "2.5" 表示 "2.5%"<br/><br/> `TSLPPCT` 订单必填 |
| expire_date | string | NO | 长期单过期时间,格式为 `YYYY-MM-DD`, 例如:`2022-12-05`<br/><br/> time_in_force 为 `GTD` 时必填 |
| side | string | YES | 买卖方向<br/><br/> **可选值:**<br/> `Buy` - 买入<br/> `Sell` - 卖出 |
| side | string | YES | 买卖方向<br/><br/> **可选值:**<br/> `Buy` - 买入<br/> `Sell` - 卖出 |
| outside_rth | string | NO | 是否允许盘前盘后,美股必填<br/><br/> **可选值:**<br/> `RTH_ONLY` - 不允许盘前盘后<br/> `ANY_TIME` - 允许盘前盘后<br/> `OVERNIGHT` - 夜盘 |
| time_in_force | string | YES | 订单有效期类型<br/><br/> **可选值:**<br/> `Day` - 当日有效<br/> `GTC` - 撤单前有效<br/> `GTD` - 到期前有效 |
| remark | string | NO | 备注 (最大 64 字符) |
| time_in_force | string | YES | 订单有效期类型<br/><br/> **可选值:**<br/> `Day` - 当日有效<br/> `GTC` - 撤单前有效<br/> `GTD` - 到期前有效 |
| remark | string | NO | 备注 (最大 64 字符) |

## Examples

Expand All @@ -61,9 +61,9 @@ resp = ctx.submit_order(
"700.HK",
OrderType.LO,
OrderSide.Buy,
100,
Decimal(100),
TimeInForceType.Day,
submitted_price=Decimal("380"),
submitted_price=Decimal(380),
remark="Hello from Python SDK",
)
```
Expand All @@ -83,7 +83,7 @@ ctx.submit_order(
"700.HK",
OrderType.MO,
OrderSide.Sell,
100,
Decimal(100),
TimeInForceType.Day,
remark="Hello from Python SDK",
)
Expand All @@ -107,7 +107,7 @@ ctx.submit_order(
"NVDA.US",
OrderType.LIT,
OrderSide.Sell,
100,
Decimal(100),
TimeInForceType.GoodTilCanceled,
Decimal("999.00"),
trigger_price=Decimal("1000.00"),
Expand All @@ -134,7 +134,7 @@ ctx.submit_order(
"NVDA.US",
OrderType.TSLPPCT,
OrderSide.Sell,
100,
Decimal(100),
TimeInForceType.GoodTilDate,
expire_date=datetime.date(2024, 6, 30),
trailing_percent=Decimal("0.5"),
Expand Down
4 changes: 2 additions & 2 deletions docs/trade/trade-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ resp = ctx.submit_order(
side=OrderSide.Buy,
symbol="700.HK",
order_type=OrderType.LO,
submitted_price=Decimal("50"),
submitted_quantity=200,
submitted_price=Decimal(50),
submitted_quantity=Decimal(200),
time_in_force=TimeInForceType.Day,
remark="Hello from Python SDK",
)
Expand Down
7 changes: 7 additions & 0 deletions i18n/en/docusaurus-plugin-content-docs/current/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ slug: changelog
sidebar_position: 7
---

## 2024-10-09

### SDK 2.0.0

- Print the opened quote packages when connected to the server.
- The quantity type in the trading API has changed from `int` to `Decimal`.

## 2024-08-28

- Change the `Depth.price` field in the SDK from `Decimal` type to `Optional[Decimal]` type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Please pay attention to protect your **Access Token** information, anyone who ge
:::

| 环境变量 | 说明 | 值范围 |
| --------------------------- | ------------------------------------------------------------------ | --------------- |
|-----------------------------|--------------------------------------------------------------------|-----------------|
| `LONGPORT_APP_KEY` | App Key get from developer center | |
| `LONGPORT_APP_SECRET` | App Secret get from developer center | |
| `LONGPORT_ACCESS_TOKEN` | Access Token get from developer center | |
Expand Down Expand Up @@ -665,8 +665,8 @@ resp = ctx.submit_order(
side=OrderSide.Buy,
symbol="700.HK",
order_type=OrderType.LO,
submitted_price=Decimal("50"),
submitted_quantity=200,
submitted_price=Decimal(50),
submitted_quantity=Decimal(200),
time_in_force=TimeInForceType.Day,
remark="Hello from Python SDK",
)
Expand Down Expand Up @@ -695,8 +695,8 @@ TradeContext.new(config)
orderType: OrderType.LO,
side: OrderSide.Buy,
timeInForce: TimeInForceType.Day,
submittedQuantity: 200,
submittedPrice: new Decimal('300'),
submittedQuantity: new Decimal(200),
submittedPrice: new Decimal(300),
})
)
.then((resp) => console.log(resp.toString()))
Expand Down Expand Up @@ -731,7 +731,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
"700.HK",
OrderType::LO,
OrderSide::Buy,
200,
decimal!(200i32),
TimeInForceType::Day,
)
.submitted_price(decimal!(50i32));
Expand Down Expand Up @@ -763,7 +763,7 @@ public class Main {
SubmitOrderOptions opts = new SubmitOrderOptions("700.HK",
OrderType.LO,
OrderSide.Buy,
200,
new BigDecimal(200),
TimeInForceType.Day).setSubmittedPrice(new BigDecimal(50));
SubmitOrderResponse resp = ctx.submitOrder(opts).get();
System.out.println(resp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This API is used for placing orders for Hong Kong and US stocks, warrants, and o
> Content-Type: application/json; charset=utf-8
| Name | Type | Required | Description |
| ------------------ | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|--------------------|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| symbol | string | YES | Stock symbol, use `ticker.region` format, example: `AAPL.US` |
| order_type | string | YES | [Order Type](../trade-definition#ordertype) |
| submitted_price | string | NO | Submitted price, example: `388.5`<br/><br/> `LO` / `ELO` / `ALO` / `ODD` / `LIT` Order Required |
Expand Down Expand Up @@ -61,9 +61,9 @@ resp = ctx.submit_order(
"700.HK",
OrderType.LO,
OrderSide.Buy,
100,
Decimal(100),
TimeInForceType.Day,
submitted_price=Decimal("380"),
submitted_price=Decimal(380),
remark="Hello from Python SDK",
)
```
Expand All @@ -83,7 +83,7 @@ ctx.submit_order(
"700.HK",
OrderType.MO,
OrderSide.Sell,
100,
Decimal(100),
TimeInForceType.Day,
remark="Hello from Python SDK",
)
Expand All @@ -107,7 +107,7 @@ ctx.submit_order(
"NVDA.US",
OrderType.LIT,
OrderSide.Sell,
100,
Decimal(100),
TimeInForceType.GoodTilCanceled,
Decimal("999.00"),
trigger_price=Decimal("1000.00"),
Expand All @@ -134,7 +134,7 @@ ctx.submit_order(
"NVDA.US",
OrderType.TSLPPCT,
OrderSide.Sell,
100,
Decimal(100),
TimeInForceType.GoodTilDate,
expire_date=datetime.date(2024, 6, 30),
trailing_percent=Decimal("0.5"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ resp = ctx.submit_order(
side=OrderSide.Buy,
symbol="700.HK",
order_type=OrderType.LO,
submitted_price=Decimal("50"),
submitted_quantity=200,
submitted_price=Decimal(50),
submitted_quantity=Decimal(200),
time_in_force=TimeInForceType.Day,
remark="Hello from Python SDK",
)
Expand Down
3 changes: 2 additions & 1 deletion i18n/en/sdk-versions/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

### API Documents

https://longportapp.github.io/openapi-sdk/cpp/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/cpp/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/cpp/index.html)
3 changes: 2 additions & 1 deletion i18n/en/sdk-versions/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Add the following line to your `pom.xml` file

### API Documents

https://longportapp.github.io/openapi-sdk/java/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/java/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/java/index.html)
3 changes: 2 additions & 1 deletion i18n/en/sdk-versions/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ $ npm install longport --save

### API Documents

https://longportapp.github.io/openapi-sdk/nodejs/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/nodejs/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/nodejs/index.html)
3 changes: 2 additions & 1 deletion i18n/en/sdk-versions/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ $ pip install longport
### API Documents

https://longportapp.github.io/openapi-sdk/python/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/python/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/python/index.html)
3 changes: 2 additions & 1 deletion i18n/en/sdk-versions/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ longport = "1.0.0"

### API Documents

[https://longportapp.github.io/openapi-sdk/rust/index.html](https://longportapp.github.io/openapi-sdk/rust/longport/index.html)
- [v1](https://longportapp.github.io/openapi-sdk/v1/rust/longport/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/rust/longport/index.html)
6 changes: 4 additions & 2 deletions i18n/zh-CN/sdk-versions/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

### 下载地址

- [openapi-cpp-sdk-1.0.32.tar.gz](https://static.lbctrl.com/openapi-sdk/openapi-cpp-sdk-1.0.32.tar.gz)
- [1.0.42](https://static.lbctrl.com/openapi-sdk/openapi-cpp-sdk-1.0.42.tar.gz)
- [2.0.0](https://static.lbctrl.com/openapi-sdk/openapi-cpp-sdk-2.0.0.tar.gz)

### API 文档

https://longportapp.github.io/openapi-sdk/cpp/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/cpp/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/cpp/index.html)
3 changes: 2 additions & 1 deletion i18n/zh-CN/sdk-versions/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@

### API 文档

https://longportapp.github.io/openapi-sdk/java/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/java/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/java/index.html)
3 changes: 2 additions & 1 deletion i18n/zh-CN/sdk-versions/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ $ npm install longport --save

### API 文档

https://longportapp.github.io/openapi-sdk/nodejs/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/nodejs/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/nodejs/index.html)
3 changes: 2 additions & 1 deletion i18n/zh-CN/sdk-versions/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ $ pip install longport -i https://mirrors.aliyun.com/pypi/simple

### API 文档

https://longportapp.github.io/openapi-sdk/python/index.html
- [v1](https://longportapp.github.io/openapi-sdk/v1/python/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/python/index.html)
5 changes: 3 additions & 2 deletions i18n/zh-CN/sdk-versions/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

```toml
[dependencies]
longport = "1.0.0"
longport = "2.0.0"
```

[https://crates.io/crates/longport](https://crates.io/crates/longport)

### API 文档

[https://longportapp.github.io/openapi-sdk/rust/index.html](https://longportapp.github.io/openapi-sdk/rust/longport/index.html)
- [v1](https://longportapp.github.io/openapi-sdk/v1/rust/longport/index.html)
- [v2](https://longportapp.github.io/openapi-sdk/v2/rust/longport/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ slug: changelog
sidebar_position: 7
---

## 2024-10-09

### SDK 2.0.0

- 連接伺服器時列印已開啟的行情包
- 交易 API 中的數量類型從 `int` 變更為 `Decimal`


## 2024-08-28

- SDK 中 `Depth.price` 字段从 `Decimal` 类型改为 `Optional[Decimal]` 类型
Expand Down
Loading

0 comments on commit e8b2399

Please sign in to comment.