onesecondtrader 0.55.0__py3-none-any.whl → 0.56.0__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.
- onesecondtrader/orchestrator/__init__.py +8 -0
- onesecondtrader/orchestrator/orchestrator.py +161 -0
- onesecondtrader/orchestrator/run_recorder.py +759 -0
- onesecondtrader/orchestrator/runs_schema.sql +500 -0
- {onesecondtrader-0.55.0.dist-info → onesecondtrader-0.56.0.dist-info}/METADATA +1 -1
- {onesecondtrader-0.55.0.dist-info → onesecondtrader-0.56.0.dist-info}/RECORD +8 -4
- {onesecondtrader-0.55.0.dist-info → onesecondtrader-0.56.0.dist-info}/WHEEL +0 -0
- {onesecondtrader-0.55.0.dist-info → onesecondtrader-0.56.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
-- Runs database schema.
|
|
2
|
+
--
|
|
3
|
+
-- The schema stores metadata about trading system runs and all events that occurred during each run.
|
|
4
|
+
-- Events are recorded by a runs_recorder subscriber listening to the event_bus.
|
|
5
|
+
-- Each event type has a dedicated table with typed columns for efficient querying and charting.
|
|
6
|
+
--
|
|
7
|
+
-- | Table | Description |
|
|
8
|
+
-- |----------------------------|----------------------------------------------------------------|
|
|
9
|
+
-- | `runs` | Registry of trading system runs with metadata. |
|
|
10
|
+
-- | `bars` | Market data bars (BarReceived events). |
|
|
11
|
+
-- | `bars_processed` | Processed bars with indicator values (BarProcessed events). |
|
|
12
|
+
-- | `order_submissions` | Order submission requests. |
|
|
13
|
+
-- | `order_cancellations` | Order cancellation requests. |
|
|
14
|
+
-- | `order_modifications` | Order modification requests. |
|
|
15
|
+
-- | `orders_accepted` | Broker order acceptance responses. |
|
|
16
|
+
-- | `orders_rejected` | Broker order rejection responses. |
|
|
17
|
+
-- | `cancellations_accepted` | Broker cancellation acceptance responses. |
|
|
18
|
+
-- | `cancellations_rejected` | Broker cancellation rejection responses. |
|
|
19
|
+
-- | `modifications_accepted` | Broker modification acceptance responses. |
|
|
20
|
+
-- | `modifications_rejected` | Broker modification rejection responses. |
|
|
21
|
+
-- | `fills` | Trade execution fill events. |
|
|
22
|
+
-- | `expirations` | Order expiration events. |
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
-- Registry of trading system runs.
|
|
27
|
+
--
|
|
28
|
+
-- Each row represents a single execution of the trading system, whether a backtest or live session.
|
|
29
|
+
-- A run is uniquely identified by `run_id` which is a UUID assigned at run creation.
|
|
30
|
+
-- The `config` and `metadata` fields store JSON-encoded data for flexibility.
|
|
31
|
+
--
|
|
32
|
+
-- | Field | Type | Constraints | Description |
|
|
33
|
+
-- |------------|-----------|----------------------------------------------------------|------------------------------------------------------------------------------------------|
|
|
34
|
+
-- | `run_id` | `TEXT` | `PRIMARY KEY` | Unique identifier for the run (UUID string). |
|
|
35
|
+
-- | `name` | `TEXT` | `NOT NULL` | Human-readable name or label for the run. |
|
|
36
|
+
-- | `ts_start` | `INTEGER` | `NOT NULL` | Start time of the run as nanoseconds since the UTC Unix epoch. |
|
|
37
|
+
-- | `ts_end` | `INTEGER` | | End time of the run as nanoseconds since the UTC Unix epoch; NULL if still in progress. |
|
|
38
|
+
-- | `status` | `TEXT` | `NOT NULL`, `CHECK IN ('running','completed','failed','cancelled')` | Current status of the run. |
|
|
39
|
+
-- | `config` | `TEXT` | | JSON-encoded configuration used for the run. |
|
|
40
|
+
-- | `metadata` | `TEXT` | | JSON-encoded additional metadata about the run. |
|
|
41
|
+
--
|
|
42
|
+
CREATE TABLE runs (
|
|
43
|
+
run_id TEXT PRIMARY KEY,
|
|
44
|
+
name TEXT NOT NULL,
|
|
45
|
+
ts_start INTEGER NOT NULL,
|
|
46
|
+
ts_end INTEGER,
|
|
47
|
+
status TEXT NOT NULL CHECK(status IN ('running', 'completed', 'failed', 'cancelled')),
|
|
48
|
+
config TEXT,
|
|
49
|
+
metadata TEXT
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
-- Stores market data bars received during a run.
|
|
54
|
+
--
|
|
55
|
+
-- Each row represents a BarReceived event captured from the event bus.
|
|
56
|
+
-- Bars are time-aggregated OHLCV data from a market data source or resampling process.
|
|
57
|
+
--
|
|
58
|
+
-- | Field | Type | Constraints | Description |
|
|
59
|
+
-- |---------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
60
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the bar record. |
|
|
61
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this bar belongs to. |
|
|
62
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the bar was observed by the system, as nanoseconds since UTC Unix epoch. |
|
|
63
|
+
-- | `ts_created_ns`| `INTEGER`| `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
64
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
65
|
+
-- | `bar_period` | `TEXT` | `NOT NULL` | Time interval represented by the bar (e.g. 'SECOND', 'MINUTE', 'HOUR', 'DAY'). |
|
|
66
|
+
-- | `open` | `REAL` | `NOT NULL` | Opening price of the bar period. |
|
|
67
|
+
-- | `high` | `REAL` | `NOT NULL` | Highest traded price during the bar period. |
|
|
68
|
+
-- | `low` | `REAL` | `NOT NULL` | Lowest traded price during the bar period. |
|
|
69
|
+
-- | `close` | `REAL` | `NOT NULL` | Closing price of the bar period. |
|
|
70
|
+
-- | `volume` | `INTEGER` | | Traded volume during the bar period; may be NULL if not available. |
|
|
71
|
+
--
|
|
72
|
+
CREATE TABLE bars (
|
|
73
|
+
id INTEGER PRIMARY KEY,
|
|
74
|
+
run_id TEXT NOT NULL,
|
|
75
|
+
ts_event_ns INTEGER NOT NULL,
|
|
76
|
+
ts_created_ns INTEGER NOT NULL,
|
|
77
|
+
symbol TEXT NOT NULL,
|
|
78
|
+
bar_period TEXT NOT NULL,
|
|
79
|
+
open REAL NOT NULL,
|
|
80
|
+
high REAL NOT NULL,
|
|
81
|
+
low REAL NOT NULL,
|
|
82
|
+
close REAL NOT NULL,
|
|
83
|
+
volume INTEGER,
|
|
84
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
CREATE INDEX idx_bars_run_symbol_ts ON bars(run_id, symbol, ts_event_ns);
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
-- Stores processed market data bars with computed indicator values.
|
|
91
|
+
--
|
|
92
|
+
-- Each row represents a BarProcessed event captured from the event bus.
|
|
93
|
+
-- This extends BarReceived by attaching indicator values derived from the bar data.
|
|
94
|
+
--
|
|
95
|
+
-- | Field | Type | Constraints | Description |
|
|
96
|
+
-- |---------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
97
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the bar record. |
|
|
98
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this bar belongs to. |
|
|
99
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the bar was observed by the system, as nanoseconds since UTC Unix epoch. |
|
|
100
|
+
-- | `ts_created_ns`| `INTEGER`| `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
101
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
102
|
+
-- | `bar_period` | `TEXT` | `NOT NULL` | Time interval represented by the bar (e.g. 'SECOND', 'MINUTE', 'HOUR', 'DAY'). |
|
|
103
|
+
-- | `open` | `REAL` | `NOT NULL` | Opening price of the bar period. |
|
|
104
|
+
-- | `high` | `REAL` | `NOT NULL` | Highest traded price during the bar period. |
|
|
105
|
+
-- | `low` | `REAL` | `NOT NULL` | Lowest traded price during the bar period. |
|
|
106
|
+
-- | `close` | `REAL` | `NOT NULL` | Closing price of the bar period. |
|
|
107
|
+
-- | `volume` | `INTEGER` | | Traded volume during the bar period; may be NULL if not available. |
|
|
108
|
+
-- | `indicators` | `TEXT` | `NOT NULL` | JSON-encoded mapping of indicator names to computed values. |
|
|
109
|
+
--
|
|
110
|
+
CREATE TABLE bars_processed (
|
|
111
|
+
id INTEGER PRIMARY KEY,
|
|
112
|
+
run_id TEXT NOT NULL,
|
|
113
|
+
ts_event_ns INTEGER NOT NULL,
|
|
114
|
+
ts_created_ns INTEGER NOT NULL,
|
|
115
|
+
symbol TEXT NOT NULL,
|
|
116
|
+
bar_period TEXT NOT NULL,
|
|
117
|
+
open REAL NOT NULL,
|
|
118
|
+
high REAL NOT NULL,
|
|
119
|
+
low REAL NOT NULL,
|
|
120
|
+
close REAL NOT NULL,
|
|
121
|
+
volume INTEGER,
|
|
122
|
+
indicators TEXT NOT NULL,
|
|
123
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
CREATE INDEX idx_bars_processed_run_symbol_ts ON bars_processed(run_id, symbol, ts_event_ns);
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
-- Stores order submission requests issued by strategies.
|
|
130
|
+
--
|
|
131
|
+
-- Each row represents an OrderSubmissionRequest event captured from the event bus.
|
|
132
|
+
-- This records the intent to submit a new order to the broker.
|
|
133
|
+
--
|
|
134
|
+
-- | Field | Type | Constraints | Description |
|
|
135
|
+
-- |------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
136
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
137
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
138
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the request was issued, as nanoseconds since UTC Unix epoch. |
|
|
139
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
140
|
+
-- | `system_order_id`| `TEXT` | `NOT NULL` | System-assigned unique identifier for the order (UUID string). |
|
|
141
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
142
|
+
-- | `order_type` | `TEXT` | `NOT NULL` | Execution constraint of the order (e.g. 'MARKET', 'LIMIT', 'STOP', 'STOP_LIMIT'). |
|
|
143
|
+
-- | `side` | `TEXT` | `NOT NULL` | Direction of the trade (e.g. 'BUY', 'SELL'). |
|
|
144
|
+
-- | `quantity` | `REAL` | `NOT NULL` | Requested order quantity. |
|
|
145
|
+
-- | `limit_price` | `REAL` | | Limit price, if applicable to the order type. |
|
|
146
|
+
-- | `stop_price` | `REAL` | | Stop price, if applicable to the order type. |
|
|
147
|
+
-- | `action` | `TEXT` | | Intent of the order from the strategy's perspective (e.g. 'ENTRY', 'EXIT'). |
|
|
148
|
+
-- | `signal` | `TEXT` | | Optional signal name or identifier that triggered this order. |
|
|
149
|
+
--
|
|
150
|
+
CREATE TABLE order_submissions (
|
|
151
|
+
id INTEGER PRIMARY KEY,
|
|
152
|
+
run_id TEXT NOT NULL,
|
|
153
|
+
ts_event_ns INTEGER NOT NULL,
|
|
154
|
+
ts_created_ns INTEGER NOT NULL,
|
|
155
|
+
system_order_id TEXT NOT NULL,
|
|
156
|
+
symbol TEXT NOT NULL,
|
|
157
|
+
order_type TEXT NOT NULL,
|
|
158
|
+
side TEXT NOT NULL,
|
|
159
|
+
quantity REAL NOT NULL,
|
|
160
|
+
limit_price REAL,
|
|
161
|
+
stop_price REAL,
|
|
162
|
+
action TEXT,
|
|
163
|
+
signal TEXT,
|
|
164
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
CREATE INDEX idx_order_submissions_run_ts ON order_submissions(run_id, ts_event_ns);
|
|
168
|
+
CREATE INDEX idx_order_submissions_order_id ON order_submissions(system_order_id);
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
-- Stores order cancellation requests issued by strategies.
|
|
172
|
+
--
|
|
173
|
+
-- Each row represents an OrderCancellationRequest event captured from the event bus.
|
|
174
|
+
-- This records the intent to cancel an existing order.
|
|
175
|
+
--
|
|
176
|
+
-- | Field | Type | Constraints | Description |
|
|
177
|
+
-- |------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
178
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
179
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
180
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the request was issued, as nanoseconds since UTC Unix epoch. |
|
|
181
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
182
|
+
-- | `system_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the order to be cancelled (UUID string). |
|
|
183
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
184
|
+
--
|
|
185
|
+
CREATE TABLE order_cancellations (
|
|
186
|
+
id INTEGER PRIMARY KEY,
|
|
187
|
+
run_id TEXT NOT NULL,
|
|
188
|
+
ts_event_ns INTEGER NOT NULL,
|
|
189
|
+
ts_created_ns INTEGER NOT NULL,
|
|
190
|
+
system_order_id TEXT NOT NULL,
|
|
191
|
+
symbol TEXT NOT NULL,
|
|
192
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
CREATE INDEX idx_order_cancellations_run_ts ON order_cancellations(run_id, ts_event_ns);
|
|
196
|
+
CREATE INDEX idx_order_cancellations_order_id ON order_cancellations(system_order_id);
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
-- Stores order modification requests issued by strategies.
|
|
200
|
+
--
|
|
201
|
+
-- Each row represents an OrderModificationRequest event captured from the event bus.
|
|
202
|
+
-- This records the intent to modify an existing order's parameters.
|
|
203
|
+
--
|
|
204
|
+
-- | Field | Type | Constraints | Description |
|
|
205
|
+
-- |------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
206
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
207
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
208
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the request was issued, as nanoseconds since UTC Unix epoch. |
|
|
209
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
210
|
+
-- | `system_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the order to be modified (UUID string). |
|
|
211
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
212
|
+
-- | `quantity` | `REAL` | | Updated order quantity, if modified. |
|
|
213
|
+
-- | `limit_price` | `REAL` | | Updated limit price, if modified. |
|
|
214
|
+
-- | `stop_price` | `REAL` | | Updated stop price, if modified. |
|
|
215
|
+
--
|
|
216
|
+
CREATE TABLE order_modifications (
|
|
217
|
+
id INTEGER PRIMARY KEY,
|
|
218
|
+
run_id TEXT NOT NULL,
|
|
219
|
+
ts_event_ns INTEGER NOT NULL,
|
|
220
|
+
ts_created_ns INTEGER NOT NULL,
|
|
221
|
+
system_order_id TEXT NOT NULL,
|
|
222
|
+
symbol TEXT NOT NULL,
|
|
223
|
+
quantity REAL,
|
|
224
|
+
limit_price REAL,
|
|
225
|
+
stop_price REAL,
|
|
226
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
CREATE INDEX idx_order_modifications_run_ts ON order_modifications(run_id, ts_event_ns);
|
|
230
|
+
CREATE INDEX idx_order_modifications_order_id ON order_modifications(system_order_id);
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
-- Stores broker order acceptance responses.
|
|
234
|
+
--
|
|
235
|
+
-- Each row represents an OrderAccepted event captured from the event bus.
|
|
236
|
+
-- This indicates that an order has been accepted by the broker and is active at the execution venue.
|
|
237
|
+
--
|
|
238
|
+
-- | Field | Type | Constraints | Description |
|
|
239
|
+
-- |---------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
240
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
241
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
242
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the acceptance was observed by the system, as nanoseconds since UTC epoch. |
|
|
243
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
244
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the acceptance, as nanoseconds since UTC Unix epoch. |
|
|
245
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the accepted order (UUID string). |
|
|
246
|
+
-- | `broker_order_id` | `TEXT` | | Broker-assigned identifier of the accepted order, if reported. |
|
|
247
|
+
--
|
|
248
|
+
CREATE TABLE orders_accepted (
|
|
249
|
+
id INTEGER PRIMARY KEY,
|
|
250
|
+
run_id TEXT NOT NULL,
|
|
251
|
+
ts_event_ns INTEGER NOT NULL,
|
|
252
|
+
ts_created_ns INTEGER NOT NULL,
|
|
253
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
254
|
+
associated_order_id TEXT NOT NULL,
|
|
255
|
+
broker_order_id TEXT,
|
|
256
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
CREATE INDEX idx_orders_accepted_run_ts ON orders_accepted(run_id, ts_event_ns);
|
|
260
|
+
CREATE INDEX idx_orders_accepted_order_id ON orders_accepted(associated_order_id);
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
-- Stores broker order rejection responses.
|
|
264
|
+
--
|
|
265
|
+
-- Each row represents an OrderRejected event captured from the event bus.
|
|
266
|
+
-- This indicates that an order has been rejected by the broker.
|
|
267
|
+
--
|
|
268
|
+
-- | Field | Type | Constraints | Description |
|
|
269
|
+
-- |---------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
270
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
271
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
272
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the rejection was observed by the system, as nanoseconds since UTC epoch. |
|
|
273
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
274
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the rejection, as nanoseconds since UTC Unix epoch. |
|
|
275
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the rejected order (UUID string). |
|
|
276
|
+
-- | `rejection_reason` | `TEXT` | `NOT NULL` | Canonical classification of the rejection cause (e.g. 'INSUFFICIENT_FUNDS'). |
|
|
277
|
+
-- | `rejection_message` | `TEXT` | `NOT NULL` | Human-readable explanation provided by the broker. |
|
|
278
|
+
--
|
|
279
|
+
CREATE TABLE orders_rejected (
|
|
280
|
+
id INTEGER PRIMARY KEY,
|
|
281
|
+
run_id TEXT NOT NULL,
|
|
282
|
+
ts_event_ns INTEGER NOT NULL,
|
|
283
|
+
ts_created_ns INTEGER NOT NULL,
|
|
284
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
285
|
+
associated_order_id TEXT NOT NULL,
|
|
286
|
+
rejection_reason TEXT NOT NULL,
|
|
287
|
+
rejection_message TEXT NOT NULL,
|
|
288
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
CREATE INDEX idx_orders_rejected_run_ts ON orders_rejected(run_id, ts_event_ns);
|
|
292
|
+
CREATE INDEX idx_orders_rejected_order_id ON orders_rejected(associated_order_id);
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
-- Stores broker cancellation acceptance responses.
|
|
296
|
+
--
|
|
297
|
+
-- Each row represents a CancellationAccepted event captured from the event bus.
|
|
298
|
+
-- This indicates that an order cancellation has been acknowledged and the order is no longer active.
|
|
299
|
+
--
|
|
300
|
+
-- | Field | Type | Constraints | Description |
|
|
301
|
+
-- |---------------------|-----------|------------------|--------------------------------------------------------------------------------------------|
|
|
302
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
303
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
304
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the cancellation was observed by the system, as nanoseconds since UTC epoch. |
|
|
305
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
306
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the cancellation, as nanoseconds since UTC Unix epoch. |
|
|
307
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the cancelled order (UUID string). |
|
|
308
|
+
-- | `broker_order_id` | `TEXT` | | Broker-assigned identifier of the cancelled order, if reported. |
|
|
309
|
+
--
|
|
310
|
+
CREATE TABLE cancellations_accepted (
|
|
311
|
+
id INTEGER PRIMARY KEY,
|
|
312
|
+
run_id TEXT NOT NULL,
|
|
313
|
+
ts_event_ns INTEGER NOT NULL,
|
|
314
|
+
ts_created_ns INTEGER NOT NULL,
|
|
315
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
316
|
+
associated_order_id TEXT NOT NULL,
|
|
317
|
+
broker_order_id TEXT,
|
|
318
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
CREATE INDEX idx_cancellations_accepted_run_ts ON cancellations_accepted(run_id, ts_event_ns);
|
|
322
|
+
CREATE INDEX idx_cancellations_accepted_order_id ON cancellations_accepted(associated_order_id);
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
-- Stores broker cancellation rejection responses.
|
|
326
|
+
--
|
|
327
|
+
-- Each row represents a CancellationRejected event captured from the event bus.
|
|
328
|
+
-- This indicates that an order cancellation request has been rejected by the broker.
|
|
329
|
+
--
|
|
330
|
+
-- | Field | Type | Constraints | Description |
|
|
331
|
+
-- |---------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
332
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
333
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
334
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the rejection was observed by the system, as nanoseconds since UTC epoch. |
|
|
335
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
336
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the rejection, as nanoseconds since UTC Unix epoch. |
|
|
337
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the order associated with the rejected cancellation. |
|
|
338
|
+
-- | `rejection_reason` | `TEXT` | `NOT NULL` | Canonical classification of the cancellation rejection cause. |
|
|
339
|
+
-- | `rejection_message` | `TEXT` | `NOT NULL` | Human-readable explanation provided by the broker. |
|
|
340
|
+
--
|
|
341
|
+
CREATE TABLE cancellations_rejected (
|
|
342
|
+
id INTEGER PRIMARY KEY,
|
|
343
|
+
run_id TEXT NOT NULL,
|
|
344
|
+
ts_event_ns INTEGER NOT NULL,
|
|
345
|
+
ts_created_ns INTEGER NOT NULL,
|
|
346
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
347
|
+
associated_order_id TEXT NOT NULL,
|
|
348
|
+
rejection_reason TEXT NOT NULL,
|
|
349
|
+
rejection_message TEXT NOT NULL,
|
|
350
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
CREATE INDEX idx_cancellations_rejected_run_ts ON cancellations_rejected(run_id, ts_event_ns);
|
|
354
|
+
CREATE INDEX idx_cancellations_rejected_order_id ON cancellations_rejected(associated_order_id);
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
-- Stores broker modification acceptance responses.
|
|
358
|
+
--
|
|
359
|
+
-- Each row represents a ModificationAccepted event captured from the event bus.
|
|
360
|
+
-- This indicates that an order modification has been acknowledged and the updated parameters are active.
|
|
361
|
+
--
|
|
362
|
+
-- | Field | Type | Constraints | Description |
|
|
363
|
+
-- |---------------------|-----------|------------------|----------------------------------------------------------------------------------------------|
|
|
364
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
365
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
366
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the acceptance was observed by the system, as nanoseconds since UTC epoch. |
|
|
367
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
368
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the modification acceptance, as nanoseconds since UTC epoch. |
|
|
369
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the modified order (UUID string). |
|
|
370
|
+
-- | `broker_order_id` | `TEXT` | | Broker-assigned identifier of the order after modification, if reported. |
|
|
371
|
+
--
|
|
372
|
+
CREATE TABLE modifications_accepted (
|
|
373
|
+
id INTEGER PRIMARY KEY,
|
|
374
|
+
run_id TEXT NOT NULL,
|
|
375
|
+
ts_event_ns INTEGER NOT NULL,
|
|
376
|
+
ts_created_ns INTEGER NOT NULL,
|
|
377
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
378
|
+
associated_order_id TEXT NOT NULL,
|
|
379
|
+
broker_order_id TEXT,
|
|
380
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
CREATE INDEX idx_modifications_accepted_run_ts ON modifications_accepted(run_id, ts_event_ns);
|
|
384
|
+
CREATE INDEX idx_modifications_accepted_order_id ON modifications_accepted(associated_order_id);
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
-- Stores broker modification rejection responses.
|
|
388
|
+
--
|
|
389
|
+
-- Each row represents a ModificationRejected event captured from the event bus.
|
|
390
|
+
-- This indicates that an order modification request has been rejected by the broker.
|
|
391
|
+
--
|
|
392
|
+
-- | Field | Type | Constraints | Description |
|
|
393
|
+
-- |---------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
394
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
395
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
396
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the rejection was observed by the system, as nanoseconds since UTC epoch. |
|
|
397
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
398
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the rejection, as nanoseconds since UTC Unix epoch. |
|
|
399
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the order associated with the rejected modification. |
|
|
400
|
+
-- | `rejection_reason` | `TEXT` | `NOT NULL` | Canonical classification of the modification rejection cause. |
|
|
401
|
+
-- | `rejection_message` | `TEXT` | `NOT NULL` | Human-readable explanation provided by the broker. |
|
|
402
|
+
--
|
|
403
|
+
CREATE TABLE modifications_rejected (
|
|
404
|
+
id INTEGER PRIMARY KEY,
|
|
405
|
+
run_id TEXT NOT NULL,
|
|
406
|
+
ts_event_ns INTEGER NOT NULL,
|
|
407
|
+
ts_created_ns INTEGER NOT NULL,
|
|
408
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
409
|
+
associated_order_id TEXT NOT NULL,
|
|
410
|
+
rejection_reason TEXT NOT NULL,
|
|
411
|
+
rejection_message TEXT NOT NULL,
|
|
412
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
CREATE INDEX idx_modifications_rejected_run_ts ON modifications_rejected(run_id, ts_event_ns);
|
|
416
|
+
CREATE INDEX idx_modifications_rejected_order_id ON modifications_rejected(associated_order_id);
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
-- Stores trade execution fill events.
|
|
420
|
+
--
|
|
421
|
+
-- Each row represents a FillEvent captured from the event bus.
|
|
422
|
+
-- A fill records the execution of a quantity of an order at a specific price.
|
|
423
|
+
-- Multiple fills may be associated with the same order in the case of partial execution.
|
|
424
|
+
--
|
|
425
|
+
-- | Field | Type | Constraints | Description |
|
|
426
|
+
-- |---------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
427
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
428
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
429
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the fill was observed by the system, as nanoseconds since UTC epoch. |
|
|
430
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
431
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the fill, as nanoseconds since UTC Unix epoch. |
|
|
432
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the order associated with the fill (UUID string). |
|
|
433
|
+
-- | `broker_order_id` | `TEXT` | | Broker-assigned identifier of the order, if available. |
|
|
434
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
435
|
+
-- | `fill_id` | `TEXT` | `NOT NULL` | System-assigned unique identifier of the fill event (UUID string). |
|
|
436
|
+
-- | `broker_fill_id` | `TEXT` | | Broker-assigned identifier of the execution record, if available. |
|
|
437
|
+
-- | `side` | `TEXT` | `NOT NULL` | Trade direction of the executed quantity (e.g. 'BUY', 'SELL'). |
|
|
438
|
+
-- | `quantity_filled` | `REAL` | `NOT NULL` | Quantity executed in this fill. |
|
|
439
|
+
-- | `fill_price` | `REAL` | `NOT NULL` | Execution price of the fill. |
|
|
440
|
+
-- | `commission` | `REAL` | `NOT NULL` | Commission or fee associated with the fill. |
|
|
441
|
+
-- | `exchange` | `TEXT` | `NOT NULL` | Identifier of the execution venue. |
|
|
442
|
+
--
|
|
443
|
+
CREATE TABLE fills (
|
|
444
|
+
id INTEGER PRIMARY KEY,
|
|
445
|
+
run_id TEXT NOT NULL,
|
|
446
|
+
ts_event_ns INTEGER NOT NULL,
|
|
447
|
+
ts_created_ns INTEGER NOT NULL,
|
|
448
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
449
|
+
associated_order_id TEXT NOT NULL,
|
|
450
|
+
broker_order_id TEXT,
|
|
451
|
+
symbol TEXT NOT NULL,
|
|
452
|
+
fill_id TEXT NOT NULL,
|
|
453
|
+
broker_fill_id TEXT,
|
|
454
|
+
side TEXT NOT NULL,
|
|
455
|
+
quantity_filled REAL NOT NULL,
|
|
456
|
+
fill_price REAL NOT NULL,
|
|
457
|
+
commission REAL NOT NULL,
|
|
458
|
+
exchange TEXT NOT NULL,
|
|
459
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
CREATE INDEX idx_fills_run_ts ON fills(run_id, ts_event_ns);
|
|
463
|
+
CREATE INDEX idx_fills_run_symbol_ts ON fills(run_id, symbol, ts_event_ns);
|
|
464
|
+
CREATE INDEX idx_fills_order_id ON fills(associated_order_id);
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
-- Stores order expiration events.
|
|
468
|
+
--
|
|
469
|
+
-- Each row represents an OrderExpired event captured from the event bus.
|
|
470
|
+
-- This indicates that an order is no longer active due to expiration according to broker or venue rules
|
|
471
|
+
-- (e.g. time-in-force constraints).
|
|
472
|
+
--
|
|
473
|
+
-- | Field | Type | Constraints | Description |
|
|
474
|
+
-- |---------------------|-----------|------------------|------------------------------------------------------------------------------------------|
|
|
475
|
+
-- | `id` | `INTEGER` | `PRIMARY KEY` | Auto-incrementing surrogate key for the record. |
|
|
476
|
+
-- | `run_id` | `TEXT` | `NOT NULL`, `FK` | Foreign key reference to `runs.run_id`, identifying the run this event belongs to. |
|
|
477
|
+
-- | `ts_event_ns` | `INTEGER` | `NOT NULL` | Time at which the expiration was observed by the system, as nanoseconds since UTC epoch. |
|
|
478
|
+
-- | `ts_created_ns` | `INTEGER` | `NOT NULL` | Time at which the event object was created, as nanoseconds since UTC Unix epoch. |
|
|
479
|
+
-- | `ts_broker_ns` | `INTEGER` | `NOT NULL` | Time reported by the broker for the expiration, as nanoseconds since UTC Unix epoch. |
|
|
480
|
+
-- | `associated_order_id`| `TEXT` | `NOT NULL` | System-assigned identifier of the expired order (UUID string). |
|
|
481
|
+
-- | `broker_order_id` | `TEXT` | | Broker-assigned identifier of the expired order, if reported. |
|
|
482
|
+
-- | `symbol` | `TEXT` | `NOT NULL` | Identifier of the traded instrument. |
|
|
483
|
+
--
|
|
484
|
+
CREATE TABLE expirations (
|
|
485
|
+
id INTEGER PRIMARY KEY,
|
|
486
|
+
run_id TEXT NOT NULL,
|
|
487
|
+
ts_event_ns INTEGER NOT NULL,
|
|
488
|
+
ts_created_ns INTEGER NOT NULL,
|
|
489
|
+
ts_broker_ns INTEGER NOT NULL,
|
|
490
|
+
associated_order_id TEXT NOT NULL,
|
|
491
|
+
broker_order_id TEXT,
|
|
492
|
+
symbol TEXT NOT NULL,
|
|
493
|
+
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
CREATE INDEX idx_expirations_run_ts ON expirations(run_id, ts_event_ns);
|
|
497
|
+
CREATE INDEX idx_expirations_order_id ON expirations(associated_order_id);
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
PRAGMA user_version = 1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.56.0
|
|
4
4
|
Summary: The Trading Infrastructure Toolkit for Python. Research, simulate, and deploy algorithmic trading strategies — all in one place.
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Author: Nils P. Kujath
|
|
@@ -38,6 +38,10 @@ onesecondtrader/models/bar_period.py,sha256=J8ncVtcAxR52uD0nbC8Knds_GUP5wiuNj5rA
|
|
|
38
38
|
onesecondtrader/models/order_types.py,sha256=SiJamarLQ7zkHzHLLbd86I_TeZrQJ4QEIMqNHj4dxXU,737
|
|
39
39
|
onesecondtrader/models/rejection_reasons.py,sha256=Avp1JYf413_aUQQkEeswI-9EJBmQdd7B6bnQ1MslDNE,2132
|
|
40
40
|
onesecondtrader/models/trade_sides.py,sha256=Pf9BpxoUxqgKC_EKAExfSqgfIIK9NW-RpJES0XHRF-8,583
|
|
41
|
+
onesecondtrader/orchestrator/__init__.py,sha256=PUXo0UqvCCgTH1FVuuDR05QLjjGvAuH9fY7K73Q-gj8,218
|
|
42
|
+
onesecondtrader/orchestrator/orchestrator.py,sha256=qrTzxyQnXQ_Uc47McaV9iCCwB5UZ3CVQou5nnGG-eXI,5470
|
|
43
|
+
onesecondtrader/orchestrator/run_recorder.py,sha256=p_-UMlPgDRudThURFudCamdHEgWgIbQ9UO0lNQUun-A,25911
|
|
44
|
+
onesecondtrader/orchestrator/runs_schema.sql,sha256=MLgj-6jYxAtMq5wZbpb9KBVr6yBNE852b18yiSfzYgo,35364
|
|
41
45
|
onesecondtrader/secmaster/__init__.py,sha256=XAouFrbRTpWWp8U43LQUkj8EZvJR9ydlI9fVdJjH1BY,294
|
|
42
46
|
onesecondtrader/secmaster/schema_versions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
47
|
onesecondtrader/secmaster/schema_versions/secmaster_schema_v1.sql,sha256=E41rVhpYlXiC_GR4cw1bNQW_8Fdy8d-s1RJASIUCijM,12974
|
|
@@ -45,7 +49,7 @@ onesecondtrader/secmaster/utils.py,sha256=d8PMSNLWVr10G0CSdL9vF-j_9jTfvOLxC-6k42
|
|
|
45
49
|
onesecondtrader/strategies/__init__.py,sha256=PPnXOT-dwchYlIQkrA6FpuZaRCsVs1qPNiTI8gOk6ME,224
|
|
46
50
|
onesecondtrader/strategies/base.py,sha256=lxX3HVr-6XQMohayEL0JExMgdd73rMTeu7v26qaMXkE,20139
|
|
47
51
|
onesecondtrader/strategies/examples.py,sha256=OWYsXg79NecPcK9K2_eFY377paYGDsDaw7ecnFaLdIc,1828
|
|
48
|
-
onesecondtrader-0.
|
|
49
|
-
onesecondtrader-0.
|
|
50
|
-
onesecondtrader-0.
|
|
51
|
-
onesecondtrader-0.
|
|
52
|
+
onesecondtrader-0.56.0.dist-info/METADATA,sha256=SxiW6mjAwaR8YSDWV0i5bVYP67JvB6MNtOFcHgGVRVY,9951
|
|
53
|
+
onesecondtrader-0.56.0.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
54
|
+
onesecondtrader-0.56.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
55
|
+
onesecondtrader-0.56.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|