X: NFT - Method reordering
This commit is contained in:
@@ -50,6 +50,125 @@ public final class EvelynMissionControlImpl implements
|
||||
javaFxRuntimeService.runLater(this::showWindow);
|
||||
}
|
||||
|
||||
static StatusIndexChart createStatusIndexChart() {
|
||||
NumberAxis xAxis = new NumberAxis(0, 1, 1);
|
||||
xAxis.setLabel("Time");
|
||||
xAxis.setTickLabelFormatter(TIMESTAMP_FORMATTER);
|
||||
xAxis.setForceZeroInRange(false);
|
||||
|
||||
double yBound = EMPTY_Y_BOUND;
|
||||
NumberAxis yAxis = new NumberAxis(-yBound, yBound, yBound / 5.0);
|
||||
yAxis.setLabel("Index value");
|
||||
yAxis.setForceZeroInRange(true);
|
||||
|
||||
LineChart<Number, Number> chart = new LineChart<>(xAxis, yAxis);
|
||||
chart.setTitle("Evelyn Status Index History");
|
||||
chart.setCreateSymbols(false);
|
||||
chart.setAnimated(false);
|
||||
XYChart.Series<Number, Number> priceIndexSeries = createSeries(
|
||||
"Evelyn Price Index",
|
||||
List.of(),
|
||||
EvelynStatusIndexPoint::evelynPriceIndex
|
||||
);
|
||||
chart.getData().add(priceIndexSeries);
|
||||
//chart.getData().add(createSeries("EVE_SYRUP Pool Depth Index", history, EvelynStatusIndexPoint::eveSyrupPoolDepthIndex));
|
||||
//chart.getData().add(createSeries("EVE_SYRUP Pool Balance Index", history, EvelynStatusIndexPoint::eveSyrupPoolBalanceIndex));
|
||||
//chart.getData().add(createSeries("AAZDKK_USDT Pool Balance Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolBalanceIndex));
|
||||
//chart.getData().add(createSeries("AAZDKK_USDT Pool Price Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolPriceIndex));
|
||||
//chart.getData().add(createSeries("AAZDKK_USDT Pool Depth Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolDepthIndex));
|
||||
return new StatusIndexChart(chart, xAxis, yAxis, priceIndexSeries);
|
||||
}
|
||||
|
||||
static double calculateYBound(List<EvelynStatusIndexPoint> history) {
|
||||
BigDecimal maxAbsoluteValue = BigDecimal.ZERO;
|
||||
for (EvelynStatusIndexPoint point : history) {
|
||||
maxAbsoluteValue = max(maxAbsoluteValue, point.evelynPriceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolDepthIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolBalanceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolBalanceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolPriceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolDepthIndex());
|
||||
}
|
||||
|
||||
double bound = maxAbsoluteValue.doubleValue();
|
||||
return bound == 0.0 ? EMPTY_Y_BOUND : bound;
|
||||
}
|
||||
|
||||
static void refreshChart(
|
||||
StatusIndexChart statusIndexChart,
|
||||
List<EvelynStatusIndexPoint> history
|
||||
) {
|
||||
if (!Platform.isFxApplicationThread()) {
|
||||
throw new IllegalStateException("Status-index charts must be updated on the JavaFX Application Thread");
|
||||
}
|
||||
|
||||
int commonPointCount = 0;
|
||||
int maximumCommonPointCount = Math.min(
|
||||
history.size(),
|
||||
statusIndexChart.renderedHistory.size()
|
||||
);
|
||||
while (commonPointCount < maximumCommonPointCount
|
||||
&& history.get(commonPointCount).equals(
|
||||
statusIndexChart.renderedHistory.get(commonPointCount)
|
||||
)) {
|
||||
commonPointCount++;
|
||||
}
|
||||
if (commonPointCount < statusIndexChart.renderedHistory.size()) {
|
||||
statusIndexChart.priceIndexSeries().getData().clear();
|
||||
statusIndexChart.renderedHistory = List.of();
|
||||
commonPointCount = 0;
|
||||
}
|
||||
for (int index = commonPointCount; index < history.size(); index++) {
|
||||
EvelynStatusIndexPoint point = history.get(index);
|
||||
statusIndexChart.priceIndexSeries().getData().add(new XYChart.Data<>(
|
||||
point.timestamp().toEpochMilli(),
|
||||
point.evelynPriceIndex()
|
||||
));
|
||||
}
|
||||
statusIndexChart.renderedHistory = List.copyOf(history);
|
||||
updateAxisBounds(statusIndexChart, history);
|
||||
}
|
||||
|
||||
static final class StatusIndexChart {
|
||||
private StatusIndexChart(
|
||||
LineChart<Number, Number> chart,
|
||||
NumberAxis xAxis,
|
||||
NumberAxis yAxis,
|
||||
XYChart.Series<Number, Number> priceIndexSeries
|
||||
) {
|
||||
this.chart = chart;
|
||||
this.xAxis = xAxis;
|
||||
this.yAxis = yAxis;
|
||||
this.priceIndexSeries = priceIndexSeries;
|
||||
}
|
||||
|
||||
LineChart<Number, Number> chart() {
|
||||
return chart;
|
||||
}
|
||||
|
||||
NumberAxis xAxis() {
|
||||
return xAxis;
|
||||
}
|
||||
|
||||
NumberAxis yAxis() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
XYChart.Series<Number, Number> priceIndexSeries() {
|
||||
return priceIndexSeries;
|
||||
}
|
||||
|
||||
private final LineChart<Number, Number> chart;
|
||||
private final NumberAxis xAxis;
|
||||
private final NumberAxis yAxis;
|
||||
private final XYChart.Series<Number, Number> priceIndexSeries;
|
||||
private List<EvelynStatusIndexPoint> renderedHistory = List.of();
|
||||
}
|
||||
|
||||
private static BigDecimal max(BigDecimal currentMaximum, BigDecimal candidate) {
|
||||
return currentMaximum.max(candidate.abs());
|
||||
}
|
||||
|
||||
private void showWindow() {
|
||||
if (window != null && window.isShowing()) {
|
||||
window.toFront();
|
||||
@@ -93,35 +212,6 @@ public final class EvelynMissionControlImpl implements
|
||||
return tab;
|
||||
}
|
||||
|
||||
static StatusIndexChart createStatusIndexChart() {
|
||||
NumberAxis xAxis = new NumberAxis(0, 1, 1);
|
||||
xAxis.setLabel("Time");
|
||||
xAxis.setTickLabelFormatter(TIMESTAMP_FORMATTER);
|
||||
xAxis.setForceZeroInRange(false);
|
||||
|
||||
double yBound = EMPTY_Y_BOUND;
|
||||
NumberAxis yAxis = new NumberAxis(-yBound, yBound, yBound / 5.0);
|
||||
yAxis.setLabel("Index value");
|
||||
yAxis.setForceZeroInRange(true);
|
||||
|
||||
LineChart<Number, Number> chart = new LineChart<>(xAxis, yAxis);
|
||||
chart.setTitle("Evelyn Status Index History");
|
||||
chart.setCreateSymbols(false);
|
||||
chart.setAnimated(false);
|
||||
XYChart.Series<Number, Number> priceIndexSeries = createSeries(
|
||||
"Evelyn Price Index",
|
||||
List.of(),
|
||||
EvelynStatusIndexPoint::evelynPriceIndex
|
||||
);
|
||||
chart.getData().add(priceIndexSeries);
|
||||
//chart.getData().add(createSeries("EVE_SYRUP Pool Depth Index", history, EvelynStatusIndexPoint::eveSyrupPoolDepthIndex));
|
||||
//chart.getData().add(createSeries("EVE_SYRUP Pool Balance Index", history, EvelynStatusIndexPoint::eveSyrupPoolBalanceIndex));
|
||||
//chart.getData().add(createSeries("AAZDKK_USDT Pool Balance Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolBalanceIndex));
|
||||
//chart.getData().add(createSeries("AAZDKK_USDT Pool Price Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolPriceIndex));
|
||||
//chart.getData().add(createSeries("AAZDKK_USDT Pool Depth Index", history, EvelynStatusIndexPoint::aazdkkUsdtPoolDepthIndex));
|
||||
return new StatusIndexChart(chart, xAxis, yAxis, priceIndexSeries);
|
||||
}
|
||||
|
||||
private static XYChart.Series<Number, Number> createSeries(
|
||||
String name,
|
||||
List<EvelynStatusIndexPoint> history,
|
||||
@@ -138,60 +228,6 @@ public final class EvelynMissionControlImpl implements
|
||||
return series;
|
||||
}
|
||||
|
||||
static double calculateYBound(List<EvelynStatusIndexPoint> history) {
|
||||
BigDecimal maxAbsoluteValue = BigDecimal.ZERO;
|
||||
for (EvelynStatusIndexPoint point : history) {
|
||||
maxAbsoluteValue = max(maxAbsoluteValue, point.evelynPriceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolDepthIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.eveSyrupPoolBalanceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolBalanceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolPriceIndex());
|
||||
//maxAbsoluteValue = max(maxAbsoluteValue, point.aazdkkUsdtPoolDepthIndex());
|
||||
}
|
||||
|
||||
double bound = maxAbsoluteValue.doubleValue();
|
||||
return bound == 0.0 ? EMPTY_Y_BOUND : bound;
|
||||
}
|
||||
|
||||
private static BigDecimal max(BigDecimal currentMaximum, BigDecimal candidate) {
|
||||
return currentMaximum.max(candidate.abs());
|
||||
}
|
||||
|
||||
static void refreshChart(
|
||||
StatusIndexChart statusIndexChart,
|
||||
List<EvelynStatusIndexPoint> history
|
||||
) {
|
||||
if (!Platform.isFxApplicationThread()) {
|
||||
throw new IllegalStateException("Status-index charts must be updated on the JavaFX Application Thread");
|
||||
}
|
||||
|
||||
int commonPointCount = 0;
|
||||
int maximumCommonPointCount = Math.min(
|
||||
history.size(),
|
||||
statusIndexChart.renderedHistory.size()
|
||||
);
|
||||
while (commonPointCount < maximumCommonPointCount
|
||||
&& history.get(commonPointCount).equals(
|
||||
statusIndexChart.renderedHistory.get(commonPointCount)
|
||||
)) {
|
||||
commonPointCount++;
|
||||
}
|
||||
if (commonPointCount < statusIndexChart.renderedHistory.size()) {
|
||||
statusIndexChart.priceIndexSeries().getData().clear();
|
||||
statusIndexChart.renderedHistory = List.of();
|
||||
commonPointCount = 0;
|
||||
}
|
||||
for (int index = commonPointCount; index < history.size(); index++) {
|
||||
EvelynStatusIndexPoint point = history.get(index);
|
||||
statusIndexChart.priceIndexSeries().getData().add(new XYChart.Data<>(
|
||||
point.timestamp().toEpochMilli(),
|
||||
point.evelynPriceIndex()
|
||||
));
|
||||
}
|
||||
statusIndexChart.renderedHistory = List.copyOf(history);
|
||||
updateAxisBounds(statusIndexChart, history);
|
||||
}
|
||||
|
||||
private static void updateAxisBounds(
|
||||
StatusIndexChart statusIndexChart,
|
||||
List<EvelynStatusIndexPoint> history
|
||||
@@ -257,42 +293,6 @@ public final class EvelynMissionControlImpl implements
|
||||
refreshChart(testChart, evelynStatusTest.getStatusIndexHistory());
|
||||
}
|
||||
|
||||
static final class StatusIndexChart {
|
||||
private StatusIndexChart(
|
||||
LineChart<Number, Number> chart,
|
||||
NumberAxis xAxis,
|
||||
NumberAxis yAxis,
|
||||
XYChart.Series<Number, Number> priceIndexSeries
|
||||
) {
|
||||
this.chart = chart;
|
||||
this.xAxis = xAxis;
|
||||
this.yAxis = yAxis;
|
||||
this.priceIndexSeries = priceIndexSeries;
|
||||
}
|
||||
|
||||
LineChart<Number, Number> chart() {
|
||||
return chart;
|
||||
}
|
||||
|
||||
NumberAxis xAxis() {
|
||||
return xAxis;
|
||||
}
|
||||
|
||||
NumberAxis yAxis() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
XYChart.Series<Number, Number> priceIndexSeries() {
|
||||
return priceIndexSeries;
|
||||
}
|
||||
|
||||
private final LineChart<Number, Number> chart;
|
||||
private final NumberAxis xAxis;
|
||||
private final NumberAxis yAxis;
|
||||
private final XYChart.Series<Number, Number> priceIndexSeries;
|
||||
private List<EvelynStatusIndexPoint> renderedHistory = List.of();
|
||||
}
|
||||
|
||||
private static final String PRODUCTION_COLOR = "#ffd6d6";
|
||||
private static final String TEST_COLOR = "#d8f3dc";
|
||||
private static final double EMPTY_Y_BOUND = 1.0;
|
||||
@@ -301,6 +301,7 @@ public final class EvelynMissionControlImpl implements
|
||||
private static final DateTimeFormatter TIMESTAMP_TICK_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("HH:mm dd/MM/yy")
|
||||
.withZone(ZoneId.of("Europe/Copenhagen"));
|
||||
|
||||
private static final StringConverter<Number> TIMESTAMP_FORMATTER = new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(Number timestamp) {
|
||||
|
||||
Reference in New Issue
Block a user