Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
- Added voting based b_s orders.
- Created config file (too much hassle otherwise)
- Created utils.py for shared utility functions (read_file, read_config).
- Small clean up
- Added way to find "best_parameters" on sample data (using param_test_script.py & param_test_inference.py
  • Loading branch information
ka5par committed Jan 18, 2021
1 parent 929705f commit 008aeb6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions configuration.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ delta_values = ['variable', 2, 3, 4, 5]
months_out_of_sample = 36

[actual_names]
^GSPC = S&P 500
^GSPC = S&P500
^DJI = Dow Jones Industrial Average
^GDAXI = DAX30
^FCHI = CAC 40
^FCHI = CAC40
^N225 = Nikkei 225
brent oil = Brent
natural gas = NG
Expand Down
10 changes: 5 additions & 5 deletions inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def vote_based_b_s(df, list_of_distance_metrics, list_of_stat_models):
return df


def main(stock_index):
def main(stock_index, vote_based=False):

next_returns, b_s_orders = utils.read_data(stock_index, True)

Expand All @@ -53,9 +53,10 @@ def main(stock_index):
month_id = np.unique(b_s_orders["monthID"])

# Create an equal vote based b_s order.
list_of_distance_metrics = ["dtw", "twed", "lcss"]
list_of_stat_models = ["knn"]
b_s_orders = vote_based_b_s(b_s_orders, list_of_distance_metrics, list_of_stat_models).reset_index()
if vote_based:
list_of_distance_metrics = ["dtw", "twed", "lcss"]
list_of_stat_models = ["knn"]
b_s_orders = vote_based_b_s(b_s_orders, list_of_distance_metrics, list_of_stat_models).reset_index()

# Instead of multi-index using a "label" column.
b_s_orders["Labels"] = b_s_orders["data_normalization"] + " " + b_s_orders["distance_model"] + " " + b_s_orders["stat_model"]
Expand Down Expand Up @@ -133,7 +134,6 @@ def main(stock_index):
dict_indexes = utils.read_config("actual_names")

if __name__ == '__main__':

for instrument in instruments:
main(instrument)

2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def convert(x):
try:
return int(x)
except ValueError:
pass
return x
else:
return x

Expand Down

0 comments on commit 008aeb6

Please sign in to comment.