forked from philipperemy/deep-learning-bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturns_quantization.py
36 lines (24 loc) · 924 Bytes
/
returns_quantization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
import pandas as pd
from data_manager import file_processor
from utils import compute_returns
def add_returns_in_place(df): # modifies df
close_prices_returns = compute_returns(df)
num_bins = 10
returns_bins = pd.qcut(close_prices_returns, num_bins)
bins_categories = returns_bins.values.categories
returns_labels = pd.qcut(close_prices_returns, num_bins, labels=False)
df['close_price_returns'] = close_prices_returns
df['close_price_returns_bins'] = returns_bins
df['close_price_returns_labels'] = returns_labels
return df, bins_categories
def generate_bins(bitcoin_file):
p = file_processor(bitcoin_file)
print(add_returns_in_place(p))
def main():
arg = sys.argv
assert len(arg) == 2, 'Usage: python3 {} BITCOIN_MARKET_DATA_CSV_PATH'.format(arg[0])
bitcoin_file = arg[1]
generate_bins(bitcoin_file)
if __name__ == '__main__':
main()