Skip to content

Instantly share code, notes, and snippets.

View lamass's full-sized avatar

Tony Nikolov lamass

  • New York
View GitHub Profile
# Take long positions
data['long_positions'] = np.where(data['short_mavg'] > data['long_mavg'], 1, 0)
# Take short positions
data['short_positions'] = np.where(data['short_mavg'] < data['long_mavg'], -1, 0)
data['positions'] = data['long_positions'] + data['short_positions']
# Plot close price and moving averages
plot_data = data[-3000:]