longport 3.0.21__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
longport/py.typed ADDED
File without changes
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: longport
3
+ Version: 3.0.21
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Topic :: Office/Business :: Financial
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Programming Language :: Python :: Implementation :: CPython
9
+ Summary: A Python library for LongPort Open API
10
+ Home-Page: https://open.longportapp.com/en/
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
13
+ Project-URL: changelog, https://github.com/longportapp/openapi/blob/master/python/CHANGELOG.md
14
+ Project-URL: documentation, https://open.longportapp.com/en/docs
15
+ Project-URL: homepage, https://open.longportapp.com/en/
16
+ Project-URL: repository, https://github.com/longportapp/openapi
17
+
18
+ # LongPort OpenAPI SDK for Python
19
+
20
+ `longport` provides an easy-to-use interface for invoking [`LongPort OpenAPI`](https://open.longportapp.com/en/).
21
+
22
+ ## Documentation
23
+
24
+ - SDK docs: https://longportapp.github.io/openapi/python/index.html
25
+ - LongPort OpenAPI: https://open.longportapp.com/en/
26
+
27
+ ## Examples
28
+
29
+ Runnable examples live in `examples/python/`:
30
+
31
+ - `examples/python/account_asset.py`
32
+ - `examples/python/history_candlesticks.py`
33
+ - `examples/python/http_client.py`
34
+ - `examples/python/subscribe_candlesticks.py`
35
+ - `examples/python/subscribe_quote.py`
36
+ - `examples/python/submit_order.py`
37
+ - `examples/python/today_orders.py`
38
+
39
+ ## References
40
+
41
+ - [Config](https://longportapp.github.io/openapi/python/config/)
42
+
43
+ The configuration of the SDK.
44
+
45
+ - [QuoteContext](https://longportapp.github.io/openapi/python/quote_context/)
46
+
47
+ The Quote API part of the SDK, e.g.: get basic information of securities, subscribe quotes...
48
+
49
+ - [TradeContext](https://longportapp.github.io/openapi/python/trade_context/)
50
+
51
+ The Trade API part of the SDK, e.g.: submit order, get order status...
52
+
53
+ ## Quickstart
54
+
55
+ _Install LongPort OpenAPI SDK_
56
+
57
+ ```bash
58
+ pip install longport
59
+ ```
60
+
61
+ _Setting environment variables(MacOS/Linux)_
62
+
63
+ ```bash
64
+ export LONGPORT_APP_KEY="App Key get from user center"
65
+ export LONGPORT_APP_SECRET="App Secret get from user center"
66
+ export LONGPORT_ACCESS_TOKEN="Access Token get from user center"
67
+ ```
68
+
69
+ _Setting environment variables(Windows)_
70
+
71
+ ```powershell
72
+ setx LONGPORT_APP_KEY "App Key get from user center"
73
+ setx LONGPORT_APP_SECRET "App Secret get from user center"
74
+ setx LONGPORT_ACCESS_TOKEN "Access Token get from user center"
75
+ ```
76
+
77
+ ## Quote API _(Get basic information of securities)_
78
+
79
+ ```python
80
+ from longport.openapi import Config, QuoteContext
81
+
82
+ # Load configuration from environment variables
83
+ config = Config.from_env()
84
+
85
+ # Create a context for quote APIs
86
+ ctx = QuoteContext(config)
87
+
88
+ # Get basic information of securities
89
+ resp = ctx.quote(["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"])
90
+ print(resp)
91
+ ```
92
+
93
+ ## Quote API _(Subscribe quotes)_
94
+
95
+ ```python
96
+ from time import sleep
97
+ from longport.openapi import Config, QuoteContext, SubType, PushQuote
98
+
99
+ # Load configuration from environment variables
100
+ config = Config.from_env()
101
+
102
+ # A callback to receive quote data
103
+ def on_quote(symbol: str, event: PushQuote):
104
+ print(symbol, event)
105
+
106
+ # Create a context for quote APIs
107
+ ctx = QuoteContext(config)
108
+ ctx.set_on_quote(on_quote)
109
+
110
+ # Subscribe
111
+ resp = ctx.subscribe(["700.HK"], [SubType.Quote], is_first_push=True)
112
+
113
+ # Receive push duration to 30 seconds
114
+ sleep(30)
115
+ ```
116
+
117
+ ## Trade API _(Submit order)_
118
+
119
+ ```python
120
+ from decimal import Decimal
121
+ from longport.openapi import TradeContext, Config, OrderType, OrderSide, TimeInForceType
122
+
123
+ # Load configuration from environment variables
124
+ config = Config.from_env()
125
+
126
+ # Create a context for trade APIs
127
+ ctx = TradeContext(config)
128
+
129
+ # Submit order
130
+ resp = ctx.submit_order("700.HK", OrderType.LO, OrderSide.Buy, Decimal(
131
+ "500"), TimeInForceType.Day, submitted_price=Decimal("50"), remark="Hello from Python SDK")
132
+ print(resp)
133
+ ```
134
+
135
+ ## Troubleshooting
136
+
137
+ - Windows `setx` requires a new terminal; use `set` for the current `cmd.exe` session.
138
+ - If the program exits, you won't receive push events; keep the process alive (e.g. `sleep(...)`).
139
+ - For debugging, set `LONGPORT_LOG_PATH` to enable SDK logs.
140
+
141
+ ## License
142
+
143
+ Licensed under either of
144
+
145
+ * Apache License, Version 2.0,([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
146
+ * MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option.
147
+
@@ -0,0 +1,8 @@
1
+ longport\__init__.py,sha256=w0BoFVpP8sPQKKt15KJCIXIE2KP7rL3VNg4ILWGWX7s,641
2
+ longport\longport.cp310-win_amd64.pyd,sha256=fd-vTGi1UiYllFSTVMghf4PqAevrgkHqtzxE2A-gTI0,9816576
3
+ longport\openapi.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ longport\openapi.pyi,sha256=ZI1HLI7MEBIMBBNDau-ddoYItCKg2ZxCUO7bjRUzDjs,103326
5
+ longport\py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ longport-3.0.21.dist-info\METADATA,sha256=p0gHPeDM-bl9iSGqXzSko93rs9lDAven9tQ44QE9upE,4458
7
+ longport-3.0.21.dist-info\WHEEL,sha256=L_nHnx2hhpjVM_Xfu45p0kXGA_F4gVVL8EpDS6M9jpM,97
8
+ longport-3.0.21.dist-info\RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.5)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-win_amd64