walrasquant-lib 0.4.20__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.
Files changed (104) hide show
  1. walrasquant_lib-0.4.20/PKG-INFO +162 -0
  2. walrasquant_lib-0.4.20/README.md +127 -0
  3. walrasquant_lib-0.4.20/pyproject.toml +59 -0
  4. walrasquant_lib-0.4.20/src/walrasquant/__init__.py +7 -0
  5. walrasquant_lib-0.4.20/src/walrasquant/aggregation.py +449 -0
  6. walrasquant_lib-0.4.20/src/walrasquant/backends/__init__.py +5 -0
  7. walrasquant_lib-0.4.20/src/walrasquant/backends/db.py +109 -0
  8. walrasquant_lib-0.4.20/src/walrasquant/backends/db_memory.py +61 -0
  9. walrasquant_lib-0.4.20/src/walrasquant/backends/db_postgresql.py +321 -0
  10. walrasquant_lib-0.4.20/src/walrasquant/backends/db_sqlite.py +310 -0
  11. walrasquant_lib-0.4.20/src/walrasquant/base/__init__.py +24 -0
  12. walrasquant_lib-0.4.20/src/walrasquant/base/api_client.py +46 -0
  13. walrasquant_lib-0.4.20/src/walrasquant/base/connector.py +863 -0
  14. walrasquant_lib-0.4.20/src/walrasquant/base/ems.py +794 -0
  15. walrasquant_lib-0.4.20/src/walrasquant/base/exchange.py +213 -0
  16. walrasquant_lib-0.4.20/src/walrasquant/base/oms.py +428 -0
  17. walrasquant_lib-0.4.20/src/walrasquant/base/retry.py +220 -0
  18. walrasquant_lib-0.4.20/src/walrasquant/base/sms.py +545 -0
  19. walrasquant_lib-0.4.20/src/walrasquant/base/ws_client.py +408 -0
  20. walrasquant_lib-0.4.20/src/walrasquant/config.py +284 -0
  21. walrasquant_lib-0.4.20/src/walrasquant/constants.py +413 -0
  22. walrasquant_lib-0.4.20/src/walrasquant/core/__init__.py +0 -0
  23. walrasquant_lib-0.4.20/src/walrasquant/core/cache.py +688 -0
  24. walrasquant_lib-0.4.20/src/walrasquant/core/clock.py +59 -0
  25. walrasquant_lib-0.4.20/src/walrasquant/core/connection.py +41 -0
  26. walrasquant_lib-0.4.20/src/walrasquant/core/entity.py +504 -0
  27. walrasquant_lib-0.4.20/src/walrasquant/core/nautilius_core.py +103 -0
  28. walrasquant_lib-0.4.20/src/walrasquant/core/registry.py +41 -0
  29. walrasquant_lib-0.4.20/src/walrasquant/engine.py +745 -0
  30. walrasquant_lib-0.4.20/src/walrasquant/error.py +34 -0
  31. walrasquant_lib-0.4.20/src/walrasquant/exchange/__init__.py +13 -0
  32. walrasquant_lib-0.4.20/src/walrasquant/exchange/base_factory.py +172 -0
  33. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/__init__.py +30 -0
  34. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/connector.py +1093 -0
  35. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/constants.py +934 -0
  36. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/ems.py +140 -0
  37. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/error.py +48 -0
  38. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/exchange.py +144 -0
  39. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/factory.py +115 -0
  40. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/oms.py +1807 -0
  41. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/rest_api.py +1653 -0
  42. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/schema.py +1063 -0
  43. walrasquant_lib-0.4.20/src/walrasquant/exchange/binance/websockets.py +389 -0
  44. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/__init__.py +28 -0
  45. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/connector.py +578 -0
  46. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/constants.py +392 -0
  47. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/ems.py +202 -0
  48. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/error.py +36 -0
  49. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/exchange.py +128 -0
  50. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/factory.py +135 -0
  51. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/oms.py +1619 -0
  52. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/rest_api.py +610 -0
  53. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/schema.py +885 -0
  54. walrasquant_lib-0.4.20/src/walrasquant/exchange/bitget/websockets.py +753 -0
  55. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/__init__.py +32 -0
  56. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/connector.py +819 -0
  57. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/constants.py +479 -0
  58. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/ems.py +93 -0
  59. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/error.py +36 -0
  60. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/exchange.py +108 -0
  61. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/factory.py +128 -0
  62. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/oms.py +1195 -0
  63. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/rest_api.py +570 -0
  64. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/schema.py +867 -0
  65. walrasquant_lib-0.4.20/src/walrasquant/exchange/bybit/websockets.py +307 -0
  66. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/__init__.py +28 -0
  67. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/connector.py +370 -0
  68. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/constants.py +371 -0
  69. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/ems.py +156 -0
  70. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/error.py +48 -0
  71. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/exchange.py +120 -0
  72. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/factory.py +135 -0
  73. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/oms.py +1081 -0
  74. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/rest_api.py +348 -0
  75. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/schema.py +583 -0
  76. walrasquant_lib-0.4.20/src/walrasquant/exchange/hyperliquid/websockets.py +592 -0
  77. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/__init__.py +25 -0
  78. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/connector.py +931 -0
  79. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/constants.py +518 -0
  80. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/ems.py +144 -0
  81. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/error.py +66 -0
  82. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/exchange.py +102 -0
  83. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/factory.py +138 -0
  84. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/oms.py +1199 -0
  85. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/rest_api.py +799 -0
  86. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/schema.py +1449 -0
  87. walrasquant_lib-0.4.20/src/walrasquant/exchange/okx/websockets.py +420 -0
  88. walrasquant_lib-0.4.20/src/walrasquant/exchange/registry.py +201 -0
  89. walrasquant_lib-0.4.20/src/walrasquant/execution/__init__.py +24 -0
  90. walrasquant_lib-0.4.20/src/walrasquant/execution/algorithm.py +968 -0
  91. walrasquant_lib-0.4.20/src/walrasquant/execution/algorithms/__init__.py +3 -0
  92. walrasquant_lib-0.4.20/src/walrasquant/execution/algorithms/twap.py +392 -0
  93. walrasquant_lib-0.4.20/src/walrasquant/execution/config.py +34 -0
  94. walrasquant_lib-0.4.20/src/walrasquant/execution/constants.py +27 -0
  95. walrasquant_lib-0.4.20/src/walrasquant/execution/schema.py +62 -0
  96. walrasquant_lib-0.4.20/src/walrasquant/indicator.py +382 -0
  97. walrasquant_lib-0.4.20/src/walrasquant/push.py +77 -0
  98. walrasquant_lib-0.4.20/src/walrasquant/schema.py +755 -0
  99. walrasquant_lib-0.4.20/src/walrasquant/strategy.py +1805 -0
  100. walrasquant_lib-0.4.20/src/walrasquant/tools/__init__.py +0 -0
  101. walrasquant_lib-0.4.20/src/walrasquant/tools/pm2_wrapper.py +1016 -0
  102. walrasquant_lib-0.4.20/src/walrasquant/web/__init__.py +26 -0
  103. walrasquant_lib-0.4.20/src/walrasquant/web/app.py +157 -0
  104. walrasquant_lib-0.4.20/src/walrasquant/web/server.py +92 -0
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.3
2
+ Name: walrasquant-lib
3
+ Version: 0.4.20
4
+ Summary: fastest python trading bot
5
+ Author: River-Shi
6
+ Author-email: River-Shi <nachuan.shi.quant@gmail.com>
7
+ License: MIT LICENSE
8
+ Requires-Dist: numpy>=1.26.4,<2.2.1
9
+ Requires-Dist: redis>=5.2.1,<6.0.0
10
+ Requires-Dist: zmq>=0.0.0,<0.0.1
11
+ Requires-Dist: apscheduler>=3.11.0,<4.0.0
12
+ Requires-Dist: returns>=0.24.0,<0.25.0
13
+ Requires-Dist: aiosqlite>=0.21.0,<0.22.0
14
+ Requires-Dist: uvloop>=0.21.0
15
+ Requires-Dist: throttled-py>=2.2.3
16
+ Requires-Dist: asyncpg>=0.30.0
17
+ Requires-Dist: psycopg2-binary>=2.9.10
18
+ Requires-Dist: click>=8.1.0
19
+ Requires-Dist: pycryptodome>=3.23.0
20
+ Requires-Dist: eth-account>=0.13.7
21
+ Requires-Dist: fastapi>=0.117.1
22
+ Requires-Dist: uvicorn>=0.36.0
23
+ Requires-Dist: dynaconf[redis]>=3.2.12
24
+ Requires-Dist: pandas>=2.3.3,<3.0.0
25
+ Requires-Dist: aiohttp>=3.13.3
26
+ Requires-Dist: rich>=14.0.0
27
+ Requires-Dist: picows>=2.1.1
28
+ Requires-Dist: ccxt>=4.5.63
29
+ Requires-Dist: nexuscore-lib>=0.2.0
30
+ Requires-Dist: flashduty-lib>=0.2.0
31
+ Requires-Dist: nexuslog-lib>=0.5.0
32
+ Requires-Dist: msgspec>=0.21.1
33
+ Requires-Python: >=3.11, <3.15
34
+ Description-Content-Type: text/markdown
35
+
36
+ # walrasquant
37
+
38
+ `walrasquant` is a high-performance Python framework for quantitative trading.
39
+ It is designed for low-latency execution, multi-exchange connectivity, and strategy development at scale.
40
+
41
+ ## Highlights
42
+
43
+ - Async-first architecture for real-time trading workflows
44
+ - Multi-exchange support (OKX, Binance, Bybit, Hyperliquid, Bitget)
45
+ - Built-in order and position lifecycle management
46
+ - Strategy framework with execution algorithms (including TWAP)
47
+ - Optional web API integration with FastAPI
48
+ - CLI and PM2 tooling for monitoring and operations
49
+
50
+ ## Installation
51
+
52
+ ### Requirements
53
+
54
+ - Python `>=3.11,<3.14`
55
+ - Redis (recommended for monitoring and shared runtime state)
56
+
57
+ ### From PyPI
58
+
59
+ ```bash
60
+ pip install walrasquant
61
+ ```
62
+
63
+ ### From source
64
+
65
+ ```bash
66
+ git clone https://github.com/walras-group/WalrasQuant.git
67
+ cd WalrasQuant
68
+ uv pip install -e .
69
+ ```
70
+
71
+ ## Quick start
72
+
73
+ ```python
74
+ from decimal import Decimal
75
+
76
+ from walrasquant.constants import settings, ExchangeType, OrderSide, OrderType
77
+ from walrasquant.config import Config, BasicConfig, PublicConnectorConfig, PrivateConnectorConfig
78
+ from walrasquant.engine import Engine
79
+ from walrasquant.exchange.okx import OkxAccountType
80
+ from walrasquant.schema import BookL1, Order
81
+ from walrasquant.strategy import Strategy
82
+
83
+
84
+ OKX_API_KEY = settings.OKX.DEMO_1.api_key
85
+ OKX_SECRET = settings.OKX.DEMO_1.secret
86
+ OKX_PASSPHRASE = settings.OKX.DEMO_1.passphrase
87
+
88
+
89
+ class DemoStrategy(Strategy):
90
+ def __init__(self):
91
+ super().__init__()
92
+ self.subscribe_bookl1(symbols=["BTCUSDT-PERP.OKX"])
93
+ self.signal = True
94
+
95
+ def on_filled_order(self, order: Order):
96
+ print(order)
97
+
98
+ def on_bookl1(self, bookl1: BookL1):
99
+ if not self.signal:
100
+ return
101
+
102
+ self.create_order(
103
+ symbol="BTCUSDT-PERP.OKX",
104
+ side=OrderSide.BUY,
105
+ type=OrderType.MARKET,
106
+ amount=Decimal("0.1"),
107
+ )
108
+ self.create_order(
109
+ symbol="BTCUSDT-PERP.OKX",
110
+ side=OrderSide.SELL,
111
+ type=OrderType.MARKET,
112
+ amount=Decimal("0.1"),
113
+ )
114
+ self.signal = False
115
+
116
+
117
+ config = Config(
118
+ strategy_id="okx_demo_buy_sell",
119
+ user_id="user_test",
120
+ strategy=DemoStrategy(),
121
+ basic_config={
122
+ ExchangeType.OKX: BasicConfig(
123
+ api_key=OKX_API_KEY,
124
+ secret=OKX_SECRET,
125
+ passphrase=OKX_PASSPHRASE,
126
+ testnet=True,
127
+ )
128
+ },
129
+ public_conn_config={
130
+ ExchangeType.OKX: [PublicConnectorConfig(account_type=OkxAccountType.DEMO)]
131
+ },
132
+ private_conn_config={
133
+ ExchangeType.OKX: [PrivateConnectorConfig(account_type=OkxAccountType.DEMO)]
134
+ },
135
+ )
136
+
137
+ engine = Engine(config)
138
+
139
+ if __name__ == "__main__":
140
+ try:
141
+ engine.start()
142
+ finally:
143
+ engine.dispose()
144
+ ```
145
+
146
+ ## CLI tools
147
+
148
+ After installation, the following commands are available:
149
+
150
+ - `wq` for PM2-based strategy process operations
151
+
152
+ ## Documentation
153
+
154
+ - Local docs source: `docs/`
155
+
156
+ ## Contributing
157
+
158
+ Contributions are welcome. Please open an issue or submit a PR.
159
+
160
+ ## License
161
+
162
+ MIT License
@@ -0,0 +1,127 @@
1
+ # walrasquant
2
+
3
+ `walrasquant` is a high-performance Python framework for quantitative trading.
4
+ It is designed for low-latency execution, multi-exchange connectivity, and strategy development at scale.
5
+
6
+ ## Highlights
7
+
8
+ - Async-first architecture for real-time trading workflows
9
+ - Multi-exchange support (OKX, Binance, Bybit, Hyperliquid, Bitget)
10
+ - Built-in order and position lifecycle management
11
+ - Strategy framework with execution algorithms (including TWAP)
12
+ - Optional web API integration with FastAPI
13
+ - CLI and PM2 tooling for monitoring and operations
14
+
15
+ ## Installation
16
+
17
+ ### Requirements
18
+
19
+ - Python `>=3.11,<3.14`
20
+ - Redis (recommended for monitoring and shared runtime state)
21
+
22
+ ### From PyPI
23
+
24
+ ```bash
25
+ pip install walrasquant
26
+ ```
27
+
28
+ ### From source
29
+
30
+ ```bash
31
+ git clone https://github.com/walras-group/WalrasQuant.git
32
+ cd WalrasQuant
33
+ uv pip install -e .
34
+ ```
35
+
36
+ ## Quick start
37
+
38
+ ```python
39
+ from decimal import Decimal
40
+
41
+ from walrasquant.constants import settings, ExchangeType, OrderSide, OrderType
42
+ from walrasquant.config import Config, BasicConfig, PublicConnectorConfig, PrivateConnectorConfig
43
+ from walrasquant.engine import Engine
44
+ from walrasquant.exchange.okx import OkxAccountType
45
+ from walrasquant.schema import BookL1, Order
46
+ from walrasquant.strategy import Strategy
47
+
48
+
49
+ OKX_API_KEY = settings.OKX.DEMO_1.api_key
50
+ OKX_SECRET = settings.OKX.DEMO_1.secret
51
+ OKX_PASSPHRASE = settings.OKX.DEMO_1.passphrase
52
+
53
+
54
+ class DemoStrategy(Strategy):
55
+ def __init__(self):
56
+ super().__init__()
57
+ self.subscribe_bookl1(symbols=["BTCUSDT-PERP.OKX"])
58
+ self.signal = True
59
+
60
+ def on_filled_order(self, order: Order):
61
+ print(order)
62
+
63
+ def on_bookl1(self, bookl1: BookL1):
64
+ if not self.signal:
65
+ return
66
+
67
+ self.create_order(
68
+ symbol="BTCUSDT-PERP.OKX",
69
+ side=OrderSide.BUY,
70
+ type=OrderType.MARKET,
71
+ amount=Decimal("0.1"),
72
+ )
73
+ self.create_order(
74
+ symbol="BTCUSDT-PERP.OKX",
75
+ side=OrderSide.SELL,
76
+ type=OrderType.MARKET,
77
+ amount=Decimal("0.1"),
78
+ )
79
+ self.signal = False
80
+
81
+
82
+ config = Config(
83
+ strategy_id="okx_demo_buy_sell",
84
+ user_id="user_test",
85
+ strategy=DemoStrategy(),
86
+ basic_config={
87
+ ExchangeType.OKX: BasicConfig(
88
+ api_key=OKX_API_KEY,
89
+ secret=OKX_SECRET,
90
+ passphrase=OKX_PASSPHRASE,
91
+ testnet=True,
92
+ )
93
+ },
94
+ public_conn_config={
95
+ ExchangeType.OKX: [PublicConnectorConfig(account_type=OkxAccountType.DEMO)]
96
+ },
97
+ private_conn_config={
98
+ ExchangeType.OKX: [PrivateConnectorConfig(account_type=OkxAccountType.DEMO)]
99
+ },
100
+ )
101
+
102
+ engine = Engine(config)
103
+
104
+ if __name__ == "__main__":
105
+ try:
106
+ engine.start()
107
+ finally:
108
+ engine.dispose()
109
+ ```
110
+
111
+ ## CLI tools
112
+
113
+ After installation, the following commands are available:
114
+
115
+ - `wq` for PM2-based strategy process operations
116
+
117
+ ## Documentation
118
+
119
+ - Local docs source: `docs/`
120
+
121
+ ## Contributing
122
+
123
+ Contributions are welcome. Please open an issue or submit a PR.
124
+
125
+ ## License
126
+
127
+ MIT License
@@ -0,0 +1,59 @@
1
+ [project]
2
+ name = "walrasquant-lib"
3
+ version = "0.4.20"
4
+ description = "fastest python trading bot"
5
+ authors = [
6
+ {name = "River-Shi",email = "nachuan.shi.quant@gmail.com"}
7
+ ]
8
+ license = {text = "MIT LICENSE"}
9
+ readme = "README.md"
10
+ requires-python = ">=3.11,<3.15"
11
+ dependencies = [
12
+ "numpy (>=1.26.4,<2.2.1)",
13
+ "redis (>=5.2.1,<6.0.0)",
14
+ "zmq (>=0.0.0,<0.0.1)",
15
+ "apscheduler (>=3.11.0,<4.0.0)",
16
+ "returns (>=0.24.0,<0.25.0)",
17
+ "aiosqlite (>=0.21.0,<0.22.0)",
18
+ "uvloop>=0.21.0",
19
+ "throttled-py>=2.2.3",
20
+ "asyncpg>=0.30.0",
21
+ "psycopg2-binary>=2.9.10",
22
+ "click>=8.1.0",
23
+ "pycryptodome>=3.23.0",
24
+ "eth-account>=0.13.7",
25
+ "fastapi>=0.117.1",
26
+ "uvicorn>=0.36.0",
27
+ "dynaconf[redis]>=3.2.12",
28
+ "pandas (>=2.3.3,<3.0.0)",
29
+ "aiohttp>=3.13.3",
30
+ "rich>=14.0.0",
31
+ "picows>=2.1.1",
32
+ "ccxt>=4.5.63",
33
+ "nexuscore-lib>=0.2.0",
34
+ "flashduty-lib>=0.2.0",
35
+ "nexuslog-lib>=0.5.0",
36
+ "msgspec>=0.21.1",
37
+ ]
38
+
39
+ [project.scripts]
40
+ wq = "walrasquant.tools.pm2_wrapper:main"
41
+
42
+ [build-system]
43
+ requires = ["uv_build>=0.10.7,<0.11.0"]
44
+ build-backend = "uv_build"
45
+
46
+ [tool.uv.build-backend]
47
+ module-name = "walrasquant"
48
+
49
+ [tool.ty.src]
50
+ include = ["src", "test", "strategy"]
51
+
52
+ [dependency-groups]
53
+ dev = [
54
+ "pytest>=8.3.5",
55
+ "pytest-asyncio>=1.3.0",
56
+ "pytest-timeout>=2.4.0",
57
+ "ruff>=0.15.6",
58
+ "ty>=0.0.23",
59
+ ]
@@ -0,0 +1,7 @@
1
+ from importlib.metadata import version, PackageNotFoundError
2
+
3
+
4
+ try:
5
+ __version__ = version("walrasquant-lib")
6
+ except PackageNotFoundError:
7
+ __version__ = "unknown"