Skip to content

Commit

Permalink
0.1.2.1 Added simple return calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
open-risk committed Mar 26, 2019
1 parent 5e80851 commit 9c5f6ba
Show file tree
Hide file tree
Showing 3 changed files with 3,028 additions and 3,002 deletions.
23 changes: 23 additions & 0 deletions correlationMatrix/utils/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def construct_log_returns(in_filename, out_filename, drop_columns=None):
"""
Load a dataframe with level data from file
Drop a list of columns that are not to be processed
Construct log-returns
Store to file
"""
Expand All @@ -89,6 +90,28 @@ def construct_log_returns(in_filename, out_filename, drop_columns=None):
log_return_data.to_csv(out_filename, index=False)


def construct_returns(in_filename, out_filename, drop_columns=None):
"""
Load a dataframe with level data from file
Drop a list of columns that are not to be processed
Construct simple returns
Store to file
"""
if drop_columns:
level_data = pd.read_csv(in_filename).drop(columns=drop_columns)
else:
level_data = pd.read_csv(in_filename)

return_data = pd.DataFrame()

for column in level_data:
return_data[column] = level_data[column] - level_data[column].shift(1)

return_data = return_data.dropna()
return_data.to_csv(out_filename, index=False)


def normalize_log_returns(in_filename, out_filename):
"""
Load a dataframe with log-return data from file
Expand Down
Loading

0 comments on commit 9c5f6ba

Please sign in to comment.