Also… ich möchte das einmal skizzieren:
import com.binance.api.client.BinanceApiRestClient;
public class MySymbol {
private String symbol;
private int stepSize;
private int stepCount;
private int precision;
private double precisionDouble;
public MySymbol(String symbol, int stepSize, int stepCount) {
this.symbol = symbol;
this.stepSize = stepSize;
this.stepCount = stepCount;
init();
}
private void init() {
MyConnection.getInstance().testClient();
precision = 3;
precisionDouble = Math.pow(10, precision);
}
public void printSimulateList() {
BinanceApiRestClient client = MyConnection.getInstance().getClient();
double last = Double.parseDouble(client.get24HrPriceStatistics(symbol).getLastPrice());
double step = stepSize / 100.0;
for (int i = 0; i <= stepCount; i++) {
double d1 = step * ((stepCount / 2) - (stepCount - i)) + 100.0;
double d2 = last * d1;
double d3 = round_u(d2) * 12.3 - round_d(d2) * 12.3;
System.out.printf("%d\t%f\t%f\t%f\t%f%n", i, d1, d2, round_d(d2), round_u(d2));
System.out.printf("Buy limit price: %f Sell limit price: %f Remaining: %f%n", round_d(d2), round_u(d2), d3);
}
}
private double round_d(double d) {
return Math.floor(d * precisionDouble) / precisionDouble;
}
private double round_u(double d) {
return Math.ceil(d * precisionDouble) / precisionDouble;
}
}
Ausgabe:
0 99,700000 6,851085 6,851000 6,852000
Buy limit price: 6,851000 Sell limit price: 6,852000 Remaining: 0,012300
1 99,730000 6,853146 6,853000 6,854000
Buy limit price: 6,853000 Sell limit price: 6,854000 Remaining: 0,012300
2 99,760000 6,855208 6,855000 6,856000
Buy limit price: 6,855000 Sell limit price: 6,856000 Remaining: 0,012300
3 99,790000 6,857269 6,857000 6,858000
Buy limit price: 6,857000 Sell limit price: 6,858000 Remaining: 0,012300
4 99,820000 6,859331 6,859000 6,860000
Buy limit price: 6,859000 Sell limit price: 6,860000 Remaining: 0,012300
5 99,850000 6,861392 6,861000 6,862000
Buy limit price: 6,861000 Sell limit price: 6,862000 Remaining: 0,012300
6 99,880000 6,863454 6,863000 6,864000
Buy limit price: 6,863000 Sell limit price: 6,864000 Remaining: 0,012300
7 99,910000 6,865515 6,865000 6,866000
Buy limit price: 6,865000 Sell limit price: 6,866000 Remaining: 0,012300
8 99,940000 6,867577 6,867000 6,868000
Buy limit price: 6,867000 Sell limit price: 6,868000 Remaining: 0,012300
9 99,970000 6,869638 6,869000 6,870000
Buy limit price: 6,869000 Sell limit price: 6,870000 Remaining: 0,012300
10 100,000000 6,871700 6,871000 6,872000
Buy limit price: 6,871000 Sell limit price: 6,872000 Remaining: 0,012300
11 100,030000 6,873762 6,873000 6,874000
Buy limit price: 6,873000 Sell limit price: 6,874000 Remaining: 0,012300
12 100,060000 6,875823 6,875000 6,876000
Buy limit price: 6,875000 Sell limit price: 6,876000 Remaining: 0,012300
13 100,090000 6,877885 6,877000 6,878000
Buy limit price: 6,877000 Sell limit price: 6,878000 Remaining: 0,012300
14 100,120000 6,879946 6,879000 6,880000
Buy limit price: 6,879000 Sell limit price: 6,880000 Remaining: 0,012300
15 100,150000 6,882008 6,882000 6,883000
Buy limit price: 6,882000 Sell limit price: 6,883000 Remaining: 0,012300
16 100,180000 6,884069 6,884000 6,885000
Buy limit price: 6,884000 Sell limit price: 6,885000 Remaining: 0,012300
17 100,210000 6,886131 6,886000 6,887000
Buy limit price: 6,886000 Sell limit price: 6,887000 Remaining: 0,012300
18 100,240000 6,888192 6,888000 6,889000
Buy limit price: 6,888000 Sell limit price: 6,889000 Remaining: 0,012300
19 100,270000 6,890254 6,890000 6,891000
Buy limit price: 6,890000 Sell limit price: 6,891000 Remaining: 0,012300
20 100,300000 6,892315 6,892000 6,893000
Buy limit price: 6,892000 Sell limit price: 6,893000 Remaining: 0,012300
Anforderungen:
- Es darf nicht mehr verkauft als gekauft werden (die Differenz darf nicht negativ sein)
- Die Börse akzeptiert aber nur Limit-Preise, die eine bestimmte Anzahl an Nachkommastellen nicht überschreiten
- Der Restbetrag sollte genau 0 sein
Problem:
- Es verbleibt immer ein Rest, > 0
Hast du eventuell e Idee?