Good evening, I’m trying to sort out a script to analyze some financial metrics – AI has really accelerated my ability to generate code well past the pace I have been picking away at things for the last several years, and today I’m so far ahead of myself that I’m lost. I’m trying to do some analysis on MACD and RSI, and getting kicked out at this point in the script each time. Can anyone point me in the right direction? thanks a lot!
# --- Analyze actions and probabilities (including indicators) --- def analyze_action(df, SYMBOL_category=None, rsi_condition=None, macd_condition=None): """Analyzes the probability of a big swing in SYMBOL given a specific SYMBOL action and indicator conditions.""" filtered_df = df.copy() if SYMBOL_category: filtered_df = filtered_df[filtered_df['SYMBOL_Category'] == SYMBOL_category] if rsi_condition: # Example: rsi_condition = ('RSI_SYMBOL', '>', 70) # Overbought condition filtered_df = filtered_df[filtered_df[rsi_condition[0]] rsi_condition[1] rsi_condition[2]] # Corrected line if macd_condition: # Example: macd_condition = ('MACD_Histogram_SYMBOL', '>', 0) # Bullish crossover filtered_df = filtered_df[filtered_df[macd_condition[0]] macd_condition[1] macd_condition[2]] # Corrected line
and my output –
line 96
filtered_df = filtered_df[filtered_df[rsi_condition[0]] rsi_condition[1] rsi_condition[2]] # Corrected line
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
submitted by /u/janzend
[link] [comments]
r/learnpython Good evening, I’m trying to sort out a script to analyze some financial metrics – AI has really accelerated my ability to generate code well past the pace I have been picking away at things for the last several years, and today I’m so far ahead of myself that I’m lost. I’m trying to do some analysis on MACD and RSI, and getting kicked out at this point in the script each time. Can anyone point me in the right direction? thanks a lot! # — Analyze actions and probabilities (including indicators) — def analyze_action(df, SYMBOL_category=None, rsi_condition=None, macd_condition=None): “””Analyzes the probability of a big swing in SYMBOL given a specific SYMBOL action and indicator conditions.””” filtered_df = df.copy() if SYMBOL_category: filtered_df = filtered_df[filtered_df[‘SYMBOL_Category’] == SYMBOL_category] if rsi_condition: # Example: rsi_condition = (‘RSI_SYMBOL’, ‘>’, 70) # Overbought condition filtered_df = filtered_df[filtered_df[rsi_condition[0]] rsi_condition[1] rsi_condition[2]] # Corrected line if macd_condition: # Example: macd_condition = (‘MACD_Histogram_SYMBOL’, ‘>’, 0) # Bullish crossover filtered_df = filtered_df[filtered_df[macd_condition[0]] macd_condition[1] macd_condition[2]] # Corrected line and my output – line 96 filtered_df = filtered_df[filtered_df[rsi_condition[0]] rsi_condition[1] rsi_condition[2]] # Corrected line ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma? submitted by /u/janzend [link] [comments]
Good evening, I’m trying to sort out a script to analyze some financial metrics – AI has really accelerated my ability to generate code well past the pace I have been picking away at things for the last several years, and today I’m so far ahead of myself that I’m lost. I’m trying to do some analysis on MACD and RSI, and getting kicked out at this point in the script each time. Can anyone point me in the right direction? thanks a lot!
# --- Analyze actions and probabilities (including indicators) --- def analyze_action(df, SYMBOL_category=None, rsi_condition=None, macd_condition=None): """Analyzes the probability of a big swing in SYMBOL given a specific SYMBOL action and indicator conditions.""" filtered_df = df.copy() if SYMBOL_category: filtered_df = filtered_df[filtered_df['SYMBOL_Category'] == SYMBOL_category] if rsi_condition: # Example: rsi_condition = ('RSI_SYMBOL', '>', 70) # Overbought condition filtered_df = filtered_df[filtered_df[rsi_condition[0]] rsi_condition[1] rsi_condition[2]] # Corrected line if macd_condition: # Example: macd_condition = ('MACD_Histogram_SYMBOL', '>', 0) # Bullish crossover filtered_df = filtered_df[filtered_df[macd_condition[0]] macd_condition[1] macd_condition[2]] # Corrected line
and my output –
line 96
filtered_df = filtered_df[filtered_df[rsi_condition[0]] rsi_condition[1] rsi_condition[2]] # Corrected line
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
submitted by /u/janzend
[link] [comments]