Working stop button

This commit is contained in:
7u83
2017-02-04 16:29:45 +01:00
parent 4a01d8f1f6
commit 98965eed43
11 changed files with 325 additions and 142 deletions

View File

@ -121,7 +121,7 @@ public class RandomTrader extends AutoTrader {
return (max - min) * r + min;
}
protected int getRandom(Integer[] minmax) {
protected int getRandom(Long[] minmax) {
return (int) Math.round(getRandom(minmax[0], minmax[1]));
}

View File

@ -44,13 +44,13 @@ public class RandomTraderConfig extends AutoTraderBase implements AutoTraderConf
public Float[] sell_volume = {100f, 100f};
public Float[] sell_limit = {-0.1f, 0.10101f};
public Integer[] sell_wait = {10000, 50000};
public Integer[] wait_after_sell = {1000, 30000};
public Long[] sell_wait = {10000L, 50000L};
public Long[] wait_after_sell = {1000L, 30000L};
public Float[] buy_volume = {100f, 100f};
public Float[] buy_limit = {-0.1f, 0.10101f};
public Integer[] buy_wait = {10000, 50000};
public Integer[] wait_after_buy = {10, 30};
public Long[] buy_wait = {10000L, 50000L};
public Long[] wait_after_buy = {10L, 30L};
@Override
public AutoTrader createTrader(Exchange se, JSONObject cfg, double money, double shares) {
@ -121,6 +121,17 @@ public class RandomTraderConfig extends AutoTraderBase implements AutoTraderConf
return ret;
}
private Long[] to_long(JSONArray a) {
Long[] ret = new Long[a.length()];
for (int i = 0; i < a.length(); i++) {
ret[i] = a.getLong(i);
}
return ret;
}
private Number[] to_arn(JSONArray a) {
Number[] ret = new Number[a.length()];
@ -148,11 +159,11 @@ public class RandomTraderConfig extends AutoTraderBase implements AutoTraderConf
buy_volume = to_float(cfg.getJSONArray(BUY_VOLUME));
sell_limit = to_float(cfg.getJSONArray(SELL_LIMIT));
buy_limit = to_float(cfg.getJSONArray(BUY_LIMIT));
sell_wait = to_integer(cfg.getJSONArray(SELL_WAIT));
buy_wait = to_integer(cfg.getJSONArray(BUY_WAIT));
sell_wait = to_long(cfg.getJSONArray(SELL_WAIT));
buy_wait = to_long(cfg.getJSONArray(BUY_WAIT));
wait_after_sell = to_integer(cfg.getJSONArray(WAIT_AFTER_SELL));
wait_after_buy = to_integer(cfg.getJSONArray(WAIT_AFTER_BUY));
wait_after_sell = to_long(cfg.getJSONArray(WAIT_AFTER_SELL));
wait_after_buy = to_long(cfg.getJSONArray(WAIT_AFTER_BUY));
}

View File

@ -220,28 +220,28 @@
<Component class="javax.swing.JSpinner" name="buyWaitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellWaitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellWaitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyWaitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>

View File

@ -79,15 +79,15 @@ public class RandomTraderGui extends AutoTraderGui {
cfg.buy_limit[1] = (Float) this.buyLimitMax.getValue();
cfg.sell_limit[0] = (Float) this.sellLimitMin.getValue();
cfg.sell_limit[1] = (Float) this.sellLimitMax.getValue();
cfg.buy_wait[0] = (Integer) this.buyWaitMin.getValue();
cfg.buy_wait[1] = (Integer) this.buyWaitMax.getValue();
cfg.sell_wait[0] = (Integer) this.sellWaitMin.getValue();
cfg.sell_wait[1] = (Integer) this.sellWaitMax.getValue();
cfg.buy_wait[0] = (Long) this.buyWaitMin.getValue();
cfg.buy_wait[1] = (Long) this.buyWaitMax.getValue();
cfg.sell_wait[0] = (Long) this.sellWaitMin.getValue();
cfg.sell_wait[1] = (Long) this.sellWaitMax.getValue();
cfg.wait_after_buy[0] = (Integer) this.waitAfterBuyMin.getValue();
cfg.wait_after_buy[1] = (Integer) this.waitAfterBuyMax.getValue();
cfg.wait_after_sell[0] = (Integer) this.waitAfterSellMin.getValue();
cfg.wait_after_sell[1] = (Integer) this.waitAfterSellMax.getValue();
cfg.wait_after_buy[0] = (Long) this.waitAfterBuyMin.getValue();
cfg.wait_after_buy[1] = (Long) this.waitAfterBuyMax.getValue();
cfg.wait_after_sell[0] = (Long) this.waitAfterSellMin.getValue();
cfg.wait_after_sell[1] = (Long) this.waitAfterSellMax.getValue();
// cfg.buy_volume[0] = Float.parseFloat(this.buyVolMin.getText());
@ -153,13 +153,13 @@ public class RandomTraderGui extends AutoTraderGui {
setBorder(null);
buyWaitMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
buyWaitMin.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
sellWaitMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
sellWaitMin.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
sellWaitMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
sellWaitMax.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
buyWaitMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
buyWaitMax.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
buyLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));

View File

@ -47,13 +47,13 @@ public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTra
sell_volume = new Float[]{17f, 100f};
sell_limit = new Float[]{-30f, 1f};
sell_wait = new Integer[]{1, 5};
wait_after_sell = new Integer[]{1, 5};
sell_wait = new Long[]{1L, 5L};
wait_after_sell = new Long[]{1L, 5L};
buy_volume = new Float[]{18f, 100f};
buy_limit = new Float[]{-1f, 30f};
buy_wait = new Integer[]{1, 5};
wait_after_buy = new Integer[]{1, 5};
buy_wait = new Long[]{1L, 5L};
wait_after_buy = new Long[]{1L, 5L};
}
@Override