MLCF - Machine Learning Toolkit for Cryptocurrency Forecasting
This library provides tools for cryptocurrency forecasting and trade decision making.
For now, the library provide only data tools, such as:
- OHLCV file reader
- Tools to add extern and intern indicators
- Tools to labelize data
- Tools to work on a set of intervals in order
- Tools to windowed the data
- Tools to build, save and read a dataset
- Tools to standardize data
- Tools to preprocess the data by filtering some windows
This library doesn't provide models or an end-to-end trade bot.
For more information, find the documentation here : https://guitheg.github.io/mlcf
Installation
OS officially supported:
Python version officially supported:
Installation for Linux (python v3.7)
pip install mlcf
Installation for Linux (python v3.8, v3.9)
pip install mlcf --no-binary TA-LIB
MLCF example module usage
In this part, we will introduce some example usage of MLCF module.
File reader module
from pathlib import Path
from mlcf.datatools.data_reader import (
read_ohlcv_json_from_file,
read_ohlcv_json_from_dir,
read_json_file
)
data = read_ohlcv_json_from_file(Path("tests/testdata/ETH_BUSD-15m.json"))
pair = "ETH_BUSD"
tf = "15m"
data = read_ohlcv_json_from_dir(Path("tests/testdata/"), pair=pair, timeframe=tf)
data = read_json_file(Path("tests/testdata/meteo.json"), 'time', ["time", "Temperature"])
Indicator Module
from mlcf.indicators.add_indicators import add_intern_indicator
data["return"] = data["close"].pct_change(1)
data.dropna(inplace=True)
data = add_intern_indicator(data, indice_name="adx")
Label Tool
from mlcf.datatools.utils import labelize
mean = data["return"].mean()
std = data["return"].std()
data = labelize(
data,
column="return",
labels=5,
bounds=(mean-std, mean+std),
label_col_name="label"
)
Data Intervals Module, Standardization Tools and WindowFilter Tool
from mlcf.datatools.data_intervals import DataIntervals
from mlcf.datatools.standardize_fct import ClassicStd, MinMaxStd
from mlcf.datatools.windowing.filter import LabelBalanceFilter
std_by_features = {
"close": ClassicStd(),
"return": ClassicStd(with_mean=False),
"adx": MinMaxStd(minmax=(0, 100))
}
data_intervals = DataIntervals.create_data_intervals_obj(data, n_intervals=10)
data_intervals.standardize(std_by_features)
filter_by_set = {
"train": LabelBalanceFilter("label")
}
dict_train_val_test = data_intervals.windowing(
window_width=30,
window_step=1,
selected_columns=["close", "return", "adx"],
filter_by_dataset=filter_by_set
)
Window Iterator Tool
from mlcf.datatools.windowing.tseries import WTSeriesLite
wtseries = WTSeriesLite.create_wtseries_lite(
dataframe=data,
window_width=30,
window_step=1,
selected_columns=["close", "return", "adx"],
window_filter=LabelBalanceFilter("label")
)
wtseries = WTSeriesLite.read(Path("/tests/testdata/wtseries.h5"))
wtseries.write(Path("/tests/testdata", "wtseries"))
for window in wtseries:
pass
Forecast Window Iterator Tool
from mlcf.datatools.windowing.forecast_iterator import WindowForecastIterator
data_train = WindowForecastIterator(
wtseries,
input_width=29,
target_width=1,
input_features=["close", "adx"],
target_features=["return"]
)
for window in data_train:
window_input, window_target = window
pass