From 19c9b88b7682e6cc0b073467dd143134a89c43c5 Mon Sep 17 00:00:00 2001 From: TPTBusiness Date: Fri, 10 Apr 2026 21:42:27 +0200 Subject: [PATCH] fix: Add critical column name rules to factor generation prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added explicit rules to prevent KeyError failures: - Column names must use $ prefix: $close, $open, $high, $low, $volume - DO NOT use groupby() for simple calculations - Examples of correct and incorrect code - This should reduce retry cycles from 10-20 to 1-2 per factor Expected speedup: ~8 factors/h → ~50+ factors/h --- prompts/standard_prompts.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/prompts/standard_prompts.yaml b/prompts/standard_prompts.yaml index 977d457b..592b9e4c 100644 --- a/prompts/standard_prompts.yaml +++ b/prompts/standard_prompts.yaml @@ -47,6 +47,17 @@ factor_evolution: Suggest specific improvements to beat current performance.' +factor_generation: + user: "\n\n⚠️ CRITICAL COLUMN NAME RULES:\n- The DataFrame columns are named: '$open',\ + \ '$close', '$high', '$low', '$volume'\n- DO NOT use 'close', 'open', 'high',\ + \ 'low', 'volume' without the $ prefix!\n- DO NOT use df.groupby() for simple\ + \ calculations - use direct vectorized operations!\n- Always use: df['$close'],\ + \ df['$high'], df['$low'], etc.\n- Example CORRECT: df['$close'] - df['$close'].shift(15)\n\ + - Example WRONG: df['close'] - df['close'].shift(15)\n- Example WRONG: df.groupby(level=1)['close'].shift(15)\n\ + \nExample of correct code:\n```python\ndef calculate_my_factor():\n df = pd.read_hdf('intraday_pv.h5',\ + \ key='data')\n df['return_15'] = (df['$close'] - df['$close'].shift(15)) /\ + \ df['$close'].shift(15)\n result = pd.DataFrame({'my_factor': df['return_15']},\ + \ index=df.index)\n result.to_hdf('result.h5', key='data', mode='w')\n```" model_coder: system: 'You are an expert ML engineer specialized in EURUSD trading models.