@@ -21,16 +21,16 @@ def plot_graph(test_df):
2121
2222def  get_final_df (model , data ):
2323    """ 
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 
2626    with true and predicted prices of the testing dataset 
2727    """ 
28-     # if predicted future price is higher than the current,   
28+     # if predicted future price is higher than the current, 
2929    # 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 
3131    # if the predicted future price is lower than the current price, 
3232    # 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 
3434    X_test  =  data ["X_test" ]
3535    y_test  =  data ["y_test" ]
3636    # perform prediction and get prices 
@@ -47,16 +47,16 @@ def get_final_df(model, data):
4747    test_df .sort_index (inplace = True )
4848    final_df  =  test_df 
4949    # 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 }  ],
5353                                    final_df [f"true_adjclose_{ LOOKUP_STEP }  ])
5454                                    # since we don't have profit for last sequence, add 0's 
5555                                    )
5656    # 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 }  ],
6060                                    final_df [f"true_adjclose_{ LOOKUP_STEP }  ])
6161                                    # since we don't have profit for last sequence, add 0's 
6262                                    )
@@ -79,8 +79,8 @@ def predict(model, data):
7979
8080
8181# 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 ,
8484                feature_columns = FEATURE_COLUMNS )
8585
8686# construct the model 
@@ -129,4 +129,4 @@ def predict(model, data):
129129if  not  os .path .isdir (csv_results_folder ):
130130    os .mkdir (csv_results_folder )
131131csv_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