wiecej zmian
This commit is contained in:
parent
35c3d4f936
commit
17c326d477
5
.gitignore
vendored
5
.gitignore
vendored
@ -20,6 +20,10 @@
|
||||
.*.lb
|
||||
*.pdf
|
||||
|
||||
/macd/
|
||||
/sprawozdanie/*-figure*
|
||||
|
||||
|
||||
## Build tool auxiliary files:
|
||||
*.fdb_latexmk
|
||||
*.synctex
|
||||
@ -27,6 +31,7 @@
|
||||
*.synctex.gz
|
||||
*.synctex.gz(busy)
|
||||
*.pdfsync
|
||||
*.auxlock
|
||||
|
||||
# hyperref
|
||||
*.brf
|
||||
|
2
common.h
2
common.h
@ -2,4 +2,4 @@
|
||||
#include "decider.h"
|
||||
|
||||
// 4 prices, 4 macd, 4 signal, 4 feedback loop
|
||||
using current_decider = neural_decider<6, 8, 8, 4, 8, 8>;
|
||||
using current_decider = neural_decider<6, 8, 8, 2, 12, 8>;
|
||||
|
1000
data/intel.dat
Normal file
1000
data/intel.dat
Normal file
File diff suppressed because it is too large
Load Diff
1260
data/nvidia.dat
Normal file
1260
data/nvidia.dat
Normal file
File diff suppressed because it is too large
Load Diff
681
data/paypal.dat
Normal file
681
data/paypal.dat
Normal file
@ -0,0 +1,681 @@
|
||||
36.709999
|
||||
36.619999
|
||||
34.700001
|
||||
34.5
|
||||
34.689999
|
||||
36.779999
|
||||
36.93
|
||||
37.509998
|
||||
38.630001
|
||||
38.389999
|
||||
40.470001
|
||||
39.349998
|
||||
38.389999
|
||||
37.009998
|
||||
37
|
||||
36.389999
|
||||
37.599998
|
||||
37.950001
|
||||
38.450001
|
||||
38.700001
|
||||
39.389999
|
||||
38.950001
|
||||
39.27
|
||||
38.849998
|
||||
39.130001
|
||||
39.049999
|
||||
38.849998
|
||||
38.189999
|
||||
37.619999
|
||||
38.139999
|
||||
38.73
|
||||
37.990002
|
||||
37.189999
|
||||
35.98
|
||||
34.25
|
||||
33.75
|
||||
32.700001
|
||||
33.169998
|
||||
34.619999
|
||||
35.040001
|
||||
35
|
||||
33.77
|
||||
35.07
|
||||
35.310001
|
||||
34.290001
|
||||
34.700001
|
||||
34.369999
|
||||
33.459999
|
||||
33.549999
|
||||
33.77
|
||||
33.799999
|
||||
33.77
|
||||
33.32
|
||||
32.919998
|
||||
34.25
|
||||
33.349998
|
||||
34.16
|
||||
33.91
|
||||
33.77
|
||||
32.25
|
||||
30.629999
|
||||
31.040001
|
||||
31.48
|
||||
32.830002
|
||||
32.669998
|
||||
31.860001
|
||||
32.380001
|
||||
31.67
|
||||
32.060001
|
||||
32.630001
|
||||
33.220001
|
||||
34.049999
|
||||
34.619999
|
||||
34.290001
|
||||
34.84
|
||||
34.869999
|
||||
33.830002
|
||||
34.790001
|
||||
34.990002
|
||||
36.439999
|
||||
35.939999
|
||||
36.52
|
||||
35.91
|
||||
36.009998
|
||||
36.990002
|
||||
37.900002
|
||||
37.599998
|
||||
36.709999
|
||||
36.240002
|
||||
36.599998
|
||||
37
|
||||
36.330002
|
||||
35.57
|
||||
34.529999
|
||||
35.610001
|
||||
36.209999
|
||||
36.220001
|
||||
36.189999
|
||||
36.360001
|
||||
35.560001
|
||||
35.119999
|
||||
35.360001
|
||||
35.18
|
||||
35.259998
|
||||
35.169998
|
||||
35.150002
|
||||
34.23
|
||||
35.619999
|
||||
35.16
|
||||
35.599998
|
||||
35.07
|
||||
35.490002
|
||||
34.689999
|
||||
35.009998
|
||||
36.32
|
||||
35.98
|
||||
35.540001
|
||||
34.98
|
||||
36.080002
|
||||
36.805
|
||||
37.110001
|
||||
37.07
|
||||
36.610001
|
||||
37.080002
|
||||
36.48
|
||||
36.200001
|
||||
34.75
|
||||
34.310001
|
||||
33.98
|
||||
33.130001
|
||||
32.689999
|
||||
33.040001
|
||||
33.080002
|
||||
32.119999
|
||||
32.869999
|
||||
32.310001
|
||||
32.200001
|
||||
31.200001
|
||||
31.200001
|
||||
31.690001
|
||||
31.469999
|
||||
31.969999
|
||||
31.59
|
||||
34.240002
|
||||
36.139999
|
||||
37.080002
|
||||
36.830002
|
||||
37.009998
|
||||
37.169998
|
||||
35.07
|
||||
33.610001
|
||||
32.700001
|
||||
32.900002
|
||||
33.52
|
||||
34.299999
|
||||
35.459999
|
||||
36.360001
|
||||
36.310001
|
||||
35.759998
|
||||
36
|
||||
35.48
|
||||
36.470001
|
||||
36.740002
|
||||
37.490002
|
||||
38.139999
|
||||
39.25
|
||||
39.16
|
||||
39.02
|
||||
39.040001
|
||||
38.98
|
||||
38.16
|
||||
38.57
|
||||
38.490002
|
||||
39.490002
|
||||
39.380001
|
||||
39.27
|
||||
39.84
|
||||
39.93
|
||||
39.41
|
||||
41.139999
|
||||
41.32
|
||||
40.52
|
||||
38.919998
|
||||
38.740002
|
||||
39.529999
|
||||
39.040001
|
||||
38.599998
|
||||
39.400002
|
||||
38.790001
|
||||
38.549999
|
||||
39.16
|
||||
38.279999
|
||||
38.41
|
||||
38.060001
|
||||
37.799999
|
||||
38.790001
|
||||
38.639999
|
||||
38.580002
|
||||
39.639999
|
||||
39.240002
|
||||
40.080002
|
||||
40.099998
|
||||
40.310001
|
||||
39.82
|
||||
39.73
|
||||
40.009998
|
||||
40.07
|
||||
39.18
|
||||
39.02
|
||||
38.360001
|
||||
38.310001
|
||||
38.950001
|
||||
39.48
|
||||
39.619999
|
||||
40.110001
|
||||
39.709999
|
||||
39.509998
|
||||
39.48
|
||||
39.299999
|
||||
39.064999
|
||||
38.98
|
||||
37.650002
|
||||
37.529999
|
||||
38.07
|
||||
38.919998
|
||||
38.759998
|
||||
38.07
|
||||
38.09
|
||||
37.790001
|
||||
38.310001
|
||||
38.560001
|
||||
38.330002
|
||||
38.099998
|
||||
37.57
|
||||
37.549999
|
||||
37.130001
|
||||
36.77
|
||||
36.540001
|
||||
37.16
|
||||
36.84
|
||||
36.970001
|
||||
36.970001
|
||||
36.860001
|
||||
36.16
|
||||
36
|
||||
36.66
|
||||
35.080002
|
||||
34.200001
|
||||
35.240002
|
||||
35.77
|
||||
36.509998
|
||||
36.349998
|
||||
36.119999
|
||||
35.93
|
||||
36.32
|
||||
37.360001
|
||||
38.150002
|
||||
38.790001
|
||||
39.279999
|
||||
39.959999
|
||||
39.09
|
||||
38.919998
|
||||
39.369999
|
||||
40.049999
|
||||
40.130001
|
||||
37.419998
|
||||
37.779999
|
||||
37.689999
|
||||
37.220001
|
||||
37.220001
|
||||
37.240002
|
||||
37.060001
|
||||
36.540001
|
||||
36.580002
|
||||
37.299999
|
||||
38.099998
|
||||
37.91
|
||||
38.099998
|
||||
38.07
|
||||
38.459999
|
||||
38.509998
|
||||
38.459999
|
||||
38.380001
|
||||
38.139999
|
||||
38.220001
|
||||
38.09
|
||||
38.110001
|
||||
37.860001
|
||||
37.52
|
||||
37.509998
|
||||
37.650002
|
||||
37.290001
|
||||
37
|
||||
37.150002
|
||||
36.830002
|
||||
37.07
|
||||
37.18
|
||||
38.560001
|
||||
39.27
|
||||
38.009998
|
||||
38.77
|
||||
39.860001
|
||||
39.959999
|
||||
40.830002
|
||||
40.700001
|
||||
40.009998
|
||||
39.689999
|
||||
40.290001
|
||||
40.490002
|
||||
40.07
|
||||
40.34
|
||||
41.060001
|
||||
40.970001
|
||||
40.389999
|
||||
40.970001
|
||||
40.59
|
||||
40.779999
|
||||
40.439999
|
||||
40.18
|
||||
39.880001
|
||||
39.860001
|
||||
39.189999
|
||||
39.529999
|
||||
39.200001
|
||||
39.240002
|
||||
39.48
|
||||
39.830002
|
||||
40.240002
|
||||
40.09
|
||||
44.150002
|
||||
43.869999
|
||||
43.310001
|
||||
42.330002
|
||||
41.689999
|
||||
41.759998
|
||||
41.66
|
||||
41.540001
|
||||
41.349998
|
||||
41.189999
|
||||
40.900002
|
||||
41.279999
|
||||
41.580002
|
||||
41.259998
|
||||
40.450001
|
||||
40.080002
|
||||
38.810001
|
||||
38.939999
|
||||
39.07
|
||||
39.880001
|
||||
40.080002
|
||||
40.630001
|
||||
40.330002
|
||||
40.049999
|
||||
40.259998
|
||||
39.959999
|
||||
39.889999
|
||||
39.279999
|
||||
38.34
|
||||
38.619999
|
||||
38.990002
|
||||
38.98
|
||||
39.450001
|
||||
39.610001
|
||||
39.650002
|
||||
39.43
|
||||
39.43
|
||||
39.549999
|
||||
39.540001
|
||||
39.32
|
||||
39.439999
|
||||
39.740002
|
||||
40.09
|
||||
39.68
|
||||
39.580002
|
||||
39.720001
|
||||
39.57
|
||||
39.959999
|
||||
39.470001
|
||||
40.25
|
||||
41
|
||||
41.060001
|
||||
41.450001
|
||||
41.400002
|
||||
41.080002
|
||||
41.279999
|
||||
41.560001
|
||||
41.599998
|
||||
41.27
|
||||
41.349998
|
||||
41.27
|
||||
41.689999
|
||||
41.619999
|
||||
41.959999
|
||||
41.709999
|
||||
41.5
|
||||
40.27
|
||||
39.860001
|
||||
39.779999
|
||||
39.310001
|
||||
39.580002
|
||||
39.59
|
||||
39.740002
|
||||
40.02
|
||||
40.880001
|
||||
40.830002
|
||||
40.580002
|
||||
41.169998
|
||||
41.619999
|
||||
41.869999
|
||||
42.150002
|
||||
41.959999
|
||||
42.43
|
||||
42.419998
|
||||
42.529999
|
||||
43.07
|
||||
42.639999
|
||||
42
|
||||
42.43
|
||||
42.77
|
||||
43.029999
|
||||
42.869999
|
||||
42.889999
|
||||
42.790001
|
||||
42.919998
|
||||
42.990002
|
||||
42.59
|
||||
42.099998
|
||||
42.389999
|
||||
42.400002
|
||||
43.080002
|
||||
43.16
|
||||
42.639999
|
||||
43.189999
|
||||
43.139999
|
||||
43.130001
|
||||
43.080002
|
||||
43.150002
|
||||
43.240002
|
||||
43.540001
|
||||
43.02
|
||||
42.630001
|
||||
42.720001
|
||||
42.889999
|
||||
42.900002
|
||||
43.040001
|
||||
43.049999
|
||||
42.689999
|
||||
42.490002
|
||||
42.549999
|
||||
43.099998
|
||||
43.09
|
||||
43.299999
|
||||
43.689999
|
||||
43.810001
|
||||
44.27
|
||||
44.709999
|
||||
44.41
|
||||
47.150002
|
||||
47.720001
|
||||
47.540001
|
||||
49.049999
|
||||
49.02
|
||||
48.91
|
||||
49.299999
|
||||
49.169998
|
||||
49.220001
|
||||
49.790001
|
||||
49.700001
|
||||
49.369999
|
||||
49.77
|
||||
50.34
|
||||
49.049999
|
||||
49.110001
|
||||
49.389999
|
||||
49.77
|
||||
50.130001
|
||||
51.049999
|
||||
50.93
|
||||
51.189999
|
||||
51.060001
|
||||
52.209999
|
||||
53.16
|
||||
53.52
|
||||
53.799999
|
||||
53.400002
|
||||
53.849998
|
||||
54.389999
|
||||
53.400002
|
||||
52.16
|
||||
52.060001
|
||||
51.900002
|
||||
52.290001
|
||||
51.84
|
||||
52.93
|
||||
52.52
|
||||
53.540001
|
||||
53.869999
|
||||
54.330002
|
||||
53.740002
|
||||
52.73
|
||||
54.389999
|
||||
53.419998
|
||||
53.669998
|
||||
52.869999
|
||||
54.610001
|
||||
53.470001
|
||||
53.970001
|
||||
54.939999
|
||||
54.759998
|
||||
56.549999
|
||||
57.900002
|
||||
57.16
|
||||
57.580002
|
||||
58.959999
|
||||
58.349998
|
||||
59.09
|
||||
58.669998
|
||||
58.580002
|
||||
58.259998
|
||||
58.790001
|
||||
60.150002
|
||||
59.200001
|
||||
58.549999
|
||||
59.34
|
||||
59.119999
|
||||
58.419998
|
||||
58.860001
|
||||
59.619999
|
||||
59.48
|
||||
59.669998
|
||||
58.02
|
||||
58.040001
|
||||
59.060001
|
||||
59.689999
|
||||
60.290001
|
||||
59.290001
|
||||
59.439999
|
||||
59.400002
|
||||
60.84
|
||||
60.049999
|
||||
60
|
||||
59.970001
|
||||
60.529999
|
||||
61.009998
|
||||
61.77
|
||||
61.68
|
||||
61.459999
|
||||
61.27
|
||||
61.240002
|
||||
62
|
||||
61.130001
|
||||
62.639999
|
||||
62.560001
|
||||
62.040001
|
||||
62.240002
|
||||
62.5
|
||||
62.919998
|
||||
63.830002
|
||||
64.739998
|
||||
64.629997
|
||||
65.080002
|
||||
63.5
|
||||
62.939999
|
||||
63.330002
|
||||
63.93
|
||||
64.029999
|
||||
64.18
|
||||
64.220001
|
||||
64.010002
|
||||
65.82
|
||||
66.050003
|
||||
66.230003
|
||||
66.040001
|
||||
67.779999
|
||||
68.860001
|
||||
68.660004
|
||||
67.309998
|
||||
66.669998
|
||||
67.260002
|
||||
67.25
|
||||
70.970001
|
||||
69.800003
|
||||
70.209999
|
||||
71.019997
|
||||
71.339996
|
||||
71.059998
|
||||
71.150002
|
||||
72.559998
|
||||
72.379997
|
||||
72.25
|
||||
73.389999
|
||||
74.739998
|
||||
74.410004
|
||||
74.769997
|
||||
74.099998
|
||||
73.989998
|
||||
74.029999
|
||||
74.489998
|
||||
73.43
|
||||
77.699997
|
||||
76.379997
|
||||
76.010002
|
||||
77.769997
|
||||
77.57
|
||||
78.57
|
||||
77.839996
|
||||
77.790001
|
||||
73.25
|
||||
75.730003
|
||||
75.300003
|
||||
70.970001
|
||||
71.199997
|
||||
73.139999
|
||||
73.690002
|
||||
72.910004
|
||||
73.290001
|
||||
73.620003
|
||||
74.089996
|
||||
74.260002
|
||||
75.650002
|
||||
75.32
|
||||
74.5
|
||||
74
|
||||
74.019997
|
||||
73.889999
|
||||
74.269997
|
||||
74.589996
|
||||
74.169998
|
||||
73.620003
|
||||
73.839996
|
||||
76.75
|
||||
76.730003
|
||||
78.699997
|
||||
79.050003
|
||||
79.190002
|
||||
79.370003
|
||||
79.75
|
||||
80.540001
|
||||
80.419998
|
||||
82.470001
|
||||
82.940002
|
||||
83.839996
|
||||
83.980003
|
||||
84.209999
|
||||
83.709999
|
||||
84.339996
|
||||
85.449997
|
||||
84.309998
|
||||
83.779999
|
||||
85.32
|
||||
78.400002
|
||||
76.57
|
||||
74.705002
|
||||
75.68
|
||||
75.589996
|
||||
72.32
|
||||
74.75
|
||||
75.279999
|
||||
74.970001
|
||||
77.269997
|
||||
78.294998
|
||||
78.370003
|
||||
77.059998
|
||||
76.510002
|
||||
77.699997
|
||||
79.690002
|
||||
79.349998
|
||||
79.459999
|
||||
79.410004
|
||||
78.639999
|
||||
78.870003
|
||||
79.07
|
||||
79.230003
|
||||
79.519997
|
||||
79.870003
|
||||
80.709999
|
||||
80.599998
|
||||
80.199997
|
||||
83.309998
|
||||
82.57
|
||||
82.160004
|
@ -6,6 +6,7 @@ macd_decider::macd_decider(std::size_t limit)
|
||||
|
||||
void macd_decider::process(double price)
|
||||
{
|
||||
count++;
|
||||
prices.add(price);
|
||||
macd.add(ema<double>(prices.begin(), prices.begin() + 12) - ema<double>(prices.begin(), prices.begin() + 26));
|
||||
signal.add(ema<double>(macd.begin(), macd.begin() + 9));
|
||||
@ -16,4 +17,7 @@ void macd_decider::reset(double price)
|
||||
prices = buffer<double>(limit, price);
|
||||
signal = buffer<double>(limit, .0);
|
||||
macd = buffer<double>(limit, .0);
|
||||
|
||||
count = 0;
|
||||
start_price = price;
|
||||
}
|
||||
|
10
decider.h
10
decider.h
@ -26,7 +26,9 @@ protected:
|
||||
buffer<double> macd;
|
||||
buffer<double> signal;
|
||||
|
||||
unsigned count = 0;
|
||||
public:
|
||||
double start_price;
|
||||
macd_decider(std::size_t limit = 1000);
|
||||
|
||||
virtual void process(double price);
|
||||
@ -36,7 +38,7 @@ public:
|
||||
template <int p, int m, int s, int r, int ...layers>
|
||||
class neural_decider : public decider, macd_decider {
|
||||
public:
|
||||
using network_t = network<double, p+m+s+r, layers..., 2+r>;
|
||||
using network_t = network<double, p+m+s+r+2, layers..., 2+r>;
|
||||
using self_t = neural_decider<p, m, s, r, layers...>;
|
||||
|
||||
network_t network;
|
||||
@ -51,6 +53,8 @@ public:
|
||||
{
|
||||
process(price);
|
||||
|
||||
if (count < 35) return 0;
|
||||
|
||||
auto input = prepare(money, stock);
|
||||
auto result = network.evaluate(input);
|
||||
|
||||
@ -108,7 +112,7 @@ private:
|
||||
typename network_t::input prepare(double money, unsigned stock)
|
||||
{
|
||||
vector<double, 2> state = {
|
||||
{ (money - start_money) / start_money },
|
||||
{ (prices[0] * stock + money) / (start_money + start_stock * start_price) },
|
||||
{ (double)stock / this->start_stock }
|
||||
};
|
||||
|
||||
@ -133,7 +137,7 @@ private:
|
||||
// analytic data is normalized in its own domain
|
||||
tech = normalize(tech);
|
||||
|
||||
return concat(concat(prices, tech), feedback);
|
||||
return concat(concat(prices, tech), concat(feedback, state));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
\coordinate (action-1) at (1,0);
|
||||
\coordinate (action-2) at (2,0);
|
||||
\coordinate (action-3) at (23,0);
|
||||
\coordinate (action-4) at (76,0);
|
||||
\coordinate (action-5) at (138,0);
|
||||
\coordinate (action-6) at (201,0);
|
||||
\coordinate (action-7) at (264,0);
|
||||
\coordinate (action-8) at (327,0);
|
||||
\coordinate (action-9) at (390,0);
|
||||
\coordinate (action-10) at (453,0);
|
||||
\coordinate (action-11) at (515,0);
|
||||
\coordinate (action-12) at (578,0);
|
||||
\coordinate (action-13) at (641,0);
|
||||
\coordinate (action-14) at (704,0);
|
||||
\coordinate (action-15) at (767,0);
|
||||
\coordinate (action-16) at (829,0);
|
||||
\coordinate (action-17) at (892,0);
|
||||
\coordinate (action-18) at (955,0);
|
||||
\coordinate (action-1) at (0,0);
|
||||
\coordinate (action-2) at (1,0);
|
||||
\coordinate (action-3) at (22,0);
|
||||
\coordinate (action-4) at (75,0);
|
||||
\coordinate (action-5) at (137,0);
|
||||
\coordinate (action-6) at (200,0);
|
||||
\coordinate (action-7) at (263,0);
|
||||
\coordinate (action-8) at (326,0);
|
||||
\coordinate (action-9) at (389,0);
|
||||
\coordinate (action-10) at (452,0);
|
||||
\coordinate (action-11) at (514,0);
|
||||
\coordinate (action-12) at (577,0);
|
||||
\coordinate (action-13) at (640,0);
|
||||
\coordinate (action-14) at (703,0);
|
||||
\coordinate (action-15) at (766,0);
|
||||
\coordinate (action-16) at (828,0);
|
||||
\coordinate (action-17) at (891,0);
|
||||
\coordinate (action-18) at (954,0);
|
||||
|
@ -190,14 +190,16 @@ public:
|
||||
|
||||
template <std::size_t N> using layer_type = typename layer_types<N, T, in, out, layers...>::type;
|
||||
|
||||
template <std::size_t N> layer_type<N>& get()
|
||||
template <std::size_t N>
|
||||
typename std::enable_if<N != 0, layer_type<N>>::type& get()
|
||||
{
|
||||
return subnetwork.template get<N-1>();
|
||||
}
|
||||
|
||||
template<> layer_type<0>& get<0>()
|
||||
template<std::size_t N>
|
||||
typename std::enable_if<N == 0, layer_type<N>>::type& get()
|
||||
{
|
||||
return base::template get<0>();
|
||||
return base::template get<N>();
|
||||
}
|
||||
|
||||
output evaluate(typename base::input inp)
|
||||
|
25
result.tex
Normal file
25
result.tex
Normal file
@ -0,0 +1,25 @@
|
||||
\begin{groupplot}[width=\linewidth, height=4cm, group style={
|
||||
group size=1 by 4,
|
||||
vertical sep=.2cm,
|
||||
group name=G
|
||||
},
|
||||
axis lines=center,
|
||||
no marks,
|
||||
xtick=\empty, clip=false
|
||||
]
|
||||
\nextgroupplot
|
||||
\addplot +[thick] table [x=no, y=price, col sep=comma] {\file};
|
||||
|
||||
\nextgroupplot[height=3cm]
|
||||
\addplot +[name path global=macd, red] table [x=no, y=macd, col sep=comma] {\file};
|
||||
\addplot +[name path global=signal, blue] table [x=no, y=signal, col sep=comma] {\file};
|
||||
|
||||
\nextgroupplot[height=2cm, ytick=\empty, y axis line style={draw=none}]
|
||||
\addplot +[thick, black] table [x=no, y=delta, col sep=comma] {\file};
|
||||
|
||||
\nextgroupplot[height=3cm]
|
||||
\addplot +[name path global=macd, red] table [x=no, y=macd, col sep=comma] {\file};
|
||||
\addplot +[name path global=signal, blue] table [x=no, y=signal, col sep=comma] {\file};
|
||||
|
||||
\coordinate (safe) at (35,0);
|
||||
\end{groupplot}
|
@ -1,5 +1,5 @@
|
||||
\begin{groupplot}[width=\linewidth, height=4cm, group style={
|
||||
group size=1 by 4,
|
||||
group size=1 by 3,
|
||||
vertical sep=.2cm,
|
||||
group name=G
|
||||
},
|
||||
@ -19,8 +19,5 @@
|
||||
|
||||
\coordinate (safe) at (35,0);
|
||||
\input{\action-c.tex}
|
||||
|
||||
\nextgroupplot[height=3cm]
|
||||
\addplot +[thick, orange] table [x=x, y=decsion, col sep=comma] {\decision};
|
||||
\end{groupplot}
|
||||
\input{\action-a.tex}
|
||||
|
24
sprawozdanie/result.tex
Normal file
24
sprawozdanie/result.tex
Normal file
@ -0,0 +1,24 @@
|
||||
\begin{groupplot}[width=\linewidth, height=4cm, group style={
|
||||
group size=1 by 4,
|
||||
vertical sep=.2cm,
|
||||
group name=G
|
||||
},
|
||||
axis lines=center,
|
||||
no marks,
|
||||
xtick=\empty, clip=false
|
||||
]
|
||||
\nextgroupplot
|
||||
\addplot +[thick] table [x=no, y=price, col sep=comma] {\file};
|
||||
|
||||
\nextgroupplot[height=3cm]
|
||||
\addplot +[orange] table [x=x, y=decsion, col sep=comma] {\action};
|
||||
|
||||
\nextgroupplot[height=2cm, ytick=\empty, y axis line style={draw=none}]
|
||||
\addplot +[thick, black] table [x=no, y=delta, col sep=comma] {\file};
|
||||
|
||||
\nextgroupplot[height=2cm]
|
||||
\addplot +[name path global=macd, red] table [x=no, y=macd, col sep=comma] {\file};
|
||||
\addplot +[name path global=signal, blue] table [x=no, y=signal, col sep=comma] {\file};
|
||||
|
||||
\coordinate (safe) at (35,0);
|
||||
\end{groupplot}
|
@ -29,6 +29,8 @@
|
||||
|
||||
\pgfplotsset{compat=1.15}
|
||||
\usepgfplotslibrary{groupplots}
|
||||
\usepgfplotslibrary{external}
|
||||
\tikzexternalize
|
||||
|
||||
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
|
||||
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
|
||||
@ -47,18 +49,172 @@
|
||||
|
||||
\floatname{algorithm}{Program}
|
||||
|
||||
\newcommand{\macd}[1]{\def\file{../macd/#1.dat}\def\action{../macd/#2-intersect.dat}\input{macd.tex}}
|
||||
\newcommand{\macd}[1]{%
|
||||
\begin{tikzpicture}
|
||||
\def\file{../macd/#1.csv}
|
||||
\def\action{../macd/#1-intersect}
|
||||
\input{macd.tex}
|
||||
\end{tikzpicture}%
|
||||
}
|
||||
|
||||
\newcommand{\result}[2]{%
|
||||
\begin{tikzpicture}
|
||||
\def\file{../macd/#1.csv}
|
||||
\def\action{#2.csv}
|
||||
\input{result.tex}
|
||||
\end{tikzpicture}%
|
||||
}
|
||||
|
||||
\tikzstyle{sell}=[red, -latex, densely dotted]
|
||||
\tikzstyle{buy}=[green, latex-, densely dotted]
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
\section{Cel projektu}
|
||||
Założeniem projektu było stworzenie programu, który umożliwiałby wyznaczenie wskaźnika giełdowego MACD. Drugim zadaniem
|
||||
było opracowanie programu, który automatycznie podejmowałby decyzje kupna bądź sprzedaży na podstawie analizy dostępnych
|
||||
mu danych.
|
||||
|
||||
\section{Analiza wskaźnika MACD}
|
||||
Wskaźnik MACD składa się z 2 powiązanych ze sobą wskaźników - wskaźnika rozbieżności między trendem krótkotrwałym oraaz
|
||||
długotrwałym, oraz wskaźnika sygnału stanowiącego średnią tej rozbieżności. Do wyznaczenia obu tych wskaźników
|
||||
wykorzystuje się średnie z danych historycznych. Przyjęło się, że poprzez trend długotrwały rozumiemy średnią z
|
||||
ostatnich 26 dni, krótkotrwały z 12 dni a sygnał jest średnią z ostatnich 9 dni.
|
||||
|
||||
Tak niska granulacja danych wynika z faktu, że w czasie opracowania wskaźnika nie było możliwości dostępu do danych o
|
||||
większej granulacji niż dniowa, i najczęściej na podstawie tego typu danych musiano podejmować decyzje kupna bądź
|
||||
sprzedaży. Dobór rozmiaru okien czasowych również w czasie opracowania prawdopodobnie był nieprzypadkowy - przy 6
|
||||
dniowym tygodniu handlowym 12 dni stanowiło 2 tygodnie, 9 dni półtora a 26 miesiąc i pół tygodnia - zatem zgodnie z ideą
|
||||
prawdopodobnie właściwym doborem parametrów dla aktualnych czasów byłyby średnie z ostatnich 22, 10 oraz 7 dni.
|
||||
|
||||
Ze względu na oparcie wskaźnika na ostatnich $n$-wartościach historycznych, reakcja wskaźnika na zachowania inwestorów
|
||||
zawsze jest opóźniona i nie radzi sobie za dobrze w wypadku nagłych gwałtownych spadków cen - w sytuacji, w której
|
||||
sprawny inwestor podjąłby szybką decyzję sprzedaży akcji, wskaźnik zasugeruje taką decyzję z drobnym, najczęściej około
|
||||
2-3 dniowym opóźnieniem.
|
||||
|
||||
Dodatkowo jak można zaobserwować na niemal wszystkich wykresach, informacje pochodzące ze wskaźnika generują znaczny
|
||||
szum w momentach, w których giełda zachowuje się relatywnie stabilnie generując wiele sygnałów o ostatecznie zerowym
|
||||
znaczeniu inwestycyjnym.
|
||||
|
||||
\begin{figure}[H]
|
||||
\begin{tikzpicture}
|
||||
\macd{sin}
|
||||
\end{tikzpicture}
|
||||
\caption{XD}
|
||||
\macd{fb}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Facebook}
|
||||
\end{figure}
|
||||
|
||||
Patrząc na powyższy wykres widzimy ogromną ilość sygnałów do kupna oraz sprzedaży, jednak część z nich stanowi całkiem
|
||||
kompetentny licznik modulo 2, sugerujący sprzedaż akcji jednego dnia tylko po to by kupić je następnego.
|
||||
Wyznacznik ten sprawdza się jednak całkiem dobrze w wypadku nagłych wzrostów, po których następuje stabilizacja -
|
||||
najczęściej całkiem dobrze przewidując moment w którym będzie bezpiecznie sprzedać bez tracenia ewentualnych zysków.
|
||||
|
||||
Dodatkowo ze względu na to, że jest to wyznacznik dość dobrze rozpowszechniony wśród osób niedoświadczonych istnieje
|
||||
niezerowe ryzyko wystąpienia zjawiska samoindukcji wskaźnika.
|
||||
|
||||
Jak wcześniej zauważono, ze względu na budowę wskaźnik ten zawsze będzie miał drobne opóźnienie względem aktualnej
|
||||
sytuacji na giełdzie. W niektórych wypadkach jednak istnieje nieorawdopodobna wręcz zgodność zachowania wykresu
|
||||
giełdowego z przewidywaniami wskaźnika. Sytuację te można zaobserwować na wyżej wymienionym wykresie firmy facebook.
|
||||
Ponieważ inwestorzy opierają się i sugerują wskaźnikiem może wystąpić sytuacja, w której wskaźnik sprawdzi się wyjątkowo
|
||||
dobrze tylko ze względu na to, że inwestorzy sugerując się nim podjęli decyzję nagłej sprzedaży.
|
||||
|
||||
\section{Automatyczne zarabianie}
|
||||
|
||||
Wnioski:
|
||||
\begin{itemize}
|
||||
\item Sieć kurewsko trudno wytrenować
|
||||
\item Najlepiej powierzyć te zadanie kotu, chodząc po klawiaturze ma równe szanse na dobre inwestycje co program
|
||||
\item
|
||||
\end{itemize}
|
||||
|
||||
\appendix
|
||||
|
||||
\section{Wykresy wskaźników dla różnych spółek giełdowych}
|
||||
\begin{figure}[H]
|
||||
\macd{11bit}
|
||||
\caption{Wskaźnik MACD oraz Signal dla 11-bit studios}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{amazon}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Amazon}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{apple}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Apple}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{bitcoin}
|
||||
\caption{Wskaźnik MACD oraz Signal dla Bitcoina}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{cdr}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy CD Projekt Red}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{dogecoin}
|
||||
\caption{Wow, such MACD, many SIGNAL, wow.}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{dow30}
|
||||
\caption{Wskaźnik MACD oraz Signal dla indeksu Dow Jones}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{fb}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Facebook}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{google}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Google}
|
||||
\end{figure}
|
||||
%
|
||||
\begin{figure}[H]
|
||||
\macd{intel}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Intel}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{ltc}
|
||||
\caption{Wskaźnik MACD oraz Signal dla kryptowaluty Litecoin}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{msft}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Microsoft}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{nasdaq}
|
||||
\caption{Wskaźnik MACD oraz Signal dla giełdy NASDAQ}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{nvidia}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Nvidia}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{paypal}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy PayPal}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{sin}
|
||||
\caption{Cóż... XD}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{tesla}
|
||||
\caption{Wskaźnik MACD oraz Signal dla firmy Tesla}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[H]
|
||||
\macd{wig20}
|
||||
\caption{Wskaźnik MACD oraz Signal dla indeksu WIG20}
|
||||
\end{figure}
|
||||
\end{document}
|
||||
|
@ -31,7 +31,7 @@ int main(int argc, const char* argv[])
|
||||
args({"s", "stock"}, 1000) >> start_stock;
|
||||
args({"m", "money"}, 1000.) >> start_money;
|
||||
|
||||
std::function<double(const double&)> normalizer = [](const double& result) -> double { return erf(result); };
|
||||
std::function<double(const double&)> normalizer = [](const double& result) -> double { return result / (1 + abs(result)); };
|
||||
|
||||
std::ifstream network_file(network, std::ios::in | std::ios::binary);
|
||||
std::ifstream input_file;
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char* argv[])
|
||||
return distribution(random_engine);
|
||||
};
|
||||
|
||||
std::function<double(const double&)> normalizer = [](const double& result) -> double { return erf(result); };
|
||||
std::function<double(const double&)> normalizer = [](const double& result) -> double { return result / (1 + abs(result)); };
|
||||
|
||||
std::function<current_decider ()> factory = [&]() -> current_decider {
|
||||
current_decider decider(normalizer);
|
||||
|
10
trainer.h
10
trainer.h
@ -47,7 +47,7 @@ public:
|
||||
auto hodl = input.back() * this->stock + this->money;
|
||||
|
||||
auto result = std::min((current - hodl)/hodl, (current - start)/start);
|
||||
if (result < 0) result *= 5;
|
||||
/* if (result < 0) result *= 4; */
|
||||
return result / (1 + abs(result));
|
||||
};
|
||||
add(n);
|
||||
@ -95,7 +95,7 @@ public:
|
||||
simulator sim(&(trainee->decider), this->money, this->stock);
|
||||
sim.proceed(input);
|
||||
|
||||
trainee->score += q(trainee, input, sim.money, sim.stock);
|
||||
trainee->score = std::min(trainee->score, q(trainee, input, sim.money, sim.stock));
|
||||
|
||||
auto last = input.back();
|
||||
auto first = input.front();
|
||||
@ -147,7 +147,7 @@ public:
|
||||
}
|
||||
|
||||
std::discrete_distribution<unsigned> distribution(probability.begin(), probability.end());
|
||||
std::exponential_distribution<double> exponential(1.5);
|
||||
std::exponential_distribution<double> exponential(2.5);
|
||||
std::uniform_real_distribution<double> ratio(0.0, 1.0);
|
||||
|
||||
auto combiner = [=](const double& a, const double& b){
|
||||
@ -160,11 +160,13 @@ public:
|
||||
};
|
||||
|
||||
auto mutator = [=](const double& a) {
|
||||
if(ratio(random_engine) < .25) return a;
|
||||
|
||||
auto mutation = (rand() % 2 ? -1 : 1) * exponential(random_engine);
|
||||
return a + mutation;
|
||||
};
|
||||
|
||||
std::size_t to_combine = diff * 0.4, to_mutate = diff * 0.4;
|
||||
std::size_t to_combine = diff * 0.5, to_mutate = diff * 0.3;
|
||||
|
||||
unsigned first, second;
|
||||
for (int i = 0; i < to_combine; i++) {
|
||||
|
1247
wig20/alr_d.dat
Normal file
1247
wig20/alr_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/bzw_d.dat
Normal file
1247
wig20/bzw_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/ccc_d.dat
Normal file
1247
wig20/ccc_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/cps_d.dat
Normal file
1247
wig20/cps_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1067
wig20/eng_d.dat
Normal file
1067
wig20/eng_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/eur_d.dat
Normal file
1247
wig20/eur_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/jsw_d.dat
Normal file
1247
wig20/jsw_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/kgh_d.dat
Normal file
1247
wig20/kgh_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/lpp_d.dat
Normal file
1247
wig20/lpp_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/lts_d.dat
Normal file
1247
wig20/lts_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/mbk_d.dat
Normal file
1247
wig20/mbk_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/opl_d.dat
Normal file
1247
wig20/opl_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/peo_d.dat
Normal file
1247
wig20/peo_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/pge_d.dat
Normal file
1247
wig20/pge_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/pgn_d.dat
Normal file
1247
wig20/pgn_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/pkn_d.dat
Normal file
1247
wig20/pkn_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/pko_d.dat
Normal file
1247
wig20/pko_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/pzu_d.dat
Normal file
1247
wig20/pzu_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
1247
wig20/tpe_d.dat
Normal file
1247
wig20/tpe_d.dat
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user