Trading, Python, Quantitative Finance, Finance, Investing.
np.where(signals['short_mavg'][short_window:] > signals['long_mavg'][short_window:], 1.0, 0.0) # Generate trading orders signals['positions'] = signals['signal'].diff() return signals # Define short and long windows for the moving averages short_window = 40 long_window = 100 # Get signals from the