feat: add Quant OS A-share baseline
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://boat.local/quant60/schemas/broker_snapshot.schema.json",
|
||||
"title": "Quant60 broker snapshot",
|
||||
"description": "A point-in-time broker fact used for pre-trade and reconciliation.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schema_version",
|
||||
"snapshot_id",
|
||||
"signal_as_of",
|
||||
"next_trading_session",
|
||||
"first_executable_window",
|
||||
"observation_as_of",
|
||||
"as_of",
|
||||
"source_time",
|
||||
"broker",
|
||||
"account_hash",
|
||||
"cash",
|
||||
"total_asset",
|
||||
"positions",
|
||||
"open_orders"
|
||||
],
|
||||
"properties": {
|
||||
"schema_version": {
|
||||
"const": "1.0"
|
||||
},
|
||||
"snapshot_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"as_of": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Broker observation completion time. This may be later than the signal close when the snapshot is queried on the next executable session."
|
||||
},
|
||||
"observation_as_of": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Explicit observation-clock alias for as_of. Account-bound decision paths require the two instants to be equal."
|
||||
},
|
||||
"signal_as_of": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Required completed signal-close clock this snapshot is intended to bind."
|
||||
},
|
||||
"next_trading_session": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "The unique adjacent trading session from the verified decision calendar."
|
||||
},
|
||||
"first_executable_window": {
|
||||
"$ref": "#/$defs/first_executable_window"
|
||||
},
|
||||
"broker": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"account_hash": {
|
||||
"type": "string",
|
||||
"minLength": 8,
|
||||
"description": "One-way account identifier; never store the raw account number."
|
||||
},
|
||||
"cash": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"total_asset": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"market_value": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"positions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/position"
|
||||
}
|
||||
},
|
||||
"open_orders": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/open_order"
|
||||
}
|
||||
},
|
||||
"source_time": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "Timestamp assigned to the broker facts; it must not predate the bound signal and must remain fresh relative to the observation clock."
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"first_executable_window": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"session",
|
||||
"timezone",
|
||||
"start",
|
||||
"end",
|
||||
"boundary",
|
||||
"purpose"
|
||||
],
|
||||
"properties": {
|
||||
"session": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"timezone": {
|
||||
"const": "Asia/Shanghai"
|
||||
},
|
||||
"start": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"end": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"boundary": {
|
||||
"const": "[start,end)"
|
||||
},
|
||||
"purpose": {
|
||||
"const": "PRE_OPEN_BROKER_OBSERVATION"
|
||||
}
|
||||
}
|
||||
},
|
||||
"canonical_symbol": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{6}\\.(XSHG|XSHE|XBSE)$"
|
||||
},
|
||||
"position": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"symbol",
|
||||
"quantity",
|
||||
"sellable_quantity"
|
||||
],
|
||||
"properties": {
|
||||
"symbol": {
|
||||
"$ref": "#/$defs/canonical_symbol"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"sellable_quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"average_cost": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"minimum": 0
|
||||
},
|
||||
"market_value": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"open_order": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"order_id",
|
||||
"broker_order_id",
|
||||
"symbol",
|
||||
"side",
|
||||
"quantity",
|
||||
"filled_quantity",
|
||||
"status",
|
||||
"limit_price",
|
||||
"order_type",
|
||||
"time_in_force"
|
||||
],
|
||||
"properties": {
|
||||
"order_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"broker_order_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"symbol": {
|
||||
"$ref": "#/$defs/canonical_symbol"
|
||||
},
|
||||
"side": {
|
||||
"enum": [
|
||||
"BUY",
|
||||
"SELL"
|
||||
]
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"filled_quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"status": {
|
||||
"enum": [
|
||||
"NEW",
|
||||
"ACCEPTED",
|
||||
"PARTIALLY_FILLED",
|
||||
"CANCEL_PENDING",
|
||||
"UNKNOWN"
|
||||
]
|
||||
},
|
||||
"limit_price": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"order_type": {
|
||||
"const": "LIMIT"
|
||||
},
|
||||
"time_in_force": {
|
||||
"const": "DAY"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://boat.local/quant60/schemas/order_event.schema.json",
|
||||
"title": "Quant60 normalized ledger replay event",
|
||||
"description": "Canonical JSON envelope consumed by LedgerProjector for ORDER_STATUS and FILL events. It is the LedgerRecord.as_dict shape emitted by SimBroker; previous_hash and hash are optional only for explicitly ordered, unhashed replay fixtures.",
|
||||
"$comment": "The canonical payload names are quantity and filled_quantity. Python compatibility aliases accepted by LedgerProjector are intentionally not part of this wire contract.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"sequence",
|
||||
"timestamp",
|
||||
"event_id",
|
||||
"event_type",
|
||||
"payload"
|
||||
],
|
||||
"properties": {
|
||||
"sequence": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"event_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"event_type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ORDER_STATUS",
|
||||
"FILL"
|
||||
]
|
||||
},
|
||||
"payload": {
|
||||
"type": "object"
|
||||
},
|
||||
"previous_hash": {
|
||||
"$ref": "#/$defs/sha256"
|
||||
},
|
||||
"hash": {
|
||||
"$ref": "#/$defs/sha256"
|
||||
}
|
||||
},
|
||||
"dependentRequired": {
|
||||
"previous_hash": [
|
||||
"hash"
|
||||
],
|
||||
"hash": [
|
||||
"previous_hash"
|
||||
]
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"title": "ORDER_STATUS ledger envelope",
|
||||
"required": [
|
||||
"event_type",
|
||||
"payload"
|
||||
],
|
||||
"properties": {
|
||||
"event_type": {
|
||||
"const": "ORDER_STATUS"
|
||||
},
|
||||
"payload": {
|
||||
"$ref": "#/$defs/order_status_payload"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "FILL ledger envelope",
|
||||
"required": [
|
||||
"event_type",
|
||||
"payload"
|
||||
],
|
||||
"properties": {
|
||||
"event_type": {
|
||||
"const": "FILL"
|
||||
},
|
||||
"payload": {
|
||||
"$ref": "#/$defs/fill_payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$defs": {
|
||||
"sha256": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9a-f]{64}$"
|
||||
},
|
||||
"canonical_symbol": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{6}\\.(XSHG|XSHE|XBSE)$"
|
||||
},
|
||||
"side": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"BUY",
|
||||
"SELL"
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"NEW",
|
||||
"ACCEPTED",
|
||||
"PARTIALLY_FILLED",
|
||||
"FILLED",
|
||||
"CANCEL_PENDING",
|
||||
"CANCELLED",
|
||||
"REJECTED",
|
||||
"UNKNOWN"
|
||||
]
|
||||
},
|
||||
"decimal": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"nonnegative_decimal": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"positive_decimal": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^(?:[1-9][0-9]*(?:\\.[0-9]+)?|0\\.[0-9]*[1-9][0-9]*)$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"order_status_payload": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"order_id",
|
||||
"symbol",
|
||||
"side",
|
||||
"quantity",
|
||||
"filled_quantity",
|
||||
"status"
|
||||
],
|
||||
"properties": {
|
||||
"order_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"broker_order_id": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"symbol": {
|
||||
"$ref": "#/$defs/canonical_symbol"
|
||||
},
|
||||
"side": {
|
||||
"$ref": "#/$defs/side"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"filled_quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"average_fill_price": {
|
||||
"$ref": "#/$defs/nonnegative_decimal"
|
||||
},
|
||||
"status": {
|
||||
"$ref": "#/$defs/status"
|
||||
},
|
||||
"reason": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"submitted_at": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fill_payload": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"fill_id",
|
||||
"order_id",
|
||||
"symbol",
|
||||
"side",
|
||||
"quantity",
|
||||
"price"
|
||||
],
|
||||
"properties": {
|
||||
"fill_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"order_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"trading_date": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"symbol": {
|
||||
"$ref": "#/$defs/canonical_symbol"
|
||||
},
|
||||
"side": {
|
||||
"$ref": "#/$defs/side"
|
||||
},
|
||||
"quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"price": {
|
||||
"$ref": "#/$defs/positive_decimal"
|
||||
},
|
||||
"commission": {
|
||||
"$ref": "#/$defs/nonnegative_decimal"
|
||||
},
|
||||
"stamp_duty": {
|
||||
"$ref": "#/$defs/nonnegative_decimal"
|
||||
},
|
||||
"transfer_fee": {
|
||||
"$ref": "#/$defs/nonnegative_decimal"
|
||||
},
|
||||
"cash_delta": {
|
||||
"$ref": "#/$defs/decimal"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://boat.local/quant60/schemas/signal.schema.json",
|
||||
"title": "Quant60 signal record",
|
||||
"description": "A point-in-time model output. It is not a target position or an order.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schema_version",
|
||||
"run_id",
|
||||
"signal_id",
|
||||
"as_of",
|
||||
"symbol",
|
||||
"horizon_trading_days",
|
||||
"score",
|
||||
"model_version",
|
||||
"data_version"
|
||||
],
|
||||
"properties": {
|
||||
"schema_version": {
|
||||
"const": "1.0"
|
||||
},
|
||||
"run_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"signal_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"as_of": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"symbol": {
|
||||
"$ref": "#/$defs/canonical_symbol"
|
||||
},
|
||||
"horizon_trading_days": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"score": {
|
||||
"type": "number"
|
||||
},
|
||||
"expected_excess_return": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"confidence": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
],
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"model_version": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"data_version": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"feature_version": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"canonical_symbol": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{6}\\.(XSHG|XSHE|XBSE)$",
|
||||
"examples": [
|
||||
"600000.XSHG",
|
||||
"000001.XSHE",
|
||||
"830799.XBSE"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://boat.local/quant60/schemas/target.schema.json",
|
||||
"title": "Quant60 target-position record",
|
||||
"description": "A portfolio decision produced from signals. It is not proof of an order or fill.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schema_version",
|
||||
"run_id",
|
||||
"decision_id",
|
||||
"as_of",
|
||||
"symbol",
|
||||
"target_weight",
|
||||
"target_quantity",
|
||||
"config_hash"
|
||||
],
|
||||
"properties": {
|
||||
"schema_version": {
|
||||
"const": "1.0"
|
||||
},
|
||||
"run_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"decision_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"as_of": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"symbol": {
|
||||
"$ref": "#/$defs/canonical_symbol"
|
||||
},
|
||||
"target_weight": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"target_quantity": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"lot_size": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"default": 100
|
||||
},
|
||||
"signal_id": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"constraint_state": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"FEASIBLE",
|
||||
"REPAIRED",
|
||||
"RISK_REDUCTION_ONLY",
|
||||
"NO_TRADE"
|
||||
]
|
||||
},
|
||||
"config_hash": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"canonical_symbol": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]{6}\\.(XSHG|XSHE|XBSE)$"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user