hubble-futures 0.2.13__py3-none-any.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.
- hubble_futures/__init__.py +151 -0
- hubble_futures/aster.py +601 -0
- hubble_futures/base.py +430 -0
- hubble_futures/config.py +34 -0
- hubble_futures/function_log.py +303 -0
- hubble_futures/version.py +8 -0
- hubble_futures/weex.py +1246 -0
- hubble_futures-0.2.13.dist-info/METADATA +217 -0
- hubble_futures-0.2.13.dist-info/RECORD +11 -0
- hubble_futures-0.2.13.dist-info/WHEEL +4 -0
- hubble_futures-0.2.13.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hubble-futures
|
|
3
|
+
Version: 0.2.13
|
|
4
|
+
Summary: Unified futures exchange client library for Hubble trading platform
|
|
5
|
+
Project-URL: Homepage, https://github.com/hubble-ecosystem/hubble-futures
|
|
6
|
+
Project-URL: Repository, https://github.com/hubble-ecosystem/hubble-futures
|
|
7
|
+
Project-URL: Documentation, https://github.com/hubble-ecosystem/hubble-futures/blob/main/README.md
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/hubble-ecosystem/hubble-futures/issues
|
|
9
|
+
Author-email: Hubble Team <dev@hubble.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,aster,binance,cryptocurrency,exchange,futures,trading,weex
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: loguru>=0.7.0
|
|
24
|
+
Requires-Dist: requests>=2.28.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-mock>=3.10; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: responses>=0.23.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: types-requests>=2.28.0; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# Hubble Futures
|
|
37
|
+
|
|
38
|
+
Unified futures exchange client library for Hubble trading platform.
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Unified Interface**: Single API for multiple exchanges
|
|
43
|
+
- **Exchange Support**: Aster DEX, WEEX (Binance, OKX coming soon)
|
|
44
|
+
- **Type Safe**: Full type hints and mypy strict mode
|
|
45
|
+
- **Adapter Pattern**: Exchange-specific differences handled internally
|
|
46
|
+
- **Retry Logic**: Automatic retry with exponential backoff for rate limits
|
|
47
|
+
- **Decimal Precision**: Proper decimal formatting for all exchanges
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install hubble-futures
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from hubble_futures import create_client, ExchangeConfig
|
|
59
|
+
|
|
60
|
+
# Create exchange configuration
|
|
61
|
+
config = ExchangeConfig(
|
|
62
|
+
name="asterdex",
|
|
63
|
+
api_key="your_api_key",
|
|
64
|
+
api_secret="your_api_secret"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Create client
|
|
68
|
+
client = create_client(config)
|
|
69
|
+
|
|
70
|
+
# Fetch market data
|
|
71
|
+
klines = client.get_klines("BTCUSDT", "1h", 200)
|
|
72
|
+
account = client.get_account()
|
|
73
|
+
positions = client.get_positions()
|
|
74
|
+
|
|
75
|
+
# Place order
|
|
76
|
+
order = client.place_order(
|
|
77
|
+
symbol="BTCUSDT",
|
|
78
|
+
side="BUY",
|
|
79
|
+
order_type="LIMIT",
|
|
80
|
+
quantity=0.01,
|
|
81
|
+
price=50000
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Supported Exchanges
|
|
86
|
+
|
|
87
|
+
| Exchange | Name | Passphrase Required |
|
|
88
|
+
|----------|------|---------------------|
|
|
89
|
+
| Aster DEX | `asterdex` or `aster` | No |
|
|
90
|
+
| WEEX | `weex` | Yes |
|
|
91
|
+
|
|
92
|
+
### WEEX Configuration
|
|
93
|
+
|
|
94
|
+
WEEX requires an additional `passphrase` parameter:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
config = ExchangeConfig(
|
|
98
|
+
name="weex",
|
|
99
|
+
api_key="your_api_key",
|
|
100
|
+
api_secret="your_api_secret",
|
|
101
|
+
passphrase="your_passphrase" # Required for WEEX
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## API Reference
|
|
106
|
+
|
|
107
|
+
### Market Data
|
|
108
|
+
|
|
109
|
+
- `get_klines(symbol, interval, limit)` - Fetch candlestick data
|
|
110
|
+
- `get_mark_price(symbol)` - Fetch mark price and funding rate
|
|
111
|
+
- `get_depth(symbol, limit)` - Fetch orderbook
|
|
112
|
+
- `get_ticker_24hr(symbol)` - Fetch 24h statistics
|
|
113
|
+
- `get_exchange_info()` - Fetch exchange metadata
|
|
114
|
+
- `get_symbol_filters(symbol)` - Fetch trading rules
|
|
115
|
+
|
|
116
|
+
### Account & Trading
|
|
117
|
+
|
|
118
|
+
- `get_account()` - Fetch account information
|
|
119
|
+
- `get_positions(symbol)` - Fetch open positions
|
|
120
|
+
- `get_balance()` - Fetch balance summary
|
|
121
|
+
- `place_order(...)` - Place an order
|
|
122
|
+
- `cancel_order(symbol, order_id)` - Cancel an order
|
|
123
|
+
- `get_open_orders(symbol)` - Get open orders
|
|
124
|
+
- `set_leverage(symbol, leverage)` - Set leverage
|
|
125
|
+
- `close_position(symbol, percent)` - Close position
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
### Setup
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Clone repository
|
|
133
|
+
git clone https://github.com/hubble/hubble-futures.git
|
|
134
|
+
cd hubble-futures
|
|
135
|
+
|
|
136
|
+
# Install dependencies
|
|
137
|
+
pip install -e ".[dev]"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Running Tests
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Unit tests
|
|
144
|
+
pytest tests/unit -m unit
|
|
145
|
+
|
|
146
|
+
# Integration tests (mocked API)
|
|
147
|
+
pytest tests/integration -m integration
|
|
148
|
+
|
|
149
|
+
# E2E tests (requires .env with API credentials)
|
|
150
|
+
pytest tests/e2e -m e2e
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Code Quality
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Format check
|
|
157
|
+
ruff check hubble_futures tests
|
|
158
|
+
|
|
159
|
+
# Type check
|
|
160
|
+
mypy hubble_futures
|
|
161
|
+
|
|
162
|
+
# Coverage
|
|
163
|
+
pytest --cov=hubble_futures --cov-report=html
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Architecture
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
┌─────────────────────────────────────────────┐
|
|
170
|
+
│ User Code │
|
|
171
|
+
│ (Agent, Trading Bot, etc.) │
|
|
172
|
+
└─────────────────────────────────────────────┘
|
|
173
|
+
↓ uses
|
|
174
|
+
┌─────────────────────────────────────────────┐
|
|
175
|
+
│ Factory: create_client(config) │
|
|
176
|
+
└─────────────────────────────────────────────┘
|
|
177
|
+
↓ creates
|
|
178
|
+
┌─────────────────────────────────────────────┐
|
|
179
|
+
│ BaseFuturesClient (Abstract) │
|
|
180
|
+
│ - Unified interface │
|
|
181
|
+
│ - Common retry logic │
|
|
182
|
+
│ - Decimal formatting │
|
|
183
|
+
└─────────────────────────────────────────────┘
|
|
184
|
+
↓ implemented by
|
|
185
|
+
┌─────────────┬─────────────┬─────────────────┐
|
|
186
|
+
│ Aster │ WEEX │ Future │
|
|
187
|
+
│ Adapter │ Adapter │ Adapters │
|
|
188
|
+
│ │ │ (Binance, OKX) │
|
|
189
|
+
└─────────────┴─────────────┴─────────────────┘
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Adapter Responsibilities
|
|
193
|
+
|
|
194
|
+
Each exchange adapter handles:
|
|
195
|
+
- API authentication (different signing methods)
|
|
196
|
+
- Symbol format conversion (e.g., `BTCUSDT` ↔ `cmt_btcusdt`)
|
|
197
|
+
- Parameter mapping (e.g., `side` ↔ `type`)
|
|
198
|
+
- Response normalization (unified return format)
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT License - see [LICENSE](LICENSE) for details
|
|
203
|
+
|
|
204
|
+
## Contributing
|
|
205
|
+
|
|
206
|
+
Contributions are welcome! Please:
|
|
207
|
+
1. Fork the repository
|
|
208
|
+
2. Create a feature branch
|
|
209
|
+
3. Add tests for new features
|
|
210
|
+
4. Ensure all tests pass (`pytest`)
|
|
211
|
+
5. Submit a pull request
|
|
212
|
+
|
|
213
|
+
## Support
|
|
214
|
+
|
|
215
|
+
For issues and questions:
|
|
216
|
+
- GitHub Issues: https://github.com/hubble/hubble-futures/issues
|
|
217
|
+
- Documentation: https://docs.hubble.com/futures-client
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
hubble_futures/__init__.py,sha256=u3TDlDj1Khttkfwc_ytuv6SJyzNFYMPKv3uQH24S1ck,4334
|
|
2
|
+
hubble_futures/aster.py,sha256=QO0aJaFZGDrK22WzSyrl6iebGNk-nx2N6E-Loo-7pmA,22549
|
|
3
|
+
hubble_futures/base.py,sha256=K_ZvopbKzEmrtxjimc83cBVVhNyTtg9--KmupTG9Eqo,15365
|
|
4
|
+
hubble_futures/config.py,sha256=yt09OBKhCNjqOTAQl_csOAL32HfpsFUAmDkhSYAxNgE,944
|
|
5
|
+
hubble_futures/function_log.py,sha256=7Bc7naU_vwR84DyBL4lER8kC-HfRPeGWBPxQvnWBF80,9826
|
|
6
|
+
hubble_futures/version.py,sha256=MnhAN1VBJNAwq5OsAtryg4nVIuz-bFXTGb_dYhAVDpU,222
|
|
7
|
+
hubble_futures/weex.py,sha256=4T1P4wUDRJTfccGttO0WNjYTBfbnHI9ISR-JISEZRCg,49429
|
|
8
|
+
hubble_futures-0.2.13.dist-info/METADATA,sha256=MjwVWnMXU3MIs2Rl7MWbBM6I0xTJmZoG7CCzgC8Q9M8,6945
|
|
9
|
+
hubble_futures-0.2.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
hubble_futures-0.2.13.dist-info/licenses/LICENSE,sha256=gfURDQ-cSA67QqAYRnns4svB6qj1dAA5PrJdW9JGGRM,1068
|
|
11
|
+
hubble_futures-0.2.13.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hubble Team
|
|
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.
|