dcex 0.3.0__tar.gz
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.
- dcex-0.3.0/LICENSE +21 -0
- dcex-0.3.0/PKG-INFO +173 -0
- dcex-0.3.0/README.md +154 -0
- dcex-0.3.0/dcex/__init__.py +59 -0
- dcex-0.3.0/dcex/async_support/__init__.py +113 -0
- dcex-0.3.0/dcex/async_support/okx/__init__.py +3 -0
- dcex-0.3.0/dcex/async_support/okx/_account_http.py +827 -0
- dcex-0.3.0/dcex/async_support/okx/_asset_http.py +531 -0
- dcex-0.3.0/dcex/async_support/okx/_http_manager.py +253 -0
- dcex-0.3.0/dcex/async_support/okx/_market_http.py +143 -0
- dcex-0.3.0/dcex/async_support/okx/_public_http.py +151 -0
- dcex-0.3.0/dcex/async_support/okx/_trade_http.py +1014 -0
- dcex-0.3.0/dcex/async_support/okx/client.py +54 -0
- dcex-0.3.0/dcex/async_support/okx/endpoints/account.py +34 -0
- dcex-0.3.0/dcex/async_support/okx/endpoints/asset.py +27 -0
- dcex-0.3.0/dcex/async_support/okx/endpoints/market.py +15 -0
- dcex-0.3.0/dcex/async_support/okx/endpoints/public.py +15 -0
- dcex-0.3.0/dcex/async_support/okx/endpoints/trade.py +25 -0
- dcex-0.3.0/dcex/async_support/product_table/fetch.py +944 -0
- dcex-0.3.0/dcex/async_support/product_table/manager.py +556 -0
- dcex-0.3.0/dcex/okx/__init__.py +3 -0
- dcex-0.3.0/dcex/okx/_account_http.py +825 -0
- dcex-0.3.0/dcex/okx/_asset_http.py +526 -0
- dcex-0.3.0/dcex/okx/_http_manager.py +251 -0
- dcex-0.3.0/dcex/okx/_market_http.py +139 -0
- dcex-0.3.0/dcex/okx/_public_http.py +106 -0
- dcex-0.3.0/dcex/okx/_trade_http.py +995 -0
- dcex-0.3.0/dcex/okx/client.py +66 -0
- dcex-0.3.0/dcex/okx/endpoints/account.py +49 -0
- dcex-0.3.0/dcex/okx/endpoints/asset.py +42 -0
- dcex-0.3.0/dcex/okx/endpoints/market.py +28 -0
- dcex-0.3.0/dcex/okx/endpoints/public.py +27 -0
- dcex-0.3.0/dcex/okx/endpoints/trade.py +40 -0
- dcex-0.3.0/dcex/product_table/fetch.py +560 -0
- dcex-0.3.0/dcex/product_table/manager.py +482 -0
- dcex-0.3.0/dcex/utils/address_utils.py +14 -0
- dcex-0.3.0/dcex/utils/common.py +22 -0
- dcex-0.3.0/dcex/utils/common_dataframe.py +35 -0
- dcex-0.3.0/dcex/utils/decimal_utils.py +15 -0
- dcex-0.3.0/dcex/utils/errors.py +74 -0
- dcex-0.3.0/dcex/utils/helpers.py +88 -0
- dcex-0.3.0/dcex/utils/jupyter_helper.py +105 -0
- dcex-0.3.0/dcex/utils/timeframe_utils.py +126 -0
- dcex-0.3.0/dcex.egg-info/PKG-INFO +173 -0
- dcex-0.3.0/dcex.egg-info/SOURCES.txt +48 -0
- dcex-0.3.0/dcex.egg-info/dependency_links.txt +1 -0
- dcex-0.3.0/dcex.egg-info/requires.txt +4 -0
- dcex-0.3.0/dcex.egg-info/top_level.txt +1 -0
- dcex-0.3.0/pyproject.toml +162 -0
- dcex-0.3.0/setup.cfg +4 -0
dcex-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sam Hong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
dcex-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dcex
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: A Lightweight Python Package for Low-Latency and Cross-Exchange Trading.
|
|
5
|
+
Author: Sam Hong
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/pg56714/dcex
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: httpx>=0.28.1
|
|
15
|
+
Requires-Dist: polars>=1.34.0
|
|
16
|
+
Requires-Dist: requests>=2.32.5
|
|
17
|
+
Requires-Dist: msgspec>=0.19.0
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# dcex - dex & cex trading library
|
|
21
|
+
|
|
22
|
+
**Important**: No default broker tags are set. You may manually specify a broker tag within function arguments if needed.
|
|
23
|
+
|
|
24
|
+
> Forked from [krex](https://github.com/kairosresearchio/krex), a simplified version of the [ccxt](https://github.com/ccxt/ccxt) Python library.
|
|
25
|
+
|
|
26
|
+
> Originally created and maintained by the same contributor, this fork continues active development, building upon the original foundation with enhanced design, unified DEX + CEX support, and fixes for previously unresolved issues.
|
|
27
|
+
|
|
28
|
+
A high-performance and lightweight Python library for interacting with cryptocurrency exchanges. dcex offers full synchronous and asynchronous support across major exchanges, designed for speed, modularity, and ease of use.
|
|
29
|
+
|
|
30
|
+
[](https://python.org)
|
|
31
|
+
[](https://opensource.org/licenses/MIT)
|
|
32
|
+
[](https://badge.fury.io/py/dcex)
|
|
33
|
+
|
|
34
|
+
## 📦 Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install dcex
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
or use `uv` to manage the project:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv add dcex
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 🚀 Quick Start
|
|
47
|
+
|
|
48
|
+
### Synchronous Usage
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import dcex
|
|
52
|
+
import os
|
|
53
|
+
|
|
54
|
+
# Initialize client for any supported exchange
|
|
55
|
+
client = dcex.binance(
|
|
56
|
+
api_key="your_api_key",
|
|
57
|
+
api_secret="your_api_secret"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Get market data
|
|
61
|
+
klines = client.get_klines(product_symbol="BTCUSDT", interval="1h")
|
|
62
|
+
print(klines)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Asynchronous Usage
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import asyncio
|
|
69
|
+
import dcex.async_support as dcex
|
|
70
|
+
import os
|
|
71
|
+
|
|
72
|
+
async def main():
|
|
73
|
+
# Initialize async client
|
|
74
|
+
client = await dcex.binance(
|
|
75
|
+
api_key="your_api_key",
|
|
76
|
+
api_secret="your_api_secret"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
# Get market data
|
|
81
|
+
klines = await client.get_klines(product_symbol="BTCUSDT", interval="1h")
|
|
82
|
+
print(klines)
|
|
83
|
+
|
|
84
|
+
finally:
|
|
85
|
+
await client.close()
|
|
86
|
+
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
asyncio.run(main())
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 📚 Supported Exchanges
|
|
92
|
+
|
|
93
|
+
| Exchange | Sync Support | Async Support |
|
|
94
|
+
| --------------- | ------------ | ------------- |
|
|
95
|
+
| **Binance** | Testing | Testing |
|
|
96
|
+
| **Bybit** | Testing | Testing |
|
|
97
|
+
| **OKX** | ✅ | ✅ |
|
|
98
|
+
| **BitMart** | Testing | Testing |
|
|
99
|
+
| **Gate.io** | Testing | Testing |
|
|
100
|
+
| **Hyperliquid** | Testing | Testing |
|
|
101
|
+
| **BitMEX** | Testing | Testing |
|
|
102
|
+
| **BingX** | Developing | Developing |
|
|
103
|
+
| **AscendEX** | Developing | Developing |
|
|
104
|
+
| **KuCoin** | Developing | Developing |
|
|
105
|
+
|
|
106
|
+
## 🔍 Key Features
|
|
107
|
+
|
|
108
|
+
- 📘 Product Table Manager for unifying trading instruments in different exchanges
|
|
109
|
+
- 🔁 Sync & Async API clients with identical interfaces
|
|
110
|
+
- ⚡ Optimized for low-latency, high-frequency trading
|
|
111
|
+
|
|
112
|
+
## What is Product Table Manager(ptm)?
|
|
113
|
+
|
|
114
|
+
Ptm is a utility that standardizes and unifies trading instrument metadata across different exchanges, making cross-exchange strategy development easier.
|
|
115
|
+
|
|
116
|
+
It is a table that contains the following columns:
|
|
117
|
+
|
|
118
|
+
| Column | Description |
|
|
119
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| exchange | The exchange name |
|
|
121
|
+
| product_symbol | The symbol we use to identify the product, it will be the same in different exchanges. For example, `BTC-USDT-SWAP` is the same product in Binance and Bybit, which named `BTCUSDT` in Binance and `BTC-USDT-SWAP` in OKX. |
|
|
122
|
+
| exchange_symbol | The symbol that the exchange will actually used |
|
|
123
|
+
| product_type | The type we will use, e.g. `spot`, `inverse`, `swap`, `futures` |
|
|
124
|
+
| exchange_type | The type the exchange will actually used, e.g. `linear`, `INVERSE`, `perp`... different exchanges have different types, pretty annoying... |
|
|
125
|
+
| base_symbol | The base symbol, e.g. `BTC` |
|
|
126
|
+
| quote_symbol | The quote symbol, e.g. `USDT` |
|
|
127
|
+
| price_precision | The price precision, e.g. `0.000001` |
|
|
128
|
+
| size_precision | The size precision, e.g. `0.000001` |
|
|
129
|
+
| min_size | The minimum size, e.g. `0.000001` |
|
|
130
|
+
| min_notional | The minimum notional, e.g. `0.000001` |
|
|
131
|
+
| multiplier | The multiplier of the product, such symbol like `1000BONKUSDT` in Bybit will need to be multiplied by 1000 to get the actual size, if you are trading across spot and swap, you will need this |
|
|
132
|
+
| size_per_contract | The size per contract. Sometimes 1 contract is not the same as 1 unit in exchanges like OKX. |
|
|
133
|
+
|
|
134
|
+
## How to use Product Table Manager?
|
|
135
|
+
|
|
136
|
+
In most cases, we have handled the case, but if you have any specific use cases, you can use the `ptm` to get the information you want.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
import dcex
|
|
140
|
+
|
|
141
|
+
bn = dcex.binance()
|
|
142
|
+
|
|
143
|
+
product_symbol = bn.ptm.get_product_symbol(
|
|
144
|
+
exchange="binance",
|
|
145
|
+
exchange_symbol="BTCUSDT",
|
|
146
|
+
product_type="swap",
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
print(product_symbol)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 🤝 Contributing
|
|
153
|
+
|
|
154
|
+
We welcome contributions! Please see our [Contributing Guide](.github/CONTRIBUTING.md) for details.
|
|
155
|
+
|
|
156
|
+
### Contributors
|
|
157
|
+
|
|
158
|
+
<a href="https://github.com/pg56714/dcex/graphs/contributors">
|
|
159
|
+
<img src="https://contrib.rocks/image?repo=pg56714/dcex" />
|
|
160
|
+
</a>
|
|
161
|
+
|
|
162
|
+
## 📄 License
|
|
163
|
+
|
|
164
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
165
|
+
|
|
166
|
+
## 🆘 Support
|
|
167
|
+
|
|
168
|
+
- **Issues**: Report bugs and request features on [GitHub Issues](https://github.com/pg56714/dcex/issues).
|
|
169
|
+
- **Discussions**: Discuss ideas and share your thoughts on [GitHub Discussions](https://github.com/pg56714/dcex/discussions).
|
|
170
|
+
|
|
171
|
+
## 📜 Disclaimer
|
|
172
|
+
|
|
173
|
+
Cryptocurrency trading involves significant risk. This library is provided as-is without any warranty. Users are responsible for their own trading decisions and risk management.
|
dcex-0.3.0/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# dcex - dex & cex trading library
|
|
2
|
+
|
|
3
|
+
**Important**: No default broker tags are set. You may manually specify a broker tag within function arguments if needed.
|
|
4
|
+
|
|
5
|
+
> Forked from [krex](https://github.com/kairosresearchio/krex), a simplified version of the [ccxt](https://github.com/ccxt/ccxt) Python library.
|
|
6
|
+
|
|
7
|
+
> Originally created and maintained by the same contributor, this fork continues active development, building upon the original foundation with enhanced design, unified DEX + CEX support, and fixes for previously unresolved issues.
|
|
8
|
+
|
|
9
|
+
A high-performance and lightweight Python library for interacting with cryptocurrency exchanges. dcex offers full synchronous and asynchronous support across major exchanges, designed for speed, modularity, and ease of use.
|
|
10
|
+
|
|
11
|
+
[](https://python.org)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
[](https://badge.fury.io/py/dcex)
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install dcex
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or use `uv` to manage the project:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uv add dcex
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 🚀 Quick Start
|
|
28
|
+
|
|
29
|
+
### Synchronous Usage
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import dcex
|
|
33
|
+
import os
|
|
34
|
+
|
|
35
|
+
# Initialize client for any supported exchange
|
|
36
|
+
client = dcex.binance(
|
|
37
|
+
api_key="your_api_key",
|
|
38
|
+
api_secret="your_api_secret"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Get market data
|
|
42
|
+
klines = client.get_klines(product_symbol="BTCUSDT", interval="1h")
|
|
43
|
+
print(klines)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Asynchronous Usage
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import asyncio
|
|
50
|
+
import dcex.async_support as dcex
|
|
51
|
+
import os
|
|
52
|
+
|
|
53
|
+
async def main():
|
|
54
|
+
# Initialize async client
|
|
55
|
+
client = await dcex.binance(
|
|
56
|
+
api_key="your_api_key",
|
|
57
|
+
api_secret="your_api_secret"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
# Get market data
|
|
62
|
+
klines = await client.get_klines(product_symbol="BTCUSDT", interval="1h")
|
|
63
|
+
print(klines)
|
|
64
|
+
|
|
65
|
+
finally:
|
|
66
|
+
await client.close()
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
asyncio.run(main())
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 📚 Supported Exchanges
|
|
73
|
+
|
|
74
|
+
| Exchange | Sync Support | Async Support |
|
|
75
|
+
| --------------- | ------------ | ------------- |
|
|
76
|
+
| **Binance** | Testing | Testing |
|
|
77
|
+
| **Bybit** | Testing | Testing |
|
|
78
|
+
| **OKX** | ✅ | ✅ |
|
|
79
|
+
| **BitMart** | Testing | Testing |
|
|
80
|
+
| **Gate.io** | Testing | Testing |
|
|
81
|
+
| **Hyperliquid** | Testing | Testing |
|
|
82
|
+
| **BitMEX** | Testing | Testing |
|
|
83
|
+
| **BingX** | Developing | Developing |
|
|
84
|
+
| **AscendEX** | Developing | Developing |
|
|
85
|
+
| **KuCoin** | Developing | Developing |
|
|
86
|
+
|
|
87
|
+
## 🔍 Key Features
|
|
88
|
+
|
|
89
|
+
- 📘 Product Table Manager for unifying trading instruments in different exchanges
|
|
90
|
+
- 🔁 Sync & Async API clients with identical interfaces
|
|
91
|
+
- ⚡ Optimized for low-latency, high-frequency trading
|
|
92
|
+
|
|
93
|
+
## What is Product Table Manager(ptm)?
|
|
94
|
+
|
|
95
|
+
Ptm is a utility that standardizes and unifies trading instrument metadata across different exchanges, making cross-exchange strategy development easier.
|
|
96
|
+
|
|
97
|
+
It is a table that contains the following columns:
|
|
98
|
+
|
|
99
|
+
| Column | Description |
|
|
100
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| exchange | The exchange name |
|
|
102
|
+
| product_symbol | The symbol we use to identify the product, it will be the same in different exchanges. For example, `BTC-USDT-SWAP` is the same product in Binance and Bybit, which named `BTCUSDT` in Binance and `BTC-USDT-SWAP` in OKX. |
|
|
103
|
+
| exchange_symbol | The symbol that the exchange will actually used |
|
|
104
|
+
| product_type | The type we will use, e.g. `spot`, `inverse`, `swap`, `futures` |
|
|
105
|
+
| exchange_type | The type the exchange will actually used, e.g. `linear`, `INVERSE`, `perp`... different exchanges have different types, pretty annoying... |
|
|
106
|
+
| base_symbol | The base symbol, e.g. `BTC` |
|
|
107
|
+
| quote_symbol | The quote symbol, e.g. `USDT` |
|
|
108
|
+
| price_precision | The price precision, e.g. `0.000001` |
|
|
109
|
+
| size_precision | The size precision, e.g. `0.000001` |
|
|
110
|
+
| min_size | The minimum size, e.g. `0.000001` |
|
|
111
|
+
| min_notional | The minimum notional, e.g. `0.000001` |
|
|
112
|
+
| multiplier | The multiplier of the product, such symbol like `1000BONKUSDT` in Bybit will need to be multiplied by 1000 to get the actual size, if you are trading across spot and swap, you will need this |
|
|
113
|
+
| size_per_contract | The size per contract. Sometimes 1 contract is not the same as 1 unit in exchanges like OKX. |
|
|
114
|
+
|
|
115
|
+
## How to use Product Table Manager?
|
|
116
|
+
|
|
117
|
+
In most cases, we have handled the case, but if you have any specific use cases, you can use the `ptm` to get the information you want.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
import dcex
|
|
121
|
+
|
|
122
|
+
bn = dcex.binance()
|
|
123
|
+
|
|
124
|
+
product_symbol = bn.ptm.get_product_symbol(
|
|
125
|
+
exchange="binance",
|
|
126
|
+
exchange_symbol="BTCUSDT",
|
|
127
|
+
product_type="swap",
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
print(product_symbol)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 🤝 Contributing
|
|
134
|
+
|
|
135
|
+
We welcome contributions! Please see our [Contributing Guide](.github/CONTRIBUTING.md) for details.
|
|
136
|
+
|
|
137
|
+
### Contributors
|
|
138
|
+
|
|
139
|
+
<a href="https://github.com/pg56714/dcex/graphs/contributors">
|
|
140
|
+
<img src="https://contrib.rocks/image?repo=pg56714/dcex" />
|
|
141
|
+
</a>
|
|
142
|
+
|
|
143
|
+
## 📄 License
|
|
144
|
+
|
|
145
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
146
|
+
|
|
147
|
+
## 🆘 Support
|
|
148
|
+
|
|
149
|
+
- **Issues**: Report bugs and request features on [GitHub Issues](https://github.com/pg56714/dcex/issues).
|
|
150
|
+
- **Discussions**: Discuss ideas and share your thoughts on [GitHub Discussions](https://github.com/pg56714/dcex/discussions).
|
|
151
|
+
|
|
152
|
+
## 📜 Disclaimer
|
|
153
|
+
|
|
154
|
+
Cryptocurrency trading involves significant risk. This library is provided as-is without any warranty. Users are responsible for their own trading decisions and risk management.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
dcex - dex & cex trading library.
|
|
3
|
+
|
|
4
|
+
A comprehensive library for cryptocurrency exchange interactions with both sync and async support.
|
|
5
|
+
Automatically handles Jupyter Notebook compatibility with nest_asyncio.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from .binance.client import Client as BinanceClient
|
|
11
|
+
from .bitmart.client import Client as BitmartClient
|
|
12
|
+
from .bitmex.client import Client as BitmexClient
|
|
13
|
+
from .bybit.client import Client as BybitClient
|
|
14
|
+
from .gateio.client import Client as GateioClient
|
|
15
|
+
from .okx.client import Client as OKXClient
|
|
16
|
+
from .utils.jupyter_helper import auto_apply_nest_asyncio
|
|
17
|
+
|
|
18
|
+
auto_apply_nest_asyncio(verbose=False)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Create callable functions for each exchange (synchronous clients)
|
|
22
|
+
def binance(**kwargs: Any) -> BinanceClient: # noqa: ANN401
|
|
23
|
+
"""Create a Binance client instance."""
|
|
24
|
+
return BinanceClient(**kwargs)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def bitmart(**kwargs: Any) -> BitmartClient: # noqa: ANN401
|
|
28
|
+
"""Create a BitMart client instance."""
|
|
29
|
+
return BitmartClient(**kwargs)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def bitmex(**kwargs: Any) -> BitmexClient: # noqa: ANN401
|
|
33
|
+
"""Create a BitMEX client instance."""
|
|
34
|
+
return BitmexClient(**kwargs)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def bybit(**kwargs: Any) -> BybitClient: # noqa: ANN401
|
|
38
|
+
"""Create a Bybit client instance."""
|
|
39
|
+
return BybitClient(**kwargs)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def gateio(**kwargs: Any) -> GateioClient: # noqa: ANN401
|
|
43
|
+
"""Create a Gate.io client instance."""
|
|
44
|
+
return GateioClient(**kwargs)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def okx(**kwargs: Any) -> OKXClient: # noqa: ANN401
|
|
48
|
+
"""Create an OKX client instance."""
|
|
49
|
+
return OKXClient(**kwargs)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
__all__ = [
|
|
53
|
+
"binance",
|
|
54
|
+
"bitmart",
|
|
55
|
+
"bitmex",
|
|
56
|
+
"bybit",
|
|
57
|
+
"gateio",
|
|
58
|
+
"okx",
|
|
59
|
+
]
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Async exchange entry points.
|
|
3
|
+
|
|
4
|
+
This module exposes coroutine factory functions for each supported exchange,
|
|
5
|
+
which return an initialized async client (after awaiting `async_init`).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Import exchange client classes and create callable functions
|
|
9
|
+
from typing import Any, cast
|
|
10
|
+
|
|
11
|
+
from .ascendex.client import Client as AscendexClient
|
|
12
|
+
from .binance.client import Client as BinanceClient
|
|
13
|
+
from .bingx.client import Client as BingXClient
|
|
14
|
+
from .bitmart.client import Client as BitmartClient
|
|
15
|
+
from .bitmex.client import Client as BitmexClient
|
|
16
|
+
from .bybit.client import Client as BybitClient
|
|
17
|
+
from .gateio.client import Client as GateioClient
|
|
18
|
+
from .hyperliquid.client import Client as HyperliquidClient
|
|
19
|
+
from .kucoin.client import Client as KuCoinClient
|
|
20
|
+
from .okx.client import Client as OKXClient
|
|
21
|
+
from .zoomex.client import Client as ZoomexClient
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def ascendex(
|
|
25
|
+
**kwargs: Any, # noqa: ANN401
|
|
26
|
+
) -> AscendexClient:
|
|
27
|
+
"""Create and initialize an AscendEX client instance."""
|
|
28
|
+
return cast(AscendexClient, await AscendexClient(**kwargs).async_init())
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def binance(
|
|
32
|
+
**kwargs: Any, # noqa: ANN401
|
|
33
|
+
) -> BinanceClient:
|
|
34
|
+
"""Create and initialize a Binance client instance."""
|
|
35
|
+
return cast(BinanceClient, await BinanceClient(**kwargs).async_init())
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
async def bingx(
|
|
39
|
+
**kwargs: Any, # noqa: ANN401
|
|
40
|
+
) -> BingXClient:
|
|
41
|
+
"""Create and initialize a BingX client instance."""
|
|
42
|
+
return cast(BingXClient, await BingXClient(**kwargs).async_init())
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def bitmart(
|
|
46
|
+
**kwargs: Any, # noqa: ANN401
|
|
47
|
+
) -> BitmartClient:
|
|
48
|
+
"""Create and initialize a BitMart client instance."""
|
|
49
|
+
return cast(BitmartClient, await BitmartClient(**kwargs).async_init())
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def bitmex(
|
|
53
|
+
**kwargs: Any, # noqa: ANN401
|
|
54
|
+
) -> BitmexClient:
|
|
55
|
+
"""Create and initialize a BitMEX client instance."""
|
|
56
|
+
return cast(BitmexClient, await BitmexClient(**kwargs).async_init())
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
async def bybit(
|
|
60
|
+
**kwargs: Any, # noqa: ANN401
|
|
61
|
+
) -> BybitClient:
|
|
62
|
+
"""Create and initialize a Bybit client instance."""
|
|
63
|
+
return cast(BybitClient, await BybitClient(**kwargs).async_init())
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
async def gateio(
|
|
67
|
+
**kwargs: Any, # noqa: ANN401
|
|
68
|
+
) -> GateioClient:
|
|
69
|
+
"""Create and initialize a Gate.io client instance."""
|
|
70
|
+
return cast(GateioClient, await GateioClient(**kwargs).async_init())
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
async def hyperliquid(
|
|
74
|
+
**kwargs: Any, # noqa: ANN401
|
|
75
|
+
) -> HyperliquidClient:
|
|
76
|
+
"""Create and initialize a Hyperliquid client instance."""
|
|
77
|
+
return cast(HyperliquidClient, await HyperliquidClient(**kwargs).async_init())
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def kucoin(
|
|
81
|
+
**kwargs: Any, # noqa: ANN401
|
|
82
|
+
) -> KuCoinClient:
|
|
83
|
+
"""Create and initialize a KuCoin client instance."""
|
|
84
|
+
return cast(KuCoinClient, await KuCoinClient(**kwargs).async_init())
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
async def okx(
|
|
88
|
+
**kwargs: Any, # noqa: ANN401
|
|
89
|
+
) -> OKXClient:
|
|
90
|
+
"""Create and initialize an OKX client instance."""
|
|
91
|
+
return cast(OKXClient, await OKXClient(**kwargs).async_init())
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async def zoomex(
|
|
95
|
+
**kwargs: Any, # noqa: ANN401
|
|
96
|
+
) -> ZoomexClient:
|
|
97
|
+
"""Create and initialize a Zoomex client instance."""
|
|
98
|
+
return cast(ZoomexClient, await ZoomexClient(**kwargs).async_init())
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
__all__ = [
|
|
102
|
+
"ascendex",
|
|
103
|
+
"binance",
|
|
104
|
+
"bingx",
|
|
105
|
+
"bitmart",
|
|
106
|
+
"bitmex",
|
|
107
|
+
"bybit",
|
|
108
|
+
"gateio",
|
|
109
|
+
"hyperliquid",
|
|
110
|
+
"kucoin",
|
|
111
|
+
"okx",
|
|
112
|
+
"zoomex",
|
|
113
|
+
]
|