feat: instrument analysis
This commit is contained in:
@@ -543,9 +543,11 @@ def _get_relevant_events(
|
||||
SELECT e.*,
|
||||
(SELECT GROUP_CONCAT(DISTINCT a.instrument)
|
||||
FROM causal_event_analyses a
|
||||
WHERE a.market_event_id = e.id) AS analyzed_instruments,
|
||||
(SELECT a.template_id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS cea_template_id,
|
||||
(SELECT a.id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS analysis_id
|
||||
WHERE a.market_event_id = e.id) AS analyzed_instruments,
|
||||
(SELECT a.template_id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS cea_template_id,
|
||||
(SELECT a.id FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS analysis_id,
|
||||
(SELECT a.prediction_json FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS cea_prediction_json,
|
||||
(SELECT a.actual_json FROM causal_event_analyses a WHERE a.market_event_id = e.id ORDER BY a.id DESC LIMIT 1) AS cea_actual_json
|
||||
FROM market_events e
|
||||
ORDER BY e.start_date DESC
|
||||
""").fetchall()
|
||||
@@ -553,7 +555,9 @@ def _get_relevant_events(
|
||||
# Use cea_template_id (from causal_event_analyses) explicitly to avoid
|
||||
# any collision with an e.* column named template_id
|
||||
all_events = [
|
||||
{**dict(r), "template_id": r["cea_template_id"]}
|
||||
{**dict(r), "template_id": r["cea_template_id"],
|
||||
"prediction_json": r["cea_prediction_json"],
|
||||
"actual_json": r["cea_actual_json"]}
|
||||
for r in rows
|
||||
]
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user