-
Notifications
You must be signed in to change notification settings - Fork 0
/
_merge_other.py
executable file
·109 lines (85 loc) · 3.55 KB
/
_merge_other.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# TO BE CLEANED -----------------------------
# Modules
import pandas as pd
import os as os
import statistics as stcs
import numpy as np
import itertools as itr
import pandas as pd
import statsmodels.formula.api as sm
import datetime
import yaml
import importlib
#temp
import matplotlib.pyplot as plt
# Import SETTINGS-file
with open("./SETTINGS.yml", 'r') as stream:
try:
SETTINGS = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
# Import helpers
spec = importlib.util.spec_from_file_location("noname", "./gen_helpers.py")
helpers = importlib.util.module_from_spec(spec)
spec.loader.exec_module(helpers)
# ----------------------------------
def mergeCRIX(self):
for cname in self.coindata.keys():
adddata = self.crixdata
maindata = self.coindata[cname]
mergeddata = pd.merge(maindata,
adddata,
on="time")
self.coindata[cname] = mergeddata
def mergeCMI10(self):
for cname in self.coindata.keys():
""" adddata = self.yfinancedata["CMI10.SW"].copy()
adddata["time"] = pd.to_datetime(adddata["time"])
adddata["cp"] = adddata["cp"].apply(np.sqrt).apply(np.sqrt)
adddata.rename(columns={"cp": "vola_cmi10"}, inplace=True)
maindata = self.coindata[cname].copy()
mergeddata = pd.merge(maindata,
adddata,
how="left",
on="time")
self.coindata[cname] = mergeddata """
adddata = self.yfinancedata["BTC-USD"].copy()
adddata["time"] = pd.to_datetime(adddata["time"])
adddata["cp"] = adddata["cp"].apply(np.sqrt).apply(np.sqrt)
adddata.rename(columns={"cp": "vola_btc"}, inplace=True)
maindata = self.coindata[cname].copy()
mergeddata = pd.merge(maindata,
adddata,
how="left",
on="time")
self.coindata[cname] = mergeddata
adddata = self.yfinancedata["ETH-USD"].copy()
adddata["time"] = pd.to_datetime(adddata["time"])
adddata["cp"] = adddata["cp"].apply(np.sqrt).apply(np.sqrt)
adddata.rename(columns={"cp": "vola_eth"}, inplace=True)
maindata = self.coindata[cname].copy()
mergeddata = pd.merge(maindata,
adddata,
how="left",
on="time")
self.coindata[cname] = mergeddata
adddata = self.yfinancedata["XRP-USD"].copy()
adddata["time"] = pd.to_datetime(adddata["time"])
adddata["cp"] = adddata["cp"].apply(np.sqrt).apply(np.sqrt)
adddata.rename(columns={"cp": "vola_xrp"}, inplace=True)
maindata = self.coindata[cname].copy()
mergeddata = pd.merge(maindata,
adddata,
how="left",
on="time")
self.coindata[cname] = mergeddata
adddata = self.yfinancedata["GAS-ETH"].copy()
adddata["time"] = pd.to_datetime(adddata["time"])
adddata["cp"] = adddata["cp"]
adddata.rename(columns={"cp": "gas"}, inplace=True)
maindata = self.coindata[cname].copy()
mergeddata = pd.merge(maindata,
adddata,
how="left",
on="time")
self.coindata[cname] = mergeddata