Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Created October 11, 2023 17:12
Show Gist options
  • Save quantra-go-algo/ddf88f82cd4787ffef9f95d31826120c to your computer and use it in GitHub Desktop.
Save quantra-go-algo/ddf88f82cd4787ffef9f95d31826120c to your computer and use it in GitHub Desktop.
# Create a simple 4-day moving average
data['sma'] = data['Close'].rolling(4).mean()
# Create the strategy signal
data['signal'] = np.where(data['Close']>data['sma'],1.0,-1.0)
# Create the leverage column
data['dc_leverage'] = 0.0
# Create the next state column
data['dc_next_state'] = 0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment