Switch from volitility to price tomorrow
This commit is contained in:
@@ -17,7 +17,7 @@ def Predict():
|
|||||||
df = features.CleanDF(df)
|
df = features.CleanDF(df)
|
||||||
|
|
||||||
# Drop our predictor
|
# Drop our predictor
|
||||||
df.drop('Volatility_5', axis=1, inplace=True)
|
df.drop('Target_Close_Tomorrow', axis=1, inplace=True)
|
||||||
|
|
||||||
# Lazy load this so it doesnt interfere with yfinance
|
# Lazy load this so it doesnt interfere with yfinance
|
||||||
from keras.models import load_model
|
from keras.models import load_model
|
||||||
@@ -34,6 +34,6 @@ def Predict():
|
|||||||
# 'predictions' will be a 2D array, flatten it if you want a simple list
|
# 'predictions' will be a 2D array, flatten it if you want a simple list
|
||||||
flat_predictions = predictions.flatten()
|
flat_predictions = predictions.flatten()
|
||||||
|
|
||||||
print(f"Predicted Volatility: {flat_predictions}")
|
print(f"Predicted Target_Close_Tomorrow: {flat_predictions}")
|
||||||
|
|
||||||
return flat_predictions
|
return flat_predictions
|
||||||
@@ -16,8 +16,8 @@ def TrainAI():
|
|||||||
|
|
||||||
# Load the dataset
|
# Load the dataset
|
||||||
dataset = pd.read_parquet(os.path.join(DATA_DIR, "stocks.parquet"))
|
dataset = pd.read_parquet(os.path.join(DATA_DIR, "stocks.parquet"))
|
||||||
X = dataset.drop('Volatility_5', axis=1)
|
X = dataset.drop('Target_Close_Tomorrow', axis=1)
|
||||||
Y = dataset['Volatility_5']
|
Y = dataset['Target_Close_Tomorrow']
|
||||||
|
|
||||||
# Show the datatypes
|
# Show the datatypes
|
||||||
print(dataset.dtypes)
|
print(dataset.dtypes)
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ def MakeFeatures(df, i):
|
|||||||
# Add feature for volitility last 20
|
# Add feature for volitility last 20
|
||||||
df['Volatility_20'] = df['Return'].transform(lambda x: x.rolling(20).std())
|
df['Volatility_20'] = df['Return'].transform(lambda x: x.rolling(20).std())
|
||||||
|
|
||||||
|
# This is our training metric
|
||||||
|
df['Target_Close_Tomorrow'] = df['Close'].shift(-1).pct_change()
|
||||||
|
|
||||||
# Return new df with new features
|
# Return new df with new features
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user