longport 3.0.18__cp314-cp314-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,124 @@
1
+ Metadata-Version: 2.4
2
+ Name: longport
3
+ Version: 3.0.18
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.7
12
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
13
+ Project-URL: homepage, https://open.longportapp.com/en/
14
+ Project-URL: documentation, https://open.longportapp.com/en/docs
15
+ Project-URL: repository, https://github.com/longportapp/openapi
16
+ Project-URL: changelog, https://github.com/longportapp/openapi/blob/master/python/CHANGELOG.md
17
+
18
+ # LongPort OpenAPI SDK for Python
19
+
20
+ `longport` provides an easy-to-use interface for invokes [`LongPort OpenAPI`](https://open.longportapp.com/en/).
21
+
22
+ ## References
23
+
24
+ - [Config](https://longportapp.github.io/openapi/python/config/)
25
+
26
+ The configuration of the SDK.
27
+
28
+ - [QuoteContext](https://longportapp.github.io/openapi/python/quote_context/)
29
+
30
+ The Quote API part of the SDK, e.g.: get basic information of securities, subscribe quotes...
31
+
32
+ - [TradeContext](https://longportapp.github.io/openapi/python/trade_context/)
33
+
34
+ The Trade API part of the SDK, e.g.: submit order, get order status...
35
+
36
+ ## Quickstart
37
+
38
+ _Install LongPort OpenAPI SDK_
39
+
40
+ ```bash
41
+ pip install longport
42
+ ```
43
+
44
+ _Setting environment variables(MacOS/Linux)_
45
+
46
+ ```bash
47
+ export LONGPORT_APP_KEY="App Key get from user center"
48
+ export LONGPORT_APP_SECRET="App Secret get from user center"
49
+ export LONGPORT_ACCESS_TOKEN="Access Token get from user center"
50
+ ```
51
+
52
+ _Setting environment variables(Windows)_
53
+
54
+ ```powershell
55
+ setx LONGPORT_APP_KEY "App Key get from user center"
56
+ setx LONGPORT_APP_SECRET "App Secret get from user center"
57
+ setx LONGPORT_ACCESS_TOKEN "Access Token get from user center"
58
+ ```
59
+
60
+ ## Quote API _(Get basic information of securities)_
61
+
62
+ ```python
63
+ from longport.openapi import Config, QuoteContext
64
+
65
+ # Load configuration from environment variables
66
+ config = Config.from_env()
67
+
68
+ # Create a context for quote APIs
69
+ ctx = QuoteContext(config)
70
+
71
+ # Get basic information of securities
72
+ resp = ctx.quote(["700.HK", "AAPL.US", "TSLA.US", "NFLX.US"])
73
+ print(resp)
74
+ ```
75
+
76
+ ## Quote API _(Subscribe quotes)_
77
+
78
+ ```python
79
+ from time import sleep
80
+ from longport.openapi import Config, QuoteContext, SubType, PushQuote
81
+
82
+ # Load configuration from environment variables
83
+ config = Config.from_env()
84
+
85
+ # A callback to receive quote data
86
+ def on_quote(symbol: str, event: PushQuote):
87
+ print(symbol, event)
88
+
89
+ # Create a context for quote APIs
90
+ ctx = QuoteContext(config)
91
+ ctx.set_on_quote(on_quote)
92
+
93
+ # Subscribe
94
+ resp = ctx.subscribe(["700.HK"], [SubType.Quote], is_first_push=True)
95
+
96
+ # Receive push duration to 30 seconds
97
+ sleep(30)
98
+ ```
99
+
100
+ ## Trade API _(Submit order)_
101
+
102
+ ```python
103
+ from decimal import Decimal
104
+ from longport.openapi import TradeContext, Config, OrderType, OrderSide, TimeInForceType
105
+
106
+ # Load configuration from environment variables
107
+ config = Config.from_env()
108
+
109
+ # Create a context for trade APIs
110
+ ctx = TradeContext(config)
111
+
112
+ # Submit order
113
+ resp = ctx.submit_order("700.HK", OrderType.LO, OrderSide.Buy, Decimal(
114
+ "500"), TimeInForceType.Day, submitted_price=Decimal("50"), remark="Hello from Python SDK")
115
+ print(resp)
116
+ ```
117
+
118
+ ## License
119
+
120
+ Licensed under either of
121
+
122
+ * Apache License, Version 2.0,([LICENSE-APACHE](./LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
123
+ * MIT license ([LICENSE-MIT](./LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option.
124
+
@@ -0,0 +1,8 @@
1
+ longport-3.0.18.dist-info/METADATA,sha256=AMm6ABayGUspHQACK6bHjxDab0Y2BXbOJURg9nftB_Q,3690
2
+ longport-3.0.18.dist-info/WHEEL,sha256=JjSYyhcURteuw-i3RmBjP15_xTjVB0XHMAgHI62hRks,97
3
+ longport/__init__.py,sha256=w0BoFVpP8sPQKKt15KJCIXIE2KP7rL3VNg4ILWGWX7s,641
4
+ longport/longport.cp314-win_amd64.pyd,sha256=7aa5j_HE-l0Y13FRtRnJHr7aN-1TnToNZ9hXMzKnVM0,9906688
5
+ longport/openapi.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ longport/openapi.pyi,sha256=W6CtaenXNGgFWP9ikuhSNteejklnEf3Q9wL_fYqBq3c,102359
7
+ longport/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ longport-3.0.18.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-win_amd64