-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstock.h
86 lines (67 loc) · 1.67 KB
/
stock.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
#ifndef __STOCK_H
#define __STOCK_H
#include <iostream>
#include <string>
#include <vector>
#include <eigen/Eigen/Dense>
using namespace std;
using namespace Eigen;
class Stock {
private:
vector<string> dates;
VectorXf price_open;
VectorXf price_close;
VectorXf price_high;
VectorXf price_low;
VectorXf volume;
public:
VectorXf simple_returns;
VectorXf log_returns;
// Constructor
Stock(
const vector<string>& _dates,
const vector<double>& _price_open,
const vector<double>& _price_close,
const vector<double>& _price_high,
const vector<double>& _price_low,
const vector<double>& _volume);
// Virtual Destructor
virtual ~Stock();
// Main methods
// returns
VectorXf k_period_log_returns(
const unsigned int& k,
const bool& preserve_difference = true) const;
VectorXf k_period_simple_returns(
const unsigned int& k,
const bool& preserve_difference = true) const;
// Prices
VectorXf k_period_log_prices(const unsigned int& k) const;
// statistics
double mean(
const VectorXf& returns) const;
double variance(
const VectorXf& returns) const;
double skewness(
const VectorXf& returns) const;
double excess_kurtosis(
const VectorXf& returns) const;
bool jb_test(
const double& skewness,
const double& excess_kurtosis,
const double& T,
const double& alpha = 0.05) const;
// Getters
vector<string> get_dates() const;
VectorXf get_price_open() const;
VectorXf get_price_close() const;
VectorXf get_price_high() const;
VectorXf get_price_low() const;
VectorXf get_volume() const;
VectorXf get_simple_returns() const;
VectorXf get_log_returns() const;
// Printer
void print_statistics(
const VectorXf& returns) const;
};
#endif