This repository has been archived by the owner on Feb 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
TradingSystem.h
105 lines (99 loc) · 4.06 KB
/
TradingSystem.h
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
#pragma once
#include "stdafx.h"
#include <functional>
#include "models/Candlestick.h"
#include "BinaryTreeChromosome.h"
#include "indicators/Indicator.h"
#include "BinaryTreeFitness.h"
#include "BinaryTreeGeneticAlgo.h"
/**
* This is the entry point to the whole calculation systems
* TradingSystem class groups all the more specific classes to one simple
* interface
*/
class TradingSystem
{
public:
/**
* Performs an analysis over specified candlestick set using specified indicators
* and options and returns the best fit strategy embedded in BinaryTreeChromosome
* class
*
* @param candlesticks An input vector of candlesticks used
* for whole analytis. The more the better
* but also slower
*
* @param indicators An input vector of configured
* indicators used for creating
* strategies
*
* @param populationCount The total population count within
* one generation
*
* @param generationCount The total generation count
*
* @param selectionAmount How many chromosomes shall be
* selected from the old generation
* when constructing a new one
*
* @param leafValueMutationProbability probability for changing the leaf
* value (0.0 - 1.0)
*
* @param leafSignMutationProbability probabolity for changing the leaf
* sign (0.0 - 1.0)
*
* @param logicalNodeMutationProbability probabolity for changing the logica
* node (0.0 - 1.0)
*
* @param leafIndicatorMutationProbability probability for changing the leaf
* indicator (0.0 - 1.0)
*
* @param crossoverProbability Probability for performing crossover
* (0.0 - 1.0)
*
* @param update Lambda expression called during progress update
* @return The best fit chromosome found
*/
BinaryTreeChromosome* PerformAnalysis(
const std::vector<Candlestick>& candlesticks,
const std::vector<BaseIndicator*>& indicators,
unsigned populationCount,
unsigned generationCount,
unsigned selectionAmount,
double leafValueMutationProbability,
double leafSignMutationProbability,
double logicalNodeMutationProbability,
double leafIndicatorMutationProbability,
double crossoverProbability,
BinaryTreeChromosome* chromosomeToStartWith,
std::function<void(double fitness, BinaryTreeChromosome * chromosome, int generation)> update);
/**
* Converts candlestick values to giher timeframe specified by second interval
*
* @param bars_to_convert The input vector of candlestick that shall
* be converted
*
* @param seconds The timeframe specified in seconds to which
* the ohlc vector shall be converted to
*
* @return New vector of candlesticks as a result
* of defined conversion
*/
std::vector<Candlestick> ConvertOHLCToLargerTimeframe(
const std::vector<Candlestick>& bars_to_convert,
int seconds);
/**
* Evaluates the given candlesticks and indicatros and returns data for all
* specified indicators
*
* @param candlesticks Input vector of candlesticks
*
* @param indicators Defined indicators
*
* @return Vector of data assigned to a different
* indicators in a map
*/
std::vector<IndicatorTuple> EvaluateCandlesticks(
const std::vector<Candlestick>& candlesticks,
const std::vector<BaseIndicator*> &indicators);
};