Skip to content

Commit 0d98b9f

Browse files
committed
error due to std 0 when stable coin
1 parent 31d8899 commit 0d98b9f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

hygdra_forecasting/utils/ohlv.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_kraken_data_to_json(tickers:list[str], interval:str) -> tuple[dict, dict
4646
response = requests.request("GET", url, headers=headers, data=payload)
4747

4848
data = json.loads(response.text)
49-
print("pair", pair)
49+
5050
for key, values in data["result"].items():
5151
if key != "last" :
5252
data_dict[pair] = values
@@ -86,11 +86,6 @@ def kraken_preprocessing(data: dict) -> tuple[dict, dict]:
8686
processed_data[key]["diff"], processed_data[key]["percent_change_close"] = dict_calculate_diff_and_pct_change(processed_data[key]["close"])
8787

8888
# corriger la shape
89-
# gestion decalage
90-
min_shape = processed_data[key]["upper"].shape[0]
91-
min_shape_roc = processed_data[key]["roc"].shape[0]
92-
max_shape = processed_data[key]["close"].shape[0]
93-
9489
for indic in processed_data[key].keys():
9590
if indic not in ["upper", "lower", "width", "rsi", "roc"]:
9691
processed_data[key][indic] = processed_data[key][indic][14:]
@@ -99,7 +94,10 @@ def kraken_preprocessing(data: dict) -> tuple[dict, dict]:
9994

10095
MEAN = np.mean(processed_data[key][indic])
10196
STD = np.std(processed_data[key][indic])
97+
if STD == 0 :
98+
STD = 1
10299
processed_data[key][indic] = (processed_data[key][indic] - MEAN) / STD
100+
# print(STD, MEAN, indic, key)
103101
unnorm_dict[key] = {"indic" : {"mean" : MEAN, "std" : STD}}
104102

105103
return processed_data, unnorm_dict

train_deep.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from hygdra_forecasting.model.train import setup_seed, train_model
55
from hygdra_forecasting.utils.learning_rate_sheduler import CosineWarmup
66
from hygdra_forecasting.model.build import ConvCausalLTSM, LtsmAttentionforecastPred
7-
from hygdra_forecasting.dataloader.dataloader import StockDataset
7+
from hygdra_forecasting.dataloader.dataloader import StockDataset as standar
8+
from hygdra_forecasting.dataloader.dataloader_kraken import StockDataset
9+
810
from torch import device, cuda, load
911
from torch.utils.data import DataLoader
1012
import json

weight/0_weight.pth

0 Bytes
Binary file not shown.

weight/best_model.pth

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)