From 455a7a5a4e4209bc37f65a6a02c5c200179993d4 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 14 Jul 2026 14:52:50 +0200 Subject: [PATCH] malkhut(docs): README updated for three-dimensional order type model Updated README to reflect Fable's corrections: - OrderType/TimeInForce/Instructions as three orthogonal dimensions - POST_ONLY/IOC/FOK correctly described as non-types - BingX trailing_stop -> TRAILING_STOP_MARKET - Three mapping tables (order type, TIF, instructions) - Integration status updated --- MALKHUT/README.md | 58 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/MALKHUT/README.md b/MALKHUT/README.md index 70e0f6a..5a99dbe 100644 --- a/MALKHUT/README.md +++ b/MALKHUT/README.md @@ -469,7 +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 | +| **Order Types** | `training/order_types.py` | (new) | Three-dimensional: OrderType × TimeInForce × Instructions (FIX-aligned) | | **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 | @@ -1195,34 +1195,41 @@ 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. +Three **orthogonal dimensions** (not one flat enum), each mapped independently: -**Five-layer hybrid model:** +**Dimension 1 — Order Types (FIX Tag 40 OrdType):** what the order IS +`MARKET`, `LIMIT`, `STOP_MARKET`, `STOP_LIMIT`, `TRIGGER_MARKET`, `TRIGGER_LIMIT`, +`TRAILING_STOP`, `OCO`, `TP_SL` -| 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` | +**Dimension 2 — Time-in-Force (FIX Tag 59):** how long the order LIVES +`GTC`, `IOC`, `FOK`, `GTD` -#### Cross-Exchange Mapping (BingX ↔ Binance ↔ Bybit) +**Dimension 3 — Instructions (FIX Tag 18 ExecInst):** behavioral modifiers +`POST_ONLY`, `REDUCE_ONLY`, `HIDDEN`, `ICEBERG` + +> CRITICAL: `POST_ONLY` is an instruction on a `LIMIT` order, not a standalone type. +> `IOC`/`FOK` are TimeInForce values applied to a `LIMIT` order, not order types. +> This aligns with FIX Protocol: Tag 40 (OrdType), Tag 59 (TimeInForce), Tag 18 (ExecInst). + +#### Cross-Exchange Order Type Mapping | 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 | +| `STOP_MARKET` | TRIGGER_MARKET | STOP_MARKET | STOP_MARKET | STOP_MARKET | +| `STOP_LIMIT` | TRIGGER_LIMIT | STOP_LOSS_LIMIT | STOP | STOP_LIMIT | +| `TRIGGER_MARKET` | TRIGGER_MARKET | TAKE_PROFIT | TAKE_PROFIT | TAKE_PROFIT_MARKET | +| `TRIGGER_LIMIT` | TRIGGER_LIMIT | TAKE_PROFIT_LIMIT | TAKE_PROFIT | TAKE_PROFIT_LIMIT | +| `TRAILING_STOP` | TRAILING_STOP_MARKET | TRAILING_STOP_MARKET | TRAILING_STOP_MARKET | TRAILING_STOP | + +#### TimeInForce Mapping + +| Normalized | BingX | Binance | Bybit | +|-----------|-------|---------|-------| +| `GTC` | GTC | GTC | GTC | +| `IOC` | IOC | IOC | IOC | +| `FOK` | FOK | FOK | FOK | #### Transferability Principle @@ -1231,15 +1238,6 @@ but semantics are identical. A `LIMIT` on BingX = `LIMIT` on Binance = `LIMIT` o (same fill behavior). Only the API string differs. The venue adapter translates normalized → exchange-native at submission time. -#### Integration Status - -- `state.py` OrderType: **17 values** (5-layer taxonomy, backward compatible) -- `order_types.py`: **Standalone standardized taxonomy** with exchange mapping tables -- `ExchangeProfile.available_order_types`: per-venue list of supported normalized types -- `action_menu.py`: uses `OrderType.MARKET`, `OrderType.LIMIT`, `OrderType.POST_ONLY` -- CWM transition: passes `action.order_type` to venue adapter -- Agent/adversary code: check `is_type_available(type, exchange)` before placing - #### Standards Referenced - FIX 4.4: Tag 40 (OrdType), Tag 59 (TimeInForce), Tag 18 (ExecInst)