malkhut: standardized order types — FIX/CCXT-aligned, multi-exchange mapping
order_types.py: Five-layer taxonomy normalized to industry standards:
Layer 1: Base types (FIX Tag 40) — MARKET, LIMIT
Layer 2: Time-in-force (FIX Tag 59) — GTC, IOC, FOK, GTD
Layer 3: Conditional/Trigger (FIX Tag 3/4+MIT) — STOP_MARKET, STOP_LIMIT,
TRIGGER_MARKET, TRIGGER_LIMIT, TRAILING_STOP
Layer 4: Instructions (FIX Tag 18) — POST_ONLY, REDUCE_ONLY, HIDDEN, ICEBERG
Layer 5: Compound (exchange-specific) — OCO, TP_SL
Cross-exchange mapping: BingX ↔ Binance ↔ Bybit (from CCXT source code).
Standards: FIX 4.4 Tag 40/59/18, CCXT unified API, ISO 10383 (MIC).
Transferability: strategy PARAMETERS transfer. ORDER TYPE NAMES are
venue-specific but semantics identical (LIMIT = LIMIT everywhere).
14 tests. README updated with full mapping table and standards references.
This commit is contained in:
@@ -136,6 +136,7 @@ MALKHUT/
|
||||
│ │ ├── pipeline.py # Bounded continuous learning loop + logger
|
||||
│ │ ├── dsl.py # Strategy DSL v2 (40+ primitives, 40+ sensors)
|
||||
│ │ ├── generator.py # Genetic programming strategy evolution
|
||||
│ │ ├── order_types.py # Standardized order type enum (FIX/CCXT-aligned)
|
||||
│ │ ├── selector.py # Regime → strategy mapping + performance matrix
|
||||
│ │ ├── asset_classification.py # Multi-label taxonomy + exchange registry
|
||||
│ │ ├── asset_behavior.py # 10-dimension behavior DSL, research-validated
|
||||
@@ -468,6 +469,7 @@ Re-measurement at correct fees is required for production deployment.
|
||||
| **Policy Registry** | `training/registry.py` | 14 | CANDIDATE → ACTIVE lifecycle |
|
||||
| **Training Pipeline** | `training/pipeline.py` | 21 | Bounded continuous learning loop |
|
||||
| **Strategy DSL v2** | `training/dsl.py` | 69 | 40+ primitives, 40+ sensors, 16 builtins |
|
||||
| **Order Types** | `training/order_types.py` | (new) | FIX/CCXT-aligned, 5-layer taxonomy, cross-exchange mapping |
|
||||
| **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 taxonomy + exchange registry, 13 assets, system-wide store |
|
||||
@@ -1191,6 +1193,52 @@ zero fidelity loss). CMA-ES training speedup is ~1.5x because multiprocessing ov
|
||||
is amortized across 90 scenarios per eval. Bottleneck is planner (MCTS), not CWM —
|
||||
numba already accelerates the CWM hot path (`_HAS_NUMBA = True`).
|
||||
|
||||
### Order Type Standardization (Multi-Exchange, FIX/CCXT-Aligned)
|
||||
|
||||
Normalized order type taxonomy based on **FIX Protocol Tag 40 (OrdType)** as the
|
||||
universal reference, with **CCXT** de facto crypto standard for practical interop.
|
||||
Neither MiFID II nor MiCA defines a standalone order type taxonomy — both defer to FIX.
|
||||
|
||||
**Five-layer hybrid model:**
|
||||
|
||||
| Layer | Standard Source | Types |
|
||||
|-------|----------------|-------|
|
||||
| 1. Base | FIX Tag 40 | `MARKET`, `LIMIT` |
|
||||
| 2. Time-in-force | FIX Tag 59 | `GTC`, `IOC`, `FOK`, `GTD` |
|
||||
| 3. Conditional/Trigger | FIX Tag 3/4 + MIT | `STOP_MARKET`, `STOP_LIMIT`, `TRIGGER_MARKET`, `TRIGGER_LIMIT`, `TRAILING_STOP` |
|
||||
| 4. Instructions | FIX Tag 18 | `POST_ONLY`, `REDUCE_ONLY`, `HIDDEN`, `ICEBERG` |
|
||||
| 5. Compound | Exchange-specific | `OCO`, `TP_SL` |
|
||||
|
||||
#### Cross-Exchange Mapping (BingX ↔ Binance ↔ Bybit)
|
||||
|
||||
| Normalized | BingX | Binance Spot | Binance Futures | Bybit |
|
||||
|-----------|-------|-------------|-----------------|-------|
|
||||
| `LIMIT` | LIMIT | LIMIT | LIMIT | LIMIT |
|
||||
| `MARKET` | MARKET | MARKET | MARKET | MARKET |
|
||||
| `POST_ONLY` | POST_ONLY | LIMIT_MAKER | LIMIT_MAKER | Post-Only |
|
||||
| `IOC` | IOC | IOC | IOC | IOC |
|
||||
| `FOK` | FOK | FOK | FOK | FOK |
|
||||
| `STOP_MARKET` | TRIGGER_MARKET | STOP_MARKET | STOP_MARKET | Stop-Market |
|
||||
| `STOP_LIMIT` | TRIGGER_LIMIT | STOP_LOSS_LIMIT | STOP | Stop-Limit |
|
||||
| `TP_MARKET` | TRIGGER_MARKET | TAKE_PROFIT | TAKE_PROFIT_MARKET | TP-Market |
|
||||
| `TP_LIMIT` | TRIGGER_LIMIT | TAKE_PROFIT_LIMIT | TAKE_PROFIT | TP-Limit |
|
||||
| `TRAILING_STOP` | TRIGGER_MARKET(trail) | (spot only) | TRAILING_STOP_MARKET | Trailing |
|
||||
|
||||
#### Transferability Principle
|
||||
|
||||
Strategy **PARAMETERS** transfer across exchanges. Order type **NAMES** are venue-specific
|
||||
but semantics are identical. A `LIMIT` on BingX = `LIMIT` on Binance = `LIMIT` on Bybit
|
||||
(same fill behavior). Only the API string differs. The venue adapter translates
|
||||
normalized → exchange-native at submission time.
|
||||
|
||||
#### Standards Referenced
|
||||
|
||||
- FIX 4.4: Tag 40 (OrdType), Tag 59 (TimeInForce), Tag 18 (ExecInst)
|
||||
- CCXT: unified `limit`/`market` + parameter composition (triggerPrice, stopPrice)
|
||||
- ISO 10383: MIC for venue identification
|
||||
- MiFID II / MiCA: defers to FIX for order type classification
|
||||
- FIA: references FIX Tag 40 in digital asset guidelines
|
||||
|
||||
### Prod Tooling
|
||||
|
||||
| Component | Purpose | File |
|
||||
|
||||
Reference in New Issue
Block a user