walrasquant-lib 0.4.20__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.
- walrasquant/__init__.py +7 -0
- walrasquant/aggregation.py +449 -0
- walrasquant/backends/__init__.py +5 -0
- walrasquant/backends/db.py +109 -0
- walrasquant/backends/db_memory.py +61 -0
- walrasquant/backends/db_postgresql.py +321 -0
- walrasquant/backends/db_sqlite.py +310 -0
- walrasquant/base/__init__.py +24 -0
- walrasquant/base/api_client.py +46 -0
- walrasquant/base/connector.py +863 -0
- walrasquant/base/ems.py +794 -0
- walrasquant/base/exchange.py +213 -0
- walrasquant/base/oms.py +428 -0
- walrasquant/base/retry.py +220 -0
- walrasquant/base/sms.py +545 -0
- walrasquant/base/ws_client.py +408 -0
- walrasquant/config.py +284 -0
- walrasquant/constants.py +413 -0
- walrasquant/core/__init__.py +0 -0
- walrasquant/core/cache.py +688 -0
- walrasquant/core/clock.py +59 -0
- walrasquant/core/connection.py +41 -0
- walrasquant/core/entity.py +504 -0
- walrasquant/core/nautilius_core.py +103 -0
- walrasquant/core/registry.py +41 -0
- walrasquant/engine.py +745 -0
- walrasquant/error.py +34 -0
- walrasquant/exchange/__init__.py +13 -0
- walrasquant/exchange/base_factory.py +172 -0
- walrasquant/exchange/binance/__init__.py +30 -0
- walrasquant/exchange/binance/connector.py +1093 -0
- walrasquant/exchange/binance/constants.py +934 -0
- walrasquant/exchange/binance/ems.py +140 -0
- walrasquant/exchange/binance/error.py +48 -0
- walrasquant/exchange/binance/exchange.py +144 -0
- walrasquant/exchange/binance/factory.py +115 -0
- walrasquant/exchange/binance/oms.py +1807 -0
- walrasquant/exchange/binance/rest_api.py +1653 -0
- walrasquant/exchange/binance/schema.py +1063 -0
- walrasquant/exchange/binance/websockets.py +389 -0
- walrasquant/exchange/bitget/__init__.py +28 -0
- walrasquant/exchange/bitget/connector.py +578 -0
- walrasquant/exchange/bitget/constants.py +392 -0
- walrasquant/exchange/bitget/ems.py +202 -0
- walrasquant/exchange/bitget/error.py +36 -0
- walrasquant/exchange/bitget/exchange.py +128 -0
- walrasquant/exchange/bitget/factory.py +135 -0
- walrasquant/exchange/bitget/oms.py +1619 -0
- walrasquant/exchange/bitget/rest_api.py +610 -0
- walrasquant/exchange/bitget/schema.py +885 -0
- walrasquant/exchange/bitget/websockets.py +753 -0
- walrasquant/exchange/bybit/__init__.py +32 -0
- walrasquant/exchange/bybit/connector.py +819 -0
- walrasquant/exchange/bybit/constants.py +479 -0
- walrasquant/exchange/bybit/ems.py +93 -0
- walrasquant/exchange/bybit/error.py +36 -0
- walrasquant/exchange/bybit/exchange.py +108 -0
- walrasquant/exchange/bybit/factory.py +128 -0
- walrasquant/exchange/bybit/oms.py +1195 -0
- walrasquant/exchange/bybit/rest_api.py +570 -0
- walrasquant/exchange/bybit/schema.py +867 -0
- walrasquant/exchange/bybit/websockets.py +307 -0
- walrasquant/exchange/hyperliquid/__init__.py +28 -0
- walrasquant/exchange/hyperliquid/connector.py +370 -0
- walrasquant/exchange/hyperliquid/constants.py +371 -0
- walrasquant/exchange/hyperliquid/ems.py +156 -0
- walrasquant/exchange/hyperliquid/error.py +48 -0
- walrasquant/exchange/hyperliquid/exchange.py +120 -0
- walrasquant/exchange/hyperliquid/factory.py +135 -0
- walrasquant/exchange/hyperliquid/oms.py +1081 -0
- walrasquant/exchange/hyperliquid/rest_api.py +348 -0
- walrasquant/exchange/hyperliquid/schema.py +583 -0
- walrasquant/exchange/hyperliquid/websockets.py +592 -0
- walrasquant/exchange/okx/__init__.py +25 -0
- walrasquant/exchange/okx/connector.py +931 -0
- walrasquant/exchange/okx/constants.py +518 -0
- walrasquant/exchange/okx/ems.py +144 -0
- walrasquant/exchange/okx/error.py +66 -0
- walrasquant/exchange/okx/exchange.py +102 -0
- walrasquant/exchange/okx/factory.py +138 -0
- walrasquant/exchange/okx/oms.py +1199 -0
- walrasquant/exchange/okx/rest_api.py +799 -0
- walrasquant/exchange/okx/schema.py +1449 -0
- walrasquant/exchange/okx/websockets.py +420 -0
- walrasquant/exchange/registry.py +201 -0
- walrasquant/execution/__init__.py +24 -0
- walrasquant/execution/algorithm.py +968 -0
- walrasquant/execution/algorithms/__init__.py +3 -0
- walrasquant/execution/algorithms/twap.py +392 -0
- walrasquant/execution/config.py +34 -0
- walrasquant/execution/constants.py +27 -0
- walrasquant/execution/schema.py +62 -0
- walrasquant/indicator.py +382 -0
- walrasquant/push.py +77 -0
- walrasquant/schema.py +755 -0
- walrasquant/strategy.py +1805 -0
- walrasquant/tools/__init__.py +0 -0
- walrasquant/tools/pm2_wrapper.py +1016 -0
- walrasquant/web/__init__.py +26 -0
- walrasquant/web/app.py +157 -0
- walrasquant/web/server.py +92 -0
- walrasquant_lib-0.4.20.dist-info/METADATA +162 -0
- walrasquant_lib-0.4.20.dist-info/RECORD +105 -0
- walrasquant_lib-0.4.20.dist-info/WHEEL +4 -0
- walrasquant_lib-0.4.20.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HyperLiquid exchange factory implementation.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from walrasquant.constants import ExchangeType, AccountType, ConfigType
|
|
8
|
+
from walrasquant.config import (
|
|
9
|
+
PublicConnectorConfig,
|
|
10
|
+
PrivateConnectorConfig,
|
|
11
|
+
BasicConfig,
|
|
12
|
+
)
|
|
13
|
+
from walrasquant.exchange.base_factory import ExchangeFactory, BuildContext
|
|
14
|
+
from walrasquant.base import (
|
|
15
|
+
ExchangeManager,
|
|
16
|
+
PublicConnector,
|
|
17
|
+
PrivateConnector,
|
|
18
|
+
ExecutionManagementSystem,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from walrasquant.exchange.hyperliquid.exchange import HyperLiquidExchangeManager
|
|
22
|
+
from walrasquant.exchange.hyperliquid.connector import (
|
|
23
|
+
HyperLiquidPublicConnector,
|
|
24
|
+
HyperLiquidPrivateConnector,
|
|
25
|
+
)
|
|
26
|
+
from walrasquant.exchange.hyperliquid.ems import HyperLiquidExecutionManagementSystem
|
|
27
|
+
from walrasquant.exchange.hyperliquid.constants import HyperLiquidAccountType
|
|
28
|
+
from walrasquant.exchange.hyperliquid.schema import HyperLiquidMarket
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class HyperLiquidFactory(ExchangeFactory):
|
|
32
|
+
"""Factory for creating HyperLiquid exchange components."""
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def exchange_type(self) -> ExchangeType:
|
|
36
|
+
return ExchangeType.HYPERLIQUID
|
|
37
|
+
|
|
38
|
+
def create_manager(self, basic_config: BasicConfig) -> ExchangeManager:
|
|
39
|
+
"""Create HyperLiquidExchangeManager."""
|
|
40
|
+
ccxt_config: ConfigType = {
|
|
41
|
+
"apiKey": basic_config.api_key or "",
|
|
42
|
+
"secret": basic_config.secret or "",
|
|
43
|
+
"exchange_id": "hyperliquid",
|
|
44
|
+
"sandbox": basic_config.testnet,
|
|
45
|
+
}
|
|
46
|
+
if basic_config.passphrase:
|
|
47
|
+
ccxt_config["password"] = basic_config.passphrase
|
|
48
|
+
|
|
49
|
+
return HyperLiquidExchangeManager(ccxt_config)
|
|
50
|
+
|
|
51
|
+
def create_public_connector(
|
|
52
|
+
self,
|
|
53
|
+
config: PublicConnectorConfig,
|
|
54
|
+
exchange: ExchangeManager,
|
|
55
|
+
context: BuildContext,
|
|
56
|
+
) -> PublicConnector:
|
|
57
|
+
"""Create HyperLiquidPublicConnector."""
|
|
58
|
+
if not isinstance(config.account_type, HyperLiquidAccountType):
|
|
59
|
+
raise TypeError(
|
|
60
|
+
"HyperLiquid public connector requires HyperLiquidAccountType"
|
|
61
|
+
)
|
|
62
|
+
connector = HyperLiquidPublicConnector(
|
|
63
|
+
account_type=config.account_type,
|
|
64
|
+
exchange=cast(HyperLiquidExchangeManager, exchange),
|
|
65
|
+
msgbus=context.msgbus,
|
|
66
|
+
clock=context.clock,
|
|
67
|
+
task_manager=context.task_manager,
|
|
68
|
+
enable_rate_limit=config.enable_rate_limit,
|
|
69
|
+
custom_url=config.custom_url,
|
|
70
|
+
max_subscriptions_per_client=config.max_subscriptions_per_client,
|
|
71
|
+
max_clients=config.max_clients,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# HyperLiquid needs post-creation setup
|
|
75
|
+
self.setup_public_connector(exchange, connector, config.account_type)
|
|
76
|
+
return connector
|
|
77
|
+
|
|
78
|
+
def create_private_connector(
|
|
79
|
+
self,
|
|
80
|
+
config: PrivateConnectorConfig,
|
|
81
|
+
exchange: ExchangeManager,
|
|
82
|
+
context: BuildContext,
|
|
83
|
+
account_type: AccountType | None = None,
|
|
84
|
+
) -> PrivateConnector:
|
|
85
|
+
"""Create HyperLiquidPrivateConnector."""
|
|
86
|
+
# Use provided account_type or fall back to config
|
|
87
|
+
final_account_type = account_type or config.account_type
|
|
88
|
+
|
|
89
|
+
if not isinstance(final_account_type, HyperLiquidAccountType):
|
|
90
|
+
raise TypeError(
|
|
91
|
+
"HyperLiquid private connector requires HyperLiquidAccountType"
|
|
92
|
+
)
|
|
93
|
+
return HyperLiquidPrivateConnector(
|
|
94
|
+
exchange=cast(HyperLiquidExchangeManager, exchange),
|
|
95
|
+
account_type=final_account_type,
|
|
96
|
+
cache=context.cache,
|
|
97
|
+
clock=context.clock,
|
|
98
|
+
msgbus=context.msgbus,
|
|
99
|
+
registry=context.registry,
|
|
100
|
+
enable_rate_limit=config.enable_rate_limit,
|
|
101
|
+
task_manager=context.task_manager,
|
|
102
|
+
max_slippage=config.max_slippage,
|
|
103
|
+
max_subscriptions_per_client=config.max_subscriptions_per_client,
|
|
104
|
+
max_clients=config.max_clients,
|
|
105
|
+
order_query_config=context.order_query_config,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
def create_ems(
|
|
109
|
+
self, exchange: ExchangeManager, context: BuildContext
|
|
110
|
+
) -> ExecutionManagementSystem:
|
|
111
|
+
"""Create HyperLiquidExecutionManagementSystem."""
|
|
112
|
+
return HyperLiquidExecutionManagementSystem(
|
|
113
|
+
market=cast(dict[str, HyperLiquidMarket], exchange.market),
|
|
114
|
+
cache=context.cache,
|
|
115
|
+
msgbus=context.msgbus,
|
|
116
|
+
clock=context.clock,
|
|
117
|
+
task_manager=context.task_manager,
|
|
118
|
+
registry=context.registry,
|
|
119
|
+
queue_maxsize=context.queue_maxsize,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def setup_public_connector(
|
|
123
|
+
self,
|
|
124
|
+
exchange: ExchangeManager,
|
|
125
|
+
connector: PublicConnector,
|
|
126
|
+
account_type: AccountType,
|
|
127
|
+
) -> None:
|
|
128
|
+
"""Setup public connector account type."""
|
|
129
|
+
if not isinstance(account_type, HyperLiquidAccountType):
|
|
130
|
+
raise TypeError(
|
|
131
|
+
"HyperLiquid public connector requires HyperLiquidAccountType"
|
|
132
|
+
)
|
|
133
|
+
cast(HyperLiquidExchangeManager, exchange).set_public_connector_account_type(
|
|
134
|
+
account_type
|
|
135
|
+
)
|