Hi , i try to shift the moving average of , for example the last 2 trading days and project it 3 days into the future
it works in the notebook like so:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
aapl_daily_low = get_pricing(
'AAPL',
fields='low', #modify to price, open_price, high, low or volume to change the field
start_date='2014-01-01', #customize your pricing date range
end_date = '2014-07-01',
frequency='daily', #change to daily for daily pricing
)
aapl_daily_high = get_pricing(
'AAPL',
fields='high', #modify to price, open_price, high, low or volume to change the field
start_date='2014-01-01', #customize your pricing date range
end_date = '2014-07-01',
frequency='daily', #change to daily for daily pricing
)
aapl_daily_close = get_pricing(
'AAPL',
fields='close_price', #modify to price, open_price, high, low or volume to change the field
start_date='2014-01-01', #customize your pricing date range
end_date = '2014-07-01',
frequency='daily', #change to daily for daily pricing
)
apple_mean_low = np.round(aapl_daily_low.rolling(window = 2, center = False).mean().shift(3),2)
apple_mean_high = np.round(aapl_daily_high.rolling(window = 2, center = False).mean().shift(3),2)
iam happy with the output:
Plot of daily low and MA of low
however if i try to run a backtest on an algo with the lines of code for creating the MAs it seems to return NaN values ?
can anybody help a python beginner please ?
thnx