*/
private double calculateTime(EGenMoney startPrice, EGenMoney endPrice, int startDirection) {
int halfPeriod = period / 2;
// Distance on the price curve from StartPrice to EndPrice (in dollars)
EGenMoney distance;
// Amount of time (in seconds) needed to move $1 on the price curve.
// In half a period the price moves over the entire price range.
double speed = halfPeriod / range.getDollars();
if (startPrice.lessThan(endPrice)) {
if (startDirection > 0) {
distance = EGenMoney.subMoney(endPrice, startPrice);
}
else {
distance = EGenMoney.addMoney(EGenMoney.subMoney(startPrice, rangeLow), EGenMoney.subMoney(endPrice, rangeLow));
}
}
else {
if (startDirection > 0) {
distance = EGenMoney.addMoney(EGenMoney.subMoney(rangeHigh, startPrice), EGenMoney.subMoney(rangeHigh, endPrice));
}
else {
distance = EGenMoney.subMoney(startPrice, endPrice);
}
}
return distance.getDollars() * speed;
}