malkhut: multi-exchange asset universe + schema docs
ExchangeProfile: standardized exchange metadata (fees, latency, capabilities). 3 pre-defined exchanges: Binance, BingX, Bybit. AssetProfile.exchanges: tuple[str] — which venues trade each asset. New query functions: get_assets_on_exchange, get_common_assets, get_exchange_for_asset, get_exchange, list_exchanges. _DATA_STORAGE_SCHEMA_FORMATS.md: comprehensive reference for agent consumption — data model, storage format, query interfaces, data flow diagram, enum reference, import patterns for BLUE/VIOLET/UV integration. README updated: exchange registry section, package structure, subsystems table.
This commit is contained in:
@@ -136,7 +136,7 @@ MALKHUT/
|
||||
│ │ ├── dsl.py # Strategy DSL v2 (40+ primitives, 40+ sensors)
|
||||
│ │ ├── generator.py # Genetic programming strategy evolution
|
||||
│ │ ├── selector.py # Regime → strategy mapping + performance matrix
|
||||
│ │ ├── asset_classification.py # Multi-label invariant asset taxonomy
|
||||
│ │ ├── asset_classification.py # Multi-label taxonomy + exchange registry (system-wide)
|
||||
│ │ ├── asset_behavior.py # 10-dimension behavior DSL, research-validated
|
||||
│ │ ├── asset_compiler.py # Auto-fetch from Binance/BingX, compile profiles
|
||||
│ │ ├── parallel_eval.py # ProcessPoolExecutor episode runner, 9x speedup
|
||||
@@ -422,7 +422,7 @@ simple doctrinal tick-exits (C11) ship first via T19 step 3; MALKHUT supersedes
|
||||
| **Strategy DSL v2** | `training/dsl.py` | 69 | 40+ primitives, 40+ sensors, 16 builtins |
|
||||
| **Strategy Generator** | `training/generator.py` | 20 | Genetic programming: crossover, mutation, tournament |
|
||||
| **Strategy Selector** | `training/selector.py` | 24 | Regime → strategy mapping, performance matrix |
|
||||
| **Asset Classification** | `training/asset_classification.py` | 190 | Multi-label invariant taxonomy, 13 assets, cross-dimensional consistency |
|
||||
| **Asset Classification** | `training/asset_classification.py` | 190 | Multi-label taxonomy + exchange registry, 13 assets, system-wide store |
|
||||
| **Asset Behavior DSL** | `training/asset_behavior.py` | (in classification) | 10 orthogonal dimensions, 3 templates, 13 behaviors, research-validated |
|
||||
| **Asset Compiler** | `training/asset_compiler.py` | (new) | Auto-fetch from Binance/BingX API, compile profiles, rate-limited |
|
||||
| **Cognition Pipeline** | `training/cognition.py` | 29 | Rate-limited, 8 sources, dedup, perm-run |
|
||||
@@ -690,6 +690,63 @@ btc.sector # Sector.CURRENCY
|
||||
btc.token_role # TokenRole.STORE_OF_VALUE
|
||||
```
|
||||
|
||||
### Exchange Registry (Multi-Exchange Asset Universe)
|
||||
|
||||
MALKHUT serves as the **system-wide asset universe store** for BLUE, VIOLET, UV, and all
|
||||
downstream systems. Each asset knows which exchanges trade it; each exchange has a
|
||||
standardized profile.
|
||||
|
||||
#### ExchangeProfile
|
||||
|
||||
| Field | Type | Purpose |
|
||||
|-------|------|---------|
|
||||
| `exchange_id` | str | Canonical key: `"binance"`, `"bingx"`, `"bybit"` |
|
||||
| `display_name` | str | Human-readable name |
|
||||
| `has_spot` | bool | Spot trading available |
|
||||
| `has_perps` | bool | Perpetual futures available |
|
||||
| `has_options` | bool | Options available |
|
||||
| `api_base_url` | str | REST API root URL |
|
||||
| `ws_base_url` | str | WebSocket root URL |
|
||||
| `default_taker_fee_bps` | float | Default taker fee |
|
||||
| `default_maker_fee_bps` | float | Default maker fee |
|
||||
| `typical_latency_ms` | float | Typical API latency |
|
||||
|
||||
#### Pre-defined Exchanges
|
||||
|
||||
| Exchange | Spot | Perps | Options | Taker Fee | Latency |
|
||||
|----------|------|-------|---------|-----------|---------|
|
||||
| **Binance** | ✓ | ✓ | ✓ | 0.4 bps | 40 ms |
|
||||
| **BingX** | ✓ | ✓ | ✗ | 0.5 bps | 100 ms |
|
||||
| **Bybit** | ✓ | ✓ | ✓ | 0.06 bps | 50 ms |
|
||||
|
||||
#### Exchange-Asset Mapping
|
||||
|
||||
Each `AssetProfile` carries an `exchanges: tuple[str, ...]` field listing which venues
|
||||
trade the asset. Default: `("binance",)`. Other systems (BLUE/VIOLET/UV) import their
|
||||
asset universes into this store.
|
||||
|
||||
```python
|
||||
from malkhut.training.asset_classification import *
|
||||
|
||||
# Which exchanges trade BTC?
|
||||
btc = get_asset_profile("BTCUSDT")
|
||||
print(btc.exchanges) # ('binance',)
|
||||
|
||||
# All assets on Binance
|
||||
binance_assets = get_assets_on_exchange("binance")
|
||||
|
||||
# Assets traded on BOTH Binance and BingX
|
||||
common = get_common_assets("binance", "bingx")
|
||||
|
||||
# Which exchanges trade a given asset?
|
||||
venues = get_exchange_for_asset("ETHUSDT")
|
||||
|
||||
# Exchange metadata
|
||||
ex = get_exchange("binance")
|
||||
print(ex.default_taker_fee_bps) # 0.4
|
||||
print(ex.typical_latency_ms) # 40
|
||||
```
|
||||
|
||||
### Asset Behavior DSL (10-Dimension Research-Validated Model)
|
||||
|
||||
The Asset Behavior DSL decomposes each asset's **trading behavior** into 10 orthogonal
|
||||
|
||||
Reference in New Issue
Block a user