qfex2 1.0.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.
qfex2-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Coin Data School
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.
qfex2-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: qfex2
3
+ Version: 1.0.0
4
+ Summary: Python SDK for the QFEX API
5
+ License: MIT
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: requests>=2.34.2
10
+ Requires-Dist: websockets>=16.1
11
+ Dynamic: license-file
12
+
13
+ # qfex2
14
+
15
+ A Python SDK for the [QFEX](https://docs.qfex.com/api-reference/introduction) API. The `examples/bot_supervisor.py`
16
+ is a pure market making bot that you can run out of the box or with customization.
17
+ By default, it continuously quotes both a buy (bid) and a sell (ask) price for
18
+ US500 around a mid-price, aiming to capture the bid–ask spread without taking a
19
+ directional bet.
20
+
21
+ ![Python Version](https://img.shields.io/badge/python-3.12%2B-blue)
22
+ ![License](https://img.shields.io/badge/license-MIT-green)
23
+
24
+ ## Disclaimers
25
+
26
+ This package is written by AI and backtested under my supervision. After two
27
+ months of tinkering, I'm releasing it as version 1.0.0. The `examples/bot_supervisor.py`
28
+ contains the settings I currently use, so if you just want to passively farming
29
+ QFEX points on autopilot, you can just run:
30
+
31
+ ```bash
32
+ caffeinate -i .venv/bin/python examples/bot_supervisor.py
33
+ ```
34
+
35
+ Of course, you will need to create an account at QFEX first. You can do that with
36
+ my referral [https://qfex.com/@re83f92f](https://qfex.com/@re83f92f) to save
37
+ 10%+ on trading fees.
38
+
39
+ ## Installation
40
+
41
+ Install via pip:
42
+
43
+ ```bash
44
+ pip install qfex2
45
+ ```
46
+
47
+ Or from source:
48
+
49
+ ```bash
50
+ git clone https://github.com/coindataschool/qfex-py.git
51
+ cd qfex-py
52
+ pip install .
53
+ ```
54
+
55
+ ## Quick Start
56
+
57
+ Create an account at [QFEX](https://qfex.com/@re83f92f) and deposit \$50~\$200.
58
+ (You can deposit more later after you feel comfortable with the bot.)
59
+
60
+ Get your QFEX API keys. See [instruction](https://docs.qfex.com/api-reference/introduction).
61
+
62
+ Store your keys in env vars by adding the following lines to the right startup
63
+ file (`~/.zprofile`, `~/.profile`, `~/.zshrc`, `~/.bashrc`) for your shell:
64
+
65
+ ```bash
66
+ export QFEX_PUBLIC_KEY="your_public_key"
67
+ export QFEX_SECRET_KEY="your_secret_key"
68
+ ```
69
+
70
+ Run pure market making bots:
71
+
72
+ ```bash
73
+ caffeinate -i .venv/bin/python examples/bot_supervisor.py
74
+ ```
75
+
76
+ `examples/bot_supervisor.py` runs one bot at a time on a daily schedule, with
77
+ pauses around news releases, the US stock-market open and weekends. All of its
78
+ times are in UTC by default (`TIMEZONE = "UTC"`). To use your own timezone, set
79
+ `TIMEZONE` to an IANA name such as `"Europe/London"` and convert the schedule,
80
+ blackouts, weekend pause and week start to it. The shipped schedule, sizes and
81
+ blackout dates are the author's own settings for late 2026 — review and replace
82
+ them before running with real money. (`caffeinate` keeps a Mac awake; on Linux
83
+ just run `python examples/bot_supervisor.py`.)
84
+
85
+ ## Build Your Own Bots
86
+
87
+ The `examples/` folder contains several other scripts, each implementing a simple
88
+ strategy. These scripts are meant to demonstrate the features of the `qfex2`
89
+ package, and are not necessarily good trading strategies. You can use them as
90
+ starting points to build your own bots.
91
+
92
+ Run simple maker stratey to place GTC Add Liquidity Orders:
93
+
94
+ ```bash
95
+ python examples/simple_maker.py \
96
+ --is-prod \
97
+ --symbol CRCL-USD \
98
+ --quantity 0.1 \
99
+ --leverage 3 \
100
+ --log-level INFO \
101
+ --log-file logs/maker.log
102
+ ```
103
+
104
+ Run simple taker stratey to place MARKET orders:
105
+
106
+ ```bash
107
+ python examples/simple_taker_market.py \
108
+ --is-prod \
109
+ --symbol CRCL-USD \
110
+ --side BUY \
111
+ --quantity 0.1 \
112
+ --leverage 3 \
113
+ --log-level INFO \
114
+ --log-file logs/taker.log
115
+ ```
116
+
117
+ Run simple taker stratey to place IOC LIMIT orders:
118
+
119
+ ```bash
120
+ python examples/simple_taker_limit_ioc.py \
121
+ --is-prod \
122
+ --symbol CRCL-USD \
123
+ --side BUY \
124
+ --price 62.45 \
125
+ --quantity 0.1 \
126
+ --leverage 5 \
127
+ --log-level INFO \
128
+ --log-file logs/taker.log
129
+ ```
130
+
131
+ Run simple perpetual market making strategy:
132
+
133
+ ```bash
134
+ python examples/perpetual_maker.py \
135
+ --is-prod \
136
+ --symbol GOLD-USD \
137
+ --order-amount 0.03 \
138
+ --bid-spread 0.0002 \
139
+ --ask-spread 0.0002 \
140
+ --underlier-weight 0 \
141
+ --order-refresh-tolerance 0.00005 \
142
+ --stop-loss-spread 0.0008 \
143
+ --take-profit-spread 0.0008 \
144
+ --bbo-stop-loss-confirm-streak 5 \
145
+ --quote-pause-spread 0.002 \
146
+ --quote-pause-spread-bad-ticks 1 \
147
+ --quote-resume-spread 0.0012 \
148
+ --leverage 5 \
149
+ --log-level DEBUG \
150
+ --log-file logs/mm.log
151
+ ```
152
+
153
+ ```bash
154
+ python examples/perpetual_maker.py \
155
+ --is-prod \
156
+ --symbol CL-USD \
157
+ --order-amount 1 \
158
+ --bid-spread 0.0004 \
159
+ --ask-spread 0.0004 \
160
+ --underlier-weight 0 \
161
+ --order-refresh-tolerance 0.0001 \
162
+ --stop-loss-spread 0.0015 \
163
+ --take-profit-spread 0.0015 \
164
+ --bbo-stop-loss-confirm-streak 5 \
165
+ --quote-pause-spread 0.002 \
166
+ --quote-pause-spread-bad-ticks 1 \
167
+ --quote-resume-spread 0.0012 \
168
+ --leverage 5 \
169
+ --log-level DEBUG \
170
+ --log-file logs/mm.log
171
+ ```
172
+
173
+ ```bash
174
+ python examples/perpetual_maker.py \
175
+ --is-prod \
176
+ --symbol US500-USD \
177
+ --order-amount 0.02 \
178
+ --bid-spread 0.00025 \
179
+ --ask-spread 0.00025 \
180
+ --underlier-weight 0 \
181
+ --order-refresh-tolerance 0.00005 \
182
+ --stop-loss-spread 0.0001 \
183
+ --take-profit-spread 0.0001 \
184
+ --bbo-stop-loss-confirm-streak 5 \
185
+ --quote-pause-spread 0.002 \
186
+ --quote-pause-spread-bad-ticks 1 \
187
+ --quote-resume-spread 0.0012 \
188
+ --leverage 5 \
189
+ --log-level DEBUG \
190
+ --log-file logs/mm.log
191
+ ```
192
+
193
+ Hint: change `INFO` to `DEBUG`, `WARNING`, `ERROR`, `CRITICAL` for details.
194
+
195
+ ## Requirements
196
+
197
+ * Python 3.12+
198
+ * `websockets`
199
+ * `requests`
200
+
201
+ ## License
202
+
203
+ MIT
qfex2-1.0.0/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # qfex2
2
+
3
+ A Python SDK for the [QFEX](https://docs.qfex.com/api-reference/introduction) API. The `examples/bot_supervisor.py`
4
+ is a pure market making bot that you can run out of the box or with customization.
5
+ By default, it continuously quotes both a buy (bid) and a sell (ask) price for
6
+ US500 around a mid-price, aiming to capture the bid–ask spread without taking a
7
+ directional bet.
8
+
9
+ ![Python Version](https://img.shields.io/badge/python-3.12%2B-blue)
10
+ ![License](https://img.shields.io/badge/license-MIT-green)
11
+
12
+ ## Disclaimers
13
+
14
+ This package is written by AI and backtested under my supervision. After two
15
+ months of tinkering, I'm releasing it as version 1.0.0. The `examples/bot_supervisor.py`
16
+ contains the settings I currently use, so if you just want to passively farming
17
+ QFEX points on autopilot, you can just run:
18
+
19
+ ```bash
20
+ caffeinate -i .venv/bin/python examples/bot_supervisor.py
21
+ ```
22
+
23
+ Of course, you will need to create an account at QFEX first. You can do that with
24
+ my referral [https://qfex.com/@re83f92f](https://qfex.com/@re83f92f) to save
25
+ 10%+ on trading fees.
26
+
27
+ ## Installation
28
+
29
+ Install via pip:
30
+
31
+ ```bash
32
+ pip install qfex2
33
+ ```
34
+
35
+ Or from source:
36
+
37
+ ```bash
38
+ git clone https://github.com/coindataschool/qfex-py.git
39
+ cd qfex-py
40
+ pip install .
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ Create an account at [QFEX](https://qfex.com/@re83f92f) and deposit \$50~\$200.
46
+ (You can deposit more later after you feel comfortable with the bot.)
47
+
48
+ Get your QFEX API keys. See [instruction](https://docs.qfex.com/api-reference/introduction).
49
+
50
+ Store your keys in env vars by adding the following lines to the right startup
51
+ file (`~/.zprofile`, `~/.profile`, `~/.zshrc`, `~/.bashrc`) for your shell:
52
+
53
+ ```bash
54
+ export QFEX_PUBLIC_KEY="your_public_key"
55
+ export QFEX_SECRET_KEY="your_secret_key"
56
+ ```
57
+
58
+ Run pure market making bots:
59
+
60
+ ```bash
61
+ caffeinate -i .venv/bin/python examples/bot_supervisor.py
62
+ ```
63
+
64
+ `examples/bot_supervisor.py` runs one bot at a time on a daily schedule, with
65
+ pauses around news releases, the US stock-market open and weekends. All of its
66
+ times are in UTC by default (`TIMEZONE = "UTC"`). To use your own timezone, set
67
+ `TIMEZONE` to an IANA name such as `"Europe/London"` and convert the schedule,
68
+ blackouts, weekend pause and week start to it. The shipped schedule, sizes and
69
+ blackout dates are the author's own settings for late 2026 — review and replace
70
+ them before running with real money. (`caffeinate` keeps a Mac awake; on Linux
71
+ just run `python examples/bot_supervisor.py`.)
72
+
73
+ ## Build Your Own Bots
74
+
75
+ The `examples/` folder contains several other scripts, each implementing a simple
76
+ strategy. These scripts are meant to demonstrate the features of the `qfex2`
77
+ package, and are not necessarily good trading strategies. You can use them as
78
+ starting points to build your own bots.
79
+
80
+ Run simple maker stratey to place GTC Add Liquidity Orders:
81
+
82
+ ```bash
83
+ python examples/simple_maker.py \
84
+ --is-prod \
85
+ --symbol CRCL-USD \
86
+ --quantity 0.1 \
87
+ --leverage 3 \
88
+ --log-level INFO \
89
+ --log-file logs/maker.log
90
+ ```
91
+
92
+ Run simple taker stratey to place MARKET orders:
93
+
94
+ ```bash
95
+ python examples/simple_taker_market.py \
96
+ --is-prod \
97
+ --symbol CRCL-USD \
98
+ --side BUY \
99
+ --quantity 0.1 \
100
+ --leverage 3 \
101
+ --log-level INFO \
102
+ --log-file logs/taker.log
103
+ ```
104
+
105
+ Run simple taker stratey to place IOC LIMIT orders:
106
+
107
+ ```bash
108
+ python examples/simple_taker_limit_ioc.py \
109
+ --is-prod \
110
+ --symbol CRCL-USD \
111
+ --side BUY \
112
+ --price 62.45 \
113
+ --quantity 0.1 \
114
+ --leverage 5 \
115
+ --log-level INFO \
116
+ --log-file logs/taker.log
117
+ ```
118
+
119
+ Run simple perpetual market making strategy:
120
+
121
+ ```bash
122
+ python examples/perpetual_maker.py \
123
+ --is-prod \
124
+ --symbol GOLD-USD \
125
+ --order-amount 0.03 \
126
+ --bid-spread 0.0002 \
127
+ --ask-spread 0.0002 \
128
+ --underlier-weight 0 \
129
+ --order-refresh-tolerance 0.00005 \
130
+ --stop-loss-spread 0.0008 \
131
+ --take-profit-spread 0.0008 \
132
+ --bbo-stop-loss-confirm-streak 5 \
133
+ --quote-pause-spread 0.002 \
134
+ --quote-pause-spread-bad-ticks 1 \
135
+ --quote-resume-spread 0.0012 \
136
+ --leverage 5 \
137
+ --log-level DEBUG \
138
+ --log-file logs/mm.log
139
+ ```
140
+
141
+ ```bash
142
+ python examples/perpetual_maker.py \
143
+ --is-prod \
144
+ --symbol CL-USD \
145
+ --order-amount 1 \
146
+ --bid-spread 0.0004 \
147
+ --ask-spread 0.0004 \
148
+ --underlier-weight 0 \
149
+ --order-refresh-tolerance 0.0001 \
150
+ --stop-loss-spread 0.0015 \
151
+ --take-profit-spread 0.0015 \
152
+ --bbo-stop-loss-confirm-streak 5 \
153
+ --quote-pause-spread 0.002 \
154
+ --quote-pause-spread-bad-ticks 1 \
155
+ --quote-resume-spread 0.0012 \
156
+ --leverage 5 \
157
+ --log-level DEBUG \
158
+ --log-file logs/mm.log
159
+ ```
160
+
161
+ ```bash
162
+ python examples/perpetual_maker.py \
163
+ --is-prod \
164
+ --symbol US500-USD \
165
+ --order-amount 0.02 \
166
+ --bid-spread 0.00025 \
167
+ --ask-spread 0.00025 \
168
+ --underlier-weight 0 \
169
+ --order-refresh-tolerance 0.00005 \
170
+ --stop-loss-spread 0.0001 \
171
+ --take-profit-spread 0.0001 \
172
+ --bbo-stop-loss-confirm-streak 5 \
173
+ --quote-pause-spread 0.002 \
174
+ --quote-pause-spread-bad-ticks 1 \
175
+ --quote-resume-spread 0.0012 \
176
+ --leverage 5 \
177
+ --log-level DEBUG \
178
+ --log-file logs/mm.log
179
+ ```
180
+
181
+ Hint: change `INFO` to `DEBUG`, `WARNING`, `ERROR`, `CRITICAL` for details.
182
+
183
+ ## Requirements
184
+
185
+ * Python 3.12+
186
+ * `websockets`
187
+ * `requests`
188
+
189
+ ## License
190
+
191
+ MIT
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "qfex2"
7
+ version = "1.0.0"
8
+ description = "Python SDK for the QFEX API"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = {text = "MIT"}
12
+ dependencies = [
13
+ "requests>=2.34.2",
14
+ "websockets>=16.1",
15
+ ]
16
+
17
+ [dependency-groups]
18
+ dev = [
19
+ "pytest>=9.1.1",
20
+ ]
21
+
22
+ [tool.pytest.ini_options]
23
+ pythonpath = "src"
qfex2-1.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,24 @@
1
+ from .trader_client import QFEXTraderClient
2
+ from .config import QFEXConfig
3
+ from .base_client import QFEXTradeError
4
+ from .models import BalanceState, PositionState, BBO, SymbolRefdata, Side, OrderType, TimeInForce
5
+ from .strategy import TraderStrategy
6
+ from .logging_setup import setup_logging
7
+ from .cli_helpers import resolve_credentials, run_leverage_gate
8
+
9
+ __all__ = [
10
+ "QFEXTraderClient",
11
+ "QFEXConfig",
12
+ "QFEXTradeError",
13
+ "BalanceState",
14
+ "PositionState",
15
+ "BBO",
16
+ "SymbolRefdata",
17
+ "Side",
18
+ "OrderType",
19
+ "TimeInForce",
20
+ "TraderStrategy",
21
+ "setup_logging",
22
+ "resolve_credentials",
23
+ "run_leverage_gate",
24
+ ]