forked from yasho3115/algorithmresult
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrice.java
71 lines (53 loc) · 1.38 KB
/
Price.java
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
package com.g4.fauxexchange.model;
import java.util.Date;
import java.time.Instant;
import java.text.SimpleDateFormat;
public class Price {
public double change;
public long time;
public double value;
public double alpha;
public double period;
public double price;
public Price() {}
public Price( double value, double period) {
this.value = value;
this.change = 0.0;
this.time = Instant.now().getEpochSecond();
this.alpha = 2.0 / (period + 1.0);
System.out.println("Price:");
}
//@Override
public void reset() {
System.out.println("Price:");
}
//@Override
public double calculate() {
value += alpha * (price - value);
System.out.println("Price:");
return price;
}
//@Override
public String toString() {
return String.format("Price[value='%f', change='%f', time='%d']", value, change, time);
}
// Getters & Setters
public double getValue() {
return this.value;
}
public void setValue( double value) {
this.value = value;
}
public double getChange() {
return this.change;
}
public void setChange(double change) {
this.change = change;
}
public long getTime() {
return this.time;
}
public void setTime( long time) {
this.time = time;
}
}