Warning: session_start(): open(/var/lib/php/sessions/sess_l8i0qvdnb3fnketu6erqa6se8l, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass TradingCandle {
// min, max, start and end prices
settable double min = infinity();
settable double max;
settable double start;
settable double end;
settable Timestamp startTime;
settable Timestamp endTime;
settable bool ongoing;
settable S coin;
double openingPrice aka startingPrice aka open() { ret end; }
double closingPrice aka endPrice aka close() { ret end; }
bool isGreen() {
ret end > start;
}
bool isRed() {
ret end < start;
}
bool isWhite() {
ret end == start;
}
S colorText() {
ret isGreen() ? "green"
: isRed() ? "red"
: "white";
}
double durationInSeconds() {
ret toSeconds(endTime.minus(startTime));
}
void addValue(double price, Timestamp timestamp) {
if (price < min) min = price;
if (price > max) max = price;
end = price;
endTime = timestamp;
if (startTime == null) {
startTime = timestamp;
start = price;
}
}
S myType() { ret "candle"; }
toString {
S text = firstToUpper(colorText()) + " " + myType();
if (startTime != null) {
text += " starting " + startTime + ", duration " +
iround(toSeconds(endTime.minus(startTime))) + "s";
text += ", starting price " + formatPrice(start) + ", end price " + formatPrice(end);
text += ", min " + formatPrice(min) + ", max " + formatPrice(max);
}
ret text;
}
double changeRatio() {
ret doubleRatio(end, start);
}
public TradingCandle clone() {
ret shallowClone(this);
}
Color color() {
ret directionToCandleColor(end-start);
}
double hl2 aka mid() { ret avg(min, max); }
double delta aka move() { ret end-start; }
double high() { ret max; }
double low() { ret min; }
}