-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPosition.cpp
58 lines (51 loc) · 1.74 KB
/
Position.cpp
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
/*
* Position.cpp
*
* Created on: Oct 23, 2016
* Author: Vadim
*/
#include "Position.h"
//3b. A constructor
Position::Position(Asset* pAsset, int quantity, double costPriceOfPosition,
double positionAge) {
this->pAsset = pAsset;
this->quantity = quantity;
this->costPriceOfPosition = costPriceOfPosition;
this->positionAge = positionAge;
}
//3c. A destructor
Position::~Position() {
}
//3d. A function getQuantity() to return the quantity of the asset held in position
int Position::getQuantity() {
return quantity;
}
//3e. A function getSymbol() to return the asset symbol of the position
string Position::getSymbol() {
return pAsset->getAssetSymbol();
}
//3f. A function getAssetType() to return the type of asset of the position
string Position::getAssetType() {
return pAsset->getAssetType();
}
//3g. A function getPosAge() to return the age of the position
double Position::getPosAge() {
return positionAge;
}
//3h. A function getCurrentPrice() to return the current price of the position
double Position::getCurrentPrice() {
return pAsset->getCurrentAssetPrice();
}
//3i. A function getTotalReturn() to return the total return of the position since inception
double Position::getTotalReturn(){
//we still need initial price, but positionAge we have inside our class
return pAsset->totalReturn(costPriceOfPosition,positionAge);
}
//3j. A function getCurrentValue() to return the current total dollar value of the position
double Position::getCurrentValue(){
return quantity * (pAsset->getCurrentAssetPrice());
}
//3k. A function getCostBasis() to return the total dollar cost of the position at purchase
double Position::getCostBasis(){
return this-> costPriceOfPosition * quantity;
}