improve docs

This commit is contained in:
robcaulk 2022-08-10 11:56:42 +02:00
parent 4289c5c684
commit 91d0c91287
3 changed files with 476 additions and 249 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,198 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
id="svg1557"
version="1.1"
viewBox="0 0 316.36553 184.36865"
height="184.36865mm"
width="316.36554mm">
<defs
id="defs1551">
<linearGradient
id="linearGradient1933">
<stop
style="stop-color:#800080;stop-opacity:1"
offset="0"
id="stop1929" />
<stop
style="stop-color:#c83737;stop-opacity:1"
offset="1"
id="stop1931" />
</linearGradient>
<linearGradient
id="linearGradient1142">
<stop
id="stop1138"
offset="0"
style="stop-color:#800080;stop-opacity:1" />
<stop
id="stop1140"
offset="1"
style="stop-color:#c83737;stop-opacity:1" />
</linearGradient>
<linearGradient
y2="26.575241"
x2="249.15274"
y1="56.015697"
x1="153.87447"
gradientUnits="userSpaceOnUse"
id="linearGradient1147"
xlink:href="#linearGradient1142" />
<linearGradient
y2="81.289787"
x2="301.36768"
y1="131.64389"
x1="293.50531"
gradientUnits="userSpaceOnUse"
id="linearGradient2187"
xlink:href="#linearGradient1142" />
<linearGradient
y2="-63.514065"
x2="229.03004"
y1="168.38782"
x1="78.344269"
gradientUnits="userSpaceOnUse"
id="linearGradient2189"
xlink:href="#linearGradient1142" />
<linearGradient
y2="75.905518"
x2="378.23627"
y1="104.48698"
x1="371.62622"
gradientUnits="userSpaceOnUse"
id="linearGradient2481"
xlink:href="#linearGradient1142" />
<linearGradient
gradientUnits="userSpaceOnUse"
y2="-40.816475"
x2="304.21649"
y1="336.74393"
x1="94.333183"
id="linearGradient1917"
xlink:href="#linearGradient1142" />
<linearGradient
y2="-0.12421786"
x2="317.15186"
y1="223.87135"
x1="192.64189"
gradientUnits="userSpaceOnUse"
id="linearGradient1927"
xlink:href="#linearGradient1933" />
</defs>
<metadata
id="metadata1554">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(7.2313488,-24.26963)"
style="display:inline"
id="layer10">
<rect
y="314.40167"
x="-484.1925"
height="232.4895"
width="354.94998"
id="rect2631"
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.6470232;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:1.94106953, 1.94106953;stroke-dashoffset:0;stroke-opacity:1;paint-order:fill markers stroke" />
</g>
<g
transform="translate(33.957064,-20.263133)"
style="display:inline"
id="layer3">
<g
style="display:inline;fill:url(#linearGradient1917);fill-opacity:1"
id="g1909"
transform="translate(-26.725716,-4.0064965)">
<g
style="fill:#000100;fill-opacity:1"
id="g1939">
<g
style="fill:#000000;fill-opacity:1"
id="g1980">
<path
id="path881-9"
d="m 356.39942,86.421204 c -0.17396,0.05482 2.4357,3.176129 3.10051,10.312194 0,0 0,4e-6 0,4e-6 0.20586,2.096756 0.0952,4.894048 -1.33373,7.469218 -1.25343,2.13742 -3.25193,3.81195 -5.65558,5.05236 -2.93094,1.54511 -6.04563,2.54914 -9.58158,3.53388 -9.1356,2.56687 -20.04019,4.74508 -31.90235,7.83241 -15.88636,3.59519 -33.5148,8.33533 -52.33259,14.75841 0.83756,-2.7566 1.23422,-5.81607 0.70262,-8.82691 0.0223,-2.30338 -0.77407,-4.68821 -1.99493,-6.91301 -1.4611,-2.64186 -3.56306,-5.01602 -5.92999,-7.27687 -1.61906,-1.5364 -3.35626,-2.97974 -5.18222,-4.36261 -1.37665,-1.04258 -2.79284,-2.04252 -4.22761,-3.01118 -8.37709,-5.651094 -17.50084,-10.254466 -26.22118,-14.397623 -10.48011,-4.973458 -21.36555,-9.589844 -30.98464,-13.65048 0,0 -1e-5,-4e-6 -1e-5,-4e-6 -11.42118,-4.820511 -20.18031,-8.446509 -29.77458,-12.806125 -4.54113,-2.063286 -8.65361,-4.021418 -12.59548,-6.066657 -3.73834,-1.938347 -7.03127,-3.797673 -10.1054,-5.837819 -2.69335,-1.778371 -4.99197,-3.538924 -6.92247,-5.650426 0,0 -10e-6,-4e-6 -10e-6,-4e-6 -0.80183,-0.874763 -1.50146,-1.804661 -2.04717,-2.821664 -0.49026,-0.904429 -0.81472,-1.883681 -0.91134,-2.893574 -0.0885,-1.030169 0.10161,-2.01267 0.47287,-2.858194 0.48152,-1.071663 1.19109,-1.910603 1.88645,-2.54708 1.0893,-1.003919 2.27599,-1.712644 3.22565,-2.206698 2.93906,-1.534207 4.70141,-1.753978 4.74507,-1.648117 0.0811,0.196701 -1.52076,0.916452 -4.11026,2.704447 -0.83313,0.576923 -1.86574,1.348431 -2.70983,2.292214 -0.53238,0.600573 -1.05044,1.314926 -1.31305,2.097114 -0.20668,0.594544 -0.28328,1.271068 -0.17452,1.930218 0.0996,0.670223 0.3941,1.349163 0.80952,2.037978 0.47644,0.781081 1.10842,1.509861 1.85807,2.251957 0,0 1e-5,4e-6 1e-5,4e-6 1.83263,1.809877 4.02113,3.293232 6.70573,4.918782 3.05114,1.836701 6.30045,3.501553 10.05398,5.286858 3.95514,1.8797 8.05108,3.675492 12.6242,5.604934 10.12682,4.272193 17.95595,7.297711 29.96196,12.143569 0,2e-6 0,3e-6 1e-5,4e-6 9.73162,3.927052 20.66105,8.413626 31.34216,13.384211 8.84262,4.110121 18.18919,8.787329 26.92864,14.653635 1.49878,1.00527 2.99073,2.05764 4.45544,3.16906 1.9426,1.47404 3.81638,3.0361 5.591,4.71759 2.60421,2.45278 5.00442,5.22721 6.81931,8.46204 1.5701,2.78182 2.55683,5.96771 2.57651,9.29582 -0.535,2.92849 -2.16465,5.64552 -4.37473,7.84329 17.95518,-7.76603 34.74366,-13.5201 50.17571,-17.70889 12.11514,-2.87129 23.00108,-4.71176 32.10076,-6.89191 3.52565,-0.85344 6.44927,-1.63374 9.17028,-2.91875 2.1583,-1.04412 3.87955,-2.24942 4.89768,-3.85743 1.24963,-1.84281 1.4993,-4.283337 1.49682,-6.195366 0,0 0,-4e-6 0,-4e-6 -0.0504,-6.60678 -1.61632,-10.310076 -1.31571,-10.404806 z"
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458299px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
transform="matrix(1.0227138,0,0,1.0923454,-58.973831,56.875697)" />
<path
transform="matrix(1.0227138,0,0,1.0923454,-59.16092,57.436967)"
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458299px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 287.81169,79.716623 c 0.57527,-0.241527 2.1586,2.423197 5.92187,5.933773 1.91609,1.778822 3.69086,3.186588 6.44336,5.381345 1.81301,1.437142 4.11089,3.236823 6.17543,5.301754 0,0 0,2e-6 0,2e-6 1.56174,1.494712 3.24293,3.539585 4.1857,6.318403 0.38589,1.23394 0.52806,2.58002 0.36532,3.96031 -0.20402,1.49969 -0.70699,2.87383 -1.40996,4.0658 -1.77865,2.96988 -4.23788,5.20126 -6.83219,7.03699 -0.35932,0.25425 -0.71769,0.4985 -1.07265,0.73365 -5.27148,3.62128 -10.92886,6.29296 -15.80027,8.39349 -15.03122,6.5041 -26.16572,8.94959 -26.50431,8.04688 -0.49022,-1.30693 9.94926,-5.67582 24.26699,-12.84815 4.62791,-2.3248 10.01349,-5.05691 14.74394,-8.35382 0.32275,-0.23363 0.6454,-0.46745 0.96311,-0.70047 2.29836,-1.6857 4.23401,-3.26099 5.32848,-5.18778 0.39775,-0.68394 0.69051,-1.33809 0.77016,-1.93652 0.0947,-0.52365 0.0528,-1.10769 -0.0867,-1.66715 -0.28886,-1.42111 -1.4746,-2.88766 -2.67529,-4.341535 0,-10e-7 0,-2e-6 0,-3e-6 -1.61291,-1.857478 -3.73693,-3.824425 -5.39523,-5.447655 -2.44895,-2.386233 -4.33769,-4.379493 -5.95763,-6.516837 -3.4988,-4.593673 -3.95669,-7.951382 -3.43009,-8.172477 z"
id="path884" />
<path
transform="matrix(1.0227138,0,0,1.0923454,-58.973831,56.875697)"
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458299px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 259.28399,134.88902 c -0.58981,-0.34354 1.99081,-4.41604 0.74117,-10.04258 -0.46566,-2.43488 -1.8083,-4.86172 -4.00669,-7.45853 -2.14453,-2.49348 -4.73438,-4.64207 -7.94131,-7.10876 -3.03988,-2.32262 -6.41877,-4.66861 -9.90813,-7.26051 -0.45636,-0.33796 -0.91555,-0.68086 -1.37564,-1.02869 -2.93031,-2.215324 -5.66959,-4.46118 -8.18387,-6.977299 -2.89283,-2.862999 -5.26183,-6.010075 -6.7652,-9.566839 -1.69097,-4.090942 -1.72034,-8.223439 -0.85619,-11.587824 0,-1e-6 0,-2e-6 0,-2e-6 2.58751,-9.615383 8.5942,-11.824672 8.45204,-11.94022 0.61218,0.497594 -3.53563,5.013512 -4.51726,12.744676 0,0 0,2e-6 0,2e-6 -0.37018,2.671471 -0.0353,5.831106 1.42115,8.768265 1.30413,2.71168 3.40603,5.15361 6.05408,7.704555 2.33112,2.218163 4.9033,4.252813 7.75593,6.413645 0.44642,0.338154 0.89474,0.675724 1.34106,1.011165 3.53526,2.648936 6.66106,4.910946 9.88086,7.573796 3.23809,2.66184 6.01538,5.31382 8.27547,8.37316 2.42253,3.22939 3.71989,6.66891 3.93316,9.91512 0.36364,8.27117 -4.57826,10.30516 -4.30063,10.46687 z"
id="path892" />
</g>
</g>
</g>
</g>
<g
transform="translate(7.2313488,-24.26963)"
style="display:inline"
id="layer7">
<text
x="-11.907605"
y="196.59839"
font-size="96.8px"
style="font-size:54.6007576px;line-height:1.25;font-family:sans-serif;display:inline;fill:#000000;stroke:#000000;stroke-width:1.36501884"
xml:space="preserve"
id="text1366"><tspan
style="font-family:'DejaVu Sans';stroke:#000000;stroke-width:1.36501884"
x="-11.907605"
y="196.59839"
id="tspan1364">FreqAI</tspan></text>
</g>
<g
transform="translate(33.957064,-20.263133)"
style="display:inline"
id="layer2">
<g
id="g1946-0"
style="display:inline"
transform="matrix(0.87349509,0,0,0.87349509,-35.29167,15.051278)">
<path
id="path1866-6"
d="m 262.60458,6.1320325 c 0,0 -23.83256,20.7132145 -52.48073,115.6686475 C 163.17669,86.858718 138.99341,82.826847 98.396519,82.115207 151.06434,55.521847 237.643,14.001643 262.60458,6.1320325 Z"
style="display:inline;opacity:1;fill:#d41212;fill-opacity:1;stroke:none;stroke-width:0.47834027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="path1868-4"
d="M 262.7038,5.9666679 C 233.36691,40.509487 210.45433,75.913535 278.69557,143.67959 c 1.41486,-33.02937 70.78288,-10.17334 80.22697,6.29057 C 343.62856,87.890224 260.42342,70.992636 262.7038,5.9666679 Z"
style="display:inline;opacity:0.83200001;fill:#00d7a6;fill-opacity:1;stroke:none;stroke-width:0.47834027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="display:inline;opacity:1;fill:#bf01ba;fill-opacity:1;stroke:none;stroke-width:0.21913391px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 262.7038,5.9666679 C 254.92781,13.218568 227.30234,72.844875 335.4454,19.416852 324.56811,76.878746 339.51291,92.983626 359.83234,152.32482 346.50711,139.64924 290.88518,95.507786 210.12385,121.80087 203.35526,41.556899 250.75016,14.34741 262.7038,5.9666679"
id="path1551" />
<path
id="path2269-6"
d="M 98.396519,82.115207 C 144.00782,52.302053 240.973,67.83967 335.4454,19.416852 260.11684,59.0956 210.12385,121.80077 210.12385,121.80077 176.54755,98.527218 155.25198,82.454217 98.396519,82.115207 Z"
style="display:inline;opacity:1;fill:#32a725;fill-opacity:1;stroke:none;stroke-width:0.47834027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="display:inline;opacity:1;fill:#2b3fda;fill-opacity:1;stroke:none;stroke-width:0.47834027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 335.4454,19.416852 c -9.20129,69.433777 11.24688,69.5371 24.38694,132.907968 C 312.28003,120.10418 255.52015,111.40061 210.12331,121.80192 250.42852,68.708729 313.52349,31.065403 335.4454,19.416852 Z"
id="path875-2" />
</g>
</g>
<g
transform="translate(7.2313488,-24.26963)"
style="display:inline"
id="layer8" />
<g
style="display:inline"
transform="translate(128.99993,-22.392096)"
id="layer1" />
</svg>

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,21 +1,37 @@
![freqai-logo](assets/freqai_logo_no_md.svg) ![freqai-logo](assets/freqai_doc_logo.svg)
# FreqAI # FreqAI
FreqAI is a module designed to automate a variety of tasks associated with FreqAI is a module designed to automate a variety of tasks associated with training a predictive model to generate market forecasts given a set of input features.
training a predictive model to provide signals based on input features.
Among the the features included: Among the the features included:
* Create large rich feature sets (10k+ features) based on simple user created strategies. * **Self-adaptive retraining**: automatically retrain models during live deployments to self-adapt to the market in an unsupervised manner.
* Sweep model training and backtesting to simulate consistent model retraining through time. * **Rapid feature engineering**: create large rich feature sets (10k+ features) based on simple user created strategies.
* Remove outliers automatically from training and prediction sets using a Dissimilarity Index and Support Vector Machines. * **High performance**: adaptive retraining occurs on separate thread (or on GPU if available) from inferencing and bot trade operations. Keep newest models and data in memory for rapid inferencing.
* Reduce the dimensionality of the data with Principal Component Analysis. * **Realistic backtesting**: emulate self-adaptive retraining with backtesting module that automates past retraining.
* Store models to disk to make reloading from a crash fast and easy (and purge obsolete files automatically for sustained dry/live runs). * **Modifiable**: use the generalized and robust architecture for incorporating any machine learning library/method available in Python. Seven examples available.
* Normalize the data automatically in a smart and statistically safe way. * **Smart outlier removal**: remove outliers automatically from training and prediction sets using a variety of outlier detection techniques.
* Automated data download and data handling. * **Crash resilience**: automatic model storage to disk to make reloading from a crash fast and easy (and purge obsolete files automatically for sustained dry/live runs).
* Clean the incoming data of NaNs in a safe way before training and prediction. * **Automated data normalization**: automatically normalize the data automatically in a smart and statistically safe way.
* Retrain live automatically so that the model self-adapts to the market in an unsupervised manner. * **Automatic data download**: automatically compute the data download timerange and downloads data accordingly (in live deployments).
* **Clean the incoming data of NaNs in a safe way before training and prediction.
* **Dimensionality reduction**: reduce the size of the training data via Principal Component Analysis.
* **Deploy bot fleets**: set one bot to train models while a fleet of other bots inference into the models and handle trades.
## Quick start
The easiest way to quickly test FreqAI is to run it in dry run with the following command
```bash
freqtrade trade --config config_examples/config_freqai.example.json --strategy FreqaiExampleStrategy --freqaimodel LightGBMRegressor --strategy-path freqtrade/templates
```
where the user will see the boot-up process of auto-data downloading, followed by simultaneous training and trading.
The example strategy, example prediction model, and example config can all be found in
`freqtrade/templates/FreqaiExampleStrategy.py`, `freqtrade/freqai/prediction_models/LightGBMRegressor.py`,
`config_examples/config_freqai.example.json`, respectively.
## General approach ## General approach
@ -30,7 +46,7 @@ An overview of the algorithm is shown here to help users understand the data pro
## Background and vocabulary ## Background and vocabulary
**Features** are the quantities with which a model is trained. $X_i$ represents the **Features** are the quantities with which a model is trained. $X_i$ represents the
vector of all features for a single candle. In Freqai, the user vector of all features for a single candle. In FreqAI, the user
builds the features from anything they can construct in the strategy. builds the features from anything they can construct in the strategy.
**Labels** are the target values with which the weights inside a model are trained **Labels** are the target values with which the weights inside a model are trained
@ -50,7 +66,7 @@ directly influence nodal weights within the model.
## Install prerequisites ## Install prerequisites
Use `pip` to install the prerequisites with: The normal Freqtrade install process will ask the user if they wish to install `FreqAI` dependencies. The user should reply "yes" to this question if they wish to use FreqAI. If the user did not reply yes, they can manually install these dependencies after the install with:
``` bash ``` bash
pip install -r requirements-freqai.txt pip install -r requirements-freqai.txt
@ -59,18 +75,6 @@ pip install -r requirements-freqai.txt
!!! Note !!! Note
Catboost will not be installed on arm devices (raspberry, Mac M1, ARM based VPS, ...), since Catboost does not provide wheels for this platform. Catboost will not be installed on arm devices (raspberry, Mac M1, ARM based VPS, ...), since Catboost does not provide wheels for this platform.
## Running from the example files
An example strategy, an example prediction model, and example config can all be found in
`freqtrade/templates/FreqaiExampleStrategy.py`, `freqtrade/freqai/prediction_models/LightGBMRegressor.py`,
`config_examples/config_freqai.example.json`, respectively.
Assuming the user has downloaded the necessary data, Freqai can be executed from these templates with:
```bash
freqtrade backtesting --config config_examples/config_freqai.example.json --strategy FreqaiExampleStrategy --freqaimodel LightGBMRegressor --strategy-path freqtrade/templates --timerange 20220101-20220201
```
## Configuring the bot ## Configuring the bot
### Parameter table ### Parameter table
@ -92,13 +96,13 @@ Mandatory parameters are marked as **Required**, which means that they are requi
| `purge_old_models` | Tell FreqAI to delete obsolete models. Otherwise, all historic models will remain on disk. Defaults to `False`. <br> **Datatype:** boolean. | `purge_old_models` | Tell FreqAI to delete obsolete models. Otherwise, all historic models will remain on disk. Defaults to `False`. <br> **Datatype:** boolean.
| `expiration_hours` | Ask FreqAI to avoid making predictions if a model is more than `expiration_hours` old. Defaults to 0 which means models never expire. <br> **Datatype:** positive integer. | `expiration_hours` | Ask FreqAI to avoid making predictions if a model is more than `expiration_hours` old. Defaults to 0 which means models never expire. <br> **Datatype:** positive integer.
| | **Feature Parameters** | | **Feature Parameters**
| `feature_parameters` | A dictionary containing the parameters used to engineer the feature set. Details and examples shown [here](#building-the-feature-set) <br> **Datatype:** dictionary. | `feature_parameters` | A dictionary containing the parameters used to engineer the feature set. Details and examples shown [here](#feature-engineering) <br> **Datatype:** dictionary.
| `include_corr_pairlist` | A list of correlated coins that FreqAI will add as additional features to all `pair_whitelist` coins. All indicators set in `populate_any_indicators` will be created for each coin in this list, and that set of features is added to the base asset feature set. <br> **Datatype:** list of assets (strings). | `include_corr_pairlist` | A list of correlated coins that FreqAI will add as additional features to all `pair_whitelist` coins. All indicators set in `populate_any_indicators` will be created for each coin in this list, and that set of features is added to the base asset feature set. <br> **Datatype:** list of assets (strings).
| `include_timeframes` | A list of timeframes that all indicators in `populate_any_indicators` will be created for and added as features to the base asset feature set. <br> **Datatype:** list of timeframes (strings). | `include_timeframes` | A list of timeframes that all indicators in `populate_any_indicators` will be created for and added as features to the base asset feature set. <br> **Datatype:** list of timeframes (strings).
| `label_period_candles` | Number of candles into the future that the labels are created for. This is used in `populate_any_indicators`, refer to `templates/FreqaiExampleStrategy.py` for detailed usage. The user can create custom labels, making use of this parameter not. <br> **Datatype:** positive integer. | `label_period_candles` | Number of candles into the future that the labels are created for. This is used in `populate_any_indicators`, refer to `templates/FreqaiExampleStrategy.py` for detailed usage. The user can create custom labels, making use of this parameter not. <br> **Datatype:** positive integer.
| `include_shifted_candles` | Parameter used to add a sense of temporal recency to flattened regression type input data. `include_shifted_candles` takes all features, duplicates and shifts them by the number indicated by user. <br> **Datatype:** positive integer. | `include_shifted_candles` | Parameter used to add a sense of temporal recency to flattened regression type input data. `include_shifted_candles` takes all features, duplicates and shifts them by the number indicated by user. <br> **Datatype:** positive integer.
| `DI_threshold` | Activates the Dissimilarity Index for outlier detection when above 0, explained more [here](#removing-outliers-with-the-dissimilarity-index). <br> **Datatype:** positive float (typically below 1). | `DI_threshold` | Activates the Dissimilarity Index for outlier detection when above 0, explained more [here](#removing-outliers-with-the-dissimilarity-index). <br> **Datatype:** positive float (typically below 1).
| `weight_factor` | Used to set weights for training data points according to their recency, see details and a figure of how it works [here](##controlling-the-model-learning-process). <br> **Datatype:** positive float (typically below 1). | `weight_factor` | Used to set weights for training data points according to their recency, see details and a figure of how it works [here](#controlling-the-model-learning-process). <br> **Datatype:** positive float (typically below 1).
| `principal_component_analysis` | Ask FreqAI to automatically reduce the dimensionality of the data set using PCA. <br> **Datatype:** boolean. | `principal_component_analysis` | Ask FreqAI to automatically reduce the dimensionality of the data set using PCA. <br> **Datatype:** boolean.
| `use_SVM_to_remove_outliers` | Ask FreqAI to train a support vector machine to detect and remove outliers from the training data set as well as from incoming data points. <br> **Datatype:** boolean. | `use_SVM_to_remove_outliers` | Ask FreqAI to train a support vector machine to detect and remove outliers from the training data set as well as from incoming data points. <br> **Datatype:** boolean.
| `svm_params` | All parameters available in Sklearn's `SGDOneClassSVM()`. E.g. `nu` *Very* broadly, is the percentage of data points that should be considered outliers. `shuffle` is by default false to maintain reprodicibility. But these and all others can be added/changed in this dictionary. <br> **Datatype:** dictionary. | `svm_params` | All parameters available in Sklearn's `SGDOneClassSVM()`. E.g. `nu` *Very* broadly, is the percentage of data points that should be considered outliers. `shuffle` is by default false to maintain reprodicibility. But these and all others can be added/changed in this dictionary. <br> **Datatype:** dictionary.
@ -133,8 +137,8 @@ Here are the values the user can expect to include/use inside the typical strate
### Example config file ### Example config file
The user interface is isolated to the typical config file. A typical Freqai The user interface is isolated to the typical config file. A typical FreqAI
config setup includes: config setup could include:
```json ```json
"freqai": { "freqai": {
@ -169,7 +173,7 @@ config setup includes:
} }
``` ```
### Building the feature set ### Feature engineering
Features are added by the user inside the `populate_any_indicators()` method of the strategy Features are added by the user inside the `populate_any_indicators()` method of the strategy
by prepending indicators with `%` and labels are added by prepending `&`. by prepending indicators with `%` and labels are added by prepending `&`.
@ -182,7 +186,7 @@ various configuration parameters which multiply the feature set such as `include
```python ```python
def populate_any_indicators( def populate_any_indicators(
self, metadata, pair, df, tf, informative=None, coin="", set_generalized_indicators=False self, pair, df, tf, informative=None, set_generalized_indicators=False
): ):
""" """
Function designed to automatically generate, name and merge features Function designed to automatically generate, name and merge features
@ -198,6 +202,8 @@ various configuration parameters which multiply the feature set such as `include
:param coin: the name of the coin which will modify the feature names. :param coin: the name of the coin which will modify the feature names.
""" """
coint = pair.split('/')[0]
with self.freqai.lock: with self.freqai.lock:
if informative is None: if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf) informative = self.dp.get_pair_dataframe(pair, tf)
@ -265,7 +271,7 @@ various configuration parameters which multiply the feature set such as `include
return df return df
``` ```
The user of the present example does not want to pass the `bb_lowerband` as a feature to the model, The user of the present example does not wish to pass the `bb_lowerband` as a feature to the model,
and has therefore not prepended it with `%`. The user does, however, wish to pass `bb_width` to the and has therefore not prepended it with `%`. The user does, however, wish to pass `bb_width` to the
model for training/prediction and has therefore prepended it with `%`. model for training/prediction and has therefore prepended it with `%`.
@ -313,7 +319,7 @@ set will include all the features from `populate_any_indicators` on all the `inc
`include_shifted_candles` is another user controlled parameter which indicates the number of previous `include_shifted_candles` is another user controlled parameter which indicates the number of previous
candles to include in the present feature set. In other words, `include_shifted_candles: 2`, tells candles to include in the present feature set. In other words, `include_shifted_candles: 2`, tells
Freqai to include the the past 2 candles for each of the features included in the dataset. FreqAI to include the the past 2 candles for each of the features included in the dataset.
In total, the number of features the present user has created is: In total, the number of features the present user has created is:
@ -326,12 +332,12 @@ Users define the backtesting timerange with the typical `--timerange` parameter
configuration file. `train_period_days` is the duration of the sliding training window, while configuration file. `train_period_days` is the duration of the sliding training window, while
`backtest_period_days` is the sliding backtesting window, both in number of days (`backtest_period_days` can be `backtest_period_days` is the sliding backtesting window, both in number of days (`backtest_period_days` can be
a float to indicate sub daily retraining in live/dry mode). In the present example, a float to indicate sub daily retraining in live/dry mode). In the present example,
the user is asking Freqai to use a training period of 30 days and backtest the subsequent 7 days. the user is asking FreqAI to use a training period of 30 days and backtest the subsequent 7 days.
This means that if the user sets `--timerange 20210501-20210701`, This means that if the user sets `--timerange 20210501-20210701`,
Freqai will train 8 separate models (because the full range comprises 8 weeks), FreqAI will train 8 separate models (because the full range comprises 8 weeks),
and then backtest the subsequent week associated with each of the 8 training and then backtest the subsequent week associated with each of the 8 training
data set timerange months. Users can think of this as a "sliding window" which data set timerange months. Users can think of this as a "sliding window" which
emulates Freqai retraining itself once per week in live using the previous emulates FreqAI retraining itself once per week in live using the previous
month of data. month of data.
In live, the required training data is automatically computed and downloaded. However, in backtesting In live, the required training data is automatically computed and downloaded. However, in backtesting
@ -349,16 +355,18 @@ and adding this to the `train_period_days`. The units need to be in the base can
!!! Note !!! Note
Although fractional `backtest_period_days` is allowed, the user should be ware that the `--timerange` is divided by this value to determine the number of models that FreqAI will need to train in order to backtest the full range. For example, if the user wants to set a `--timerange` of 10 days, and asks for a `backtest_period_days` of 0.1, FreqAI will need to train 100 models per pair to complete the full backtest. This is why it is physically impossible to truly backtest FreqAI adaptive training. The best way to fully test a model is to run it dry and let it constantly train. In this case, backtesting would take the exact same amount of time as a dry run. Although fractional `backtest_period_days` is allowed, the user should be ware that the `--timerange` is divided by this value to determine the number of models that FreqAI will need to train in order to backtest the full range. For example, if the user wants to set a `--timerange` of 10 days, and asks for a `backtest_period_days` of 0.1, FreqAI will need to train 100 models per pair to complete the full backtest. This is why it is physically impossible to truly backtest FreqAI adaptive training. The best way to fully test a model is to run it dry and let it constantly train. In this case, backtesting would take the exact same amount of time as a dry run.
## Running Freqai ## Running FreqAI
### Training and backtesting ### Backtesting
The freqai training/backtesting module can be executed with the following command: The FreqAI backtesting module can be executed with the following command:
```bash ```bash
freqtrade backtesting --strategy FreqaiExampleStrategy --config config_freqai.example.json --freqaimodel LightGBMRegressor --timerange 20210501-20210701 freqtrade backtesting --strategy FreqaiExampleStrategy --config config_freqai.example.json --freqaimodel LightGBMRegressor --timerange 20210501-20210701
``` ```
Backtesting mode requires the user to have the data pre-downloaded (unlike dry/live, where FreqAI automatically downloads the necessary data). The user should be careful to consider that the range of the downloaded data is more than the backtesting range. This is because FreqAI needs data prior to the desired backtesting range in order to train a model to be ready to make predictions on the first candle of the user set backtesting range. More details on how to calculate the data download timerange can be found [here](#deciding-the-sliding-training-window-and-backtesting-duration).
If this command has never been executed with the existing config file, then it will train a new model If this command has never been executed with the existing config file, then it will train a new model
for each pair, for each backtesting window within the bigger `--timerange`. for each pair, for each backtesting window within the bigger `--timerange`.
@ -374,7 +382,7 @@ for each pair, for each backtesting window within the bigger `--timerange`.
### Building a freqai strategy ### Building a freqai strategy
The Freqai strategy requires the user to include the following lines of code in the strategy: The FreqAI strategy requires the user to include the following lines of code in the strategy:
```python ```python
@ -419,21 +427,16 @@ FreqAI includes a the `CatboostClassifier` via the flag `--freqaimodel CatboostC
df['&s-up_or_down'] = np.where( df["close"].shift(-100) > df["close"], 'up', 'down') df['&s-up_or_down'] = np.where( df["close"].shift(-100) > df["close"], 'up', 'down')
``` ```
### Building an IFreqaiModel
FreqAI has multiple example prediction model based libraries such as `Catboost` regression (`freqai/prediction_models/CatboostRegressor.py`) and `LightGBM` regression.
However, users can customize and create their own prediction models using the `IFreqaiModel` class.
Users are encouraged to inherit `train()` and `predict()` to let them customize various aspects of their training procedures.
### Running the model live ### Running the model live
Freqai can be run dry/live using the following command FreqAI can be run dry/live using the following command
```bash ```bash
freqtrade trade --strategy FreqaiExampleStrategy --config config_freqai.example.json --freqaimodel ExamplePredictionModel freqtrade trade --strategy FreqaiExampleStrategy --config config_freqai.example.json --freqaimodel LightGBMRegressor
``` ```
By default, Freqai will not find find any existing models and will start by training a new one By default, FreqAI will not find find any existing models and will start by training a new one
given the user configuration settings. Following training, it will use that model to make predictions on incoming candles until a new model is available. New models are typically generated as often as possible, with FreqAI managing an internal queue of the pairs to try and keep all models equally "young." FreqAI will always use the newest trained model to make predictions on incoming live data. If users do not want FreqAI to retrain new models as often as possible, they can set `live_retrain_hours` to tell FreqAI to wait at least that number of hours before retraining a new model. Additionally, users can set `expired_hours` to tell FreqAI to avoid making predictions on models aged over this number of hours. given the user configuration settings. Following training, it will use that model to make predictions on incoming candles until a new model is available. New models are typically generated as often as possible, with FreqAI managing an internal queue of the pairs to try and keep all models equally "young." FreqAI will always use the newest trained model to make predictions on incoming live data. If users do not want FreqAI to retrain new models as often as possible, they can set `live_retrain_hours` to tell FreqAI to wait at least that number of hours before retraining a new model. Additionally, users can set `expired_hours` to tell FreqAI to avoid making predictions on models aged over this number of hours.
If the user wishes to start dry/live from a backtested saved model, the user only needs to reuse If the user wishes to start dry/live from a backtested saved model, the user only needs to reuse
@ -446,7 +449,7 @@ the same `identifier` parameter
} }
``` ```
In this case, although Freqai will initiate with a In this case, although FreqAI will initiate with a
pre-trained model, it will still check to see how much time has elapsed since the model was trained, pre-trained model, it will still check to see how much time has elapsed since the model was trained,
and if a full `live_retrain_hours` has elapsed since the end of the loaded model, FreqAI will self retrain. and if a full `live_retrain_hours` has elapsed since the end of the loaded model, FreqAI will self retrain.
@ -473,7 +476,7 @@ the user is asking for `labels` that are 24 candles in the future.
### Removing outliers with the Dissimilarity Index ### Removing outliers with the Dissimilarity Index
The Dissimilarity Index (DI) aims to quantify the uncertainty associated with each The Dissimilarity Index (DI) aims to quantify the uncertainty associated with each
prediction by the model. To do so, Freqai measures the distance between each training prediction by the model. To do so, FreqAI measures the distance between each training
data point and all other training data points: data point and all other training data points:
$$ d_{ab} = \sqrt{\sum_{j=1}^p(X_{a,j}-X_{b,j})^2} $$ $$ d_{ab} = \sqrt{\sum_{j=1}^p(X_{a,j}-X_{b,j})^2} $$
@ -679,6 +682,11 @@ database setup in a pandas dataframe and ready to be analyzed. Here is an exampl
return return
``` ```
## Building an IFreqaiModel
FreqAI has multiple example prediction model based libraries such as `Catboost` regression (`freqai/prediction_models/CatboostRegressor.py`) and `LightGBM` regression.
However, users can customize and create their own prediction models using the `IFreqaiModel` class.
Users are encouraged to inherit `train()` and `predict()` to let them customize various aspects of their training procedures.
<!-- ## Dynamic target expectation <!-- ## Dynamic target expectation