@@ -21,16 +21,16 @@ def plot_graph(test_df):
21
21
22
22
def get_final_df (model , data ):
23
23
"""
24
- This function takes the `model` and `data` dict to
25
- construct a final dataframe that includes the features along
24
+ This function takes the `model` and `data` dict to
25
+ construct a final dataframe that includes the features along
26
26
with true and predicted prices of the testing dataset
27
27
"""
28
- # if predicted future price is higher than the current,
28
+ # if predicted future price is higher than the current,
29
29
# then calculate the true future price minus the current price, to get the buy profit
30
- buy_profit = lambda current , true_future , pred_future : true_future - current if pred_future > current else 0
30
+ buy_profit = lambda current , pred_future , true_future : true_future - current if pred_future > current else 0
31
31
# if the predicted future price is lower than the current price,
32
32
# then subtract the true future price from the current price
33
- sell_profit = lambda current , true_future , pred_future : current - true_future if pred_future < current else 0
33
+ sell_profit = lambda current , pred_future , true_future : current - true_future if pred_future < current else 0
34
34
X_test = data ["X_test" ]
35
35
y_test = data ["y_test" ]
36
36
# perform prediction and get prices
@@ -47,16 +47,16 @@ def get_final_df(model, data):
47
47
test_df .sort_index (inplace = True )
48
48
final_df = test_df
49
49
# add the buy profit column
50
- final_df ["buy_profit" ] = list (map (buy_profit ,
51
- final_df ["adjclose" ],
52
- final_df [f"adjclose_{ LOOKUP_STEP } " ],
50
+ final_df ["buy_profit" ] = list (map (buy_profit ,
51
+ final_df ["adjclose" ],
52
+ final_df [f"adjclose_{ LOOKUP_STEP } " ],
53
53
final_df [f"true_adjclose_{ LOOKUP_STEP } " ])
54
54
# since we don't have profit for last sequence, add 0's
55
55
)
56
56
# add the sell profit column
57
- final_df ["sell_profit" ] = list (map (sell_profit ,
58
- final_df ["adjclose" ],
59
- final_df [f"adjclose_{ LOOKUP_STEP } " ],
57
+ final_df ["sell_profit" ] = list (map (sell_profit ,
58
+ final_df ["adjclose" ],
59
+ final_df [f"adjclose_{ LOOKUP_STEP } " ],
60
60
final_df [f"true_adjclose_{ LOOKUP_STEP } " ])
61
61
# since we don't have profit for last sequence, add 0's
62
62
)
@@ -79,8 +79,8 @@ def predict(model, data):
79
79
80
80
81
81
# load the data
82
- data = load_data (ticker , N_STEPS , scale = SCALE , split_by_date = SPLIT_BY_DATE ,
83
- shuffle = SHUFFLE , lookup_step = LOOKUP_STEP , test_size = TEST_SIZE ,
82
+ data = load_data (ticker , N_STEPS , scale = SCALE , split_by_date = SPLIT_BY_DATE ,
83
+ shuffle = SHUFFLE , lookup_step = LOOKUP_STEP , test_size = TEST_SIZE ,
84
84
feature_columns = FEATURE_COLUMNS )
85
85
86
86
# construct the model
@@ -129,4 +129,4 @@ def predict(model, data):
129
129
if not os .path .isdir (csv_results_folder ):
130
130
os .mkdir (csv_results_folder )
131
131
csv_filename = os .path .join (csv_results_folder , model_name + ".csv" )
132
- final_df .to_csv (csv_filename )
132
+ final_df .to_csv (csv_filename )
0 commit comments