-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPut.java
More file actions
29 lines (26 loc) · 737 Bytes
/
Put.java
File metadata and controls
29 lines (26 loc) · 737 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
public class Put implements Holding {
private double strikePrice;
private double premium;
private boolean Buy;
Put(double strikePrice, double premium, boolean Buy) {
this.strikePrice = strikePrice;
this.premium = premium;
this.Buy = Buy;
}
public double end(double stockPrice) {
if (stockPrice <= strikePrice) {
double valuereturn = (strikePrice - stockPrice) * 100 - premium;
if (Buy) {
return valuereturn;
} else {
return -valuereturn;
}
} else {
if (Buy) {
return -premium;
} else {
return premium;
}
}
}
}