Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Created January 31, 2024 18:41
Show Gist options
  • Save quantra-go-algo/f6cd26b16296085f569ef3f96ac214e1 to your computer and use it in GitHub Desktop.
Save quantra-go-algo/f6cd26b16296085f569ef3f96ac214e1 to your computer and use it in GitHub Desktop.
# Generate signals based on moving average crossover
aapl_data['Signal'] = 0 # 0 indicates no signal
aapl_data.loc[aapl_data['SMA_50'] > aapl_data['SMA_200'], 'Signal'] = 1 # 1 indicates buy signal
aapl_data.loc[aapl_data['SMA_50'] < aapl_data['SMA_200'], 'Signal'] = -1 # -1 indicates sell signal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment