-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStockClass.cpp
More file actions
34 lines (30 loc) · 744 Bytes
/
StockClass.cpp
File metadata and controls
34 lines (30 loc) · 744 Bytes
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
#include "StockClass.h"
using namespace std;
void StockClass::setData(float d)
{
data.push_back(d);
}
float StockClass::calcDailyPnL(int x)
{
float dailyPnL = 0.0;
dailyPnL = data[x] / data[x - 1] - 1;
return dailyPnL;
}
float StockClass::calcMovingAvg(int x, int y)
{
float movingAvg = 0.0;
for (int i = x - 1; i > (x - y - 1); i--)
{
movingAvg += (data[i]);
}
return (movingAvg / static_cast<float>(y));
}
float StockClass::getDayData(int x)
{
return data[x];
}
float StockClass::benchMark() {
float benchMark;
benchMark = data.back() / data[0];
return benchMark;
}