Code cleaning

This commit is contained in:
7u83 2017-02-11 13:12:02 +01:00
parent dc4806bd64
commit 4090947001
15 changed files with 292 additions and 1584 deletions

View File

@ -112,6 +112,9 @@
<Property name="mnemonic" type="int" value="111"/>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -79,6 +79,11 @@ public class EditExchangeDialog extends javax.swing.JDialog {
jButton2.setMnemonic('o');
jButton2.setText("Ok");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -123,6 +128,10 @@ public class EditExchangeDialog extends javax.swing.JDialog {
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// Globals.prefs.put("money_decimals", value);
}//GEN-LAST:event_jButton2ActionPerformed
/**
* @param args the command line arguments
*/

View File

@ -67,11 +67,15 @@ public class NewMDIApplication extends javax.swing.JFrame {
AutoTraderInterface ac = Globals.tloader.getStrategyBase(base);
ac.putConfig(cfg);
ac.init(se, id, name, money, shares, cfg);
return ac;
}
public void startTraders() {
Globals.se.setMoneyDecimals(8);
Globals.se.setSharesDecimals(0);
JSONArray tlist = Globals.getTraders();
Double moneyTotal = 0.0;
@ -495,14 +499,19 @@ public class NewMDIApplication extends javax.swing.JFrame {
resetSim();
this.stopButton.setEnabled(true);
this.orderBookPanel.invalidate();
this.orderBookPanel.repaint();
this.clock.invalidate();
this.clock.repaint();
this.startTraders();
Globals.se.timer.setPause(false);
Globals.se.timer.start();
Globals.se.timer.setAcceleration((Double) this.accelSpinner.getValue());
this.clock.invalidate();
this.clock.repaint();
}

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sesim;
import sesim.Exchange.OrderComparator;
import java.util.*;
import sesim.Exchange.*;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class AccountData {
public double id;
public double money;
public double shares;
public ArrayList <OrderData> orders;
}

View File

@ -101,7 +101,7 @@ public class Exchange {
return owner;
}
public Map getOrders() {
public HashMap<Long,Order> getOrders() {
return orders;
}
@ -676,7 +676,7 @@ public class Exchange {
return accounts.get(account_id);
}
public AccountData getAccountData(double account_id) {
/*public AccountData getAccountData(double account_id) {
tradelock.lock();
Account a = accounts.get(account_id);
tradelock.unlock();
@ -713,7 +713,8 @@ public class Exchange {
//KeySet ks = a.orders.keySet();
return ad;
}
*/
public ArrayList<OrderData> getOpenOrders(double account_id) {
Account a = accounts.get(account_id);

View File

@ -1,304 +0,0 @@
/*
* Copyright (c) 2017, 7u83
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package traders;
import gui.Globals;
import java.util.*;
import java.util.Random;
import org.json.JSONObject;
//import java.util.TimerTask;
/*import sesim.AccountData;*/
import sesim.AutoTrader;
import sesim.Exchange;
import sesim.Exchange.OrderType;
import sesim.*;
/**
*
* @author 7u83
*/
public class RandomTrader extends AutoTrader {
/* long event() {
sesim.Exchange.Account a = se.getAccount(account_id);
long rc = this.doTrade();
return rc;
}
*/
public RandomTrader(Exchange se, long id, String name, double money, double shares, RandomTraderConfig config) {
super(se, id, name,money, shares, config);
if (this.config == null) {
this.config = new RandomTraderConfig();
}
}
/**
*
* @return
*/
@Override
public long timerTask() {
sesim.Exchange.Account a = se.getAccount(account_id);
long rc = this.doTrade();
return rc;
// return this.event();
}
protected enum Action {
BUY, SELL, RANDOM
}
protected Action getAction() {
if (se.randNextInt(2) == 0) {
return Action.BUY;
} else {
return Action.SELL;
}
}
double getStart() {
return Globals.se.fairValue;
}
//Timer timer = new Timer();
@Override
public void start() {
// timer.schedule(new TimerTaskImpl(this, timer), 0);
se.timer.startTimerEvent(this, 0);
// timer.schedule(new TimerTaskImpl, date);
}
// config for this trader
//final private RandomTraderConfig_old myconfig;
// object to generate random numbers
//final private Random rand = new Random();
/**
* Get a (long) random number between min an max
*
* @param min minimum value
* @param max maximeum value
* @return the number
*/
protected double getRandom(double min, double max) {
double r = se.randNextDouble();
// System.out.printf("RD: %f", r);
// System.exit(0);
return (max - min) * r + min;
}
protected int getRandom(Long[] minmax) {
return (int) Math.round(getRandom(minmax[0], minmax[1]));
}
/**
*
* @param val
* @param minmax
* @return
*/
protected double getRandomAmmount(double val, Float[] minmax) {
//System.out.printf("RandomAmmount: %f (%f,%f)\n",val, minmax[0], minmax[1]);
double min = val * minmax[0] / 100.0;
double max = val * minmax[1] / 100.0;
return getRandom(min, max);
}
public long cancelOrders() {
int n = se.getNumberOfOpenOrders(account_id);
// System.out.print("Open Orders: "+n+"\n");
if (n > 0) {
// System.out.print("Want to killń\n");
AccountData ad = se.getAccountData(account_id);
Iterator<OrderData> it = ad.orders.iterator();
while (it.hasNext()) {
OrderData od = it.next();
boolean rc = se.cancelOrder(account_id, od.id);
// System.out.print("killer rc "+rc+"\n");
// System.out.print("Killing: "+od.id+"\n");
}
}
return n;
}
public long doBuy() {
RandomTraderConfig myconfig = (RandomTraderConfig) this.config;
AccountData ad = this.se.getAccountData(account_id);
OrderType type = OrderType.BUYLIMIT;
if (ad == null || myconfig == null) {
//System.out.printf("%s: myconf = 0 \n", this.getName());
return 0;
}
// how much money we ant to invest?
double money = getRandomAmmount(ad.money, myconfig.buy_volume);
Quote q = se.getCurrentPrice();
double lp = q == null ? getStart() : q.price;
double limit;
limit = lp + getRandomAmmount(lp, myconfig.buy_limit);
// 10
// 24 13
// System.out.printf("MyLimit: %f\n",limit);
long volume = (long) (money / limit);
if (volume <= 0) {
volume=1;
limit = money;
}
// double volume = (money / (limit * 1));
// if (volume <= 0) {
// return 0;
// }
//System.out.printf("%s: create order %s %f\n", this.getName(),type.toString(),limit);
se.createOrder(account_id, type, volume, limit);
return getRandom(myconfig.buy_wait);
}
public long doSell() {
RandomTraderConfig myconfig = (RandomTraderConfig) this.config;
AccountData ad = this.se.getAccountData(account_id);
OrderType type = OrderType.SELLLIMIT;
//System.out.printf("%s: calling rand for volume\n", this.getName());
// how much money we ant to envest?
double volume = (long) getRandomAmmount(ad.shares, myconfig.sell_volume);
// double lp = 100.0; //se.getBestLimit(type);
Quote q = se.getCurrentPrice();
double lp = q == null ? getStart() : q.price;
double limit;
limit = lp + getRandomAmmount(lp, myconfig.sell_limit);
// long volume = (long) (money / (limit * 1));
if (volume <= 0) {
// System.out.print("SellVolume 0\n");
return 5000;
}
// System.out.print("Volume is:"+volume+"\n");
// System.out.print("My Ammount is: "+volume+" My limit si:"+limit+ "\n");
//System.out.printf("%s: create order %s %f\n", this.getName(),type.toString(),limit);
se.createOrder(account_id, type, volume, limit);
return getRandom(myconfig.sell_wait);
}
long doTrade() {
cancelOrders();
Action a = getAction();
switch (a) {
case BUY:
return doBuy()+1;
case SELL:
return doSell()+1;
}
// System.out.printf("%s: do nothing\n",this.getName());
return 0;
}
/*
private static class TimerTaskImpl extends TimerTask {
RandomTrader trader;
Timer timer;
public TimerTaskImpl(RandomTrader trader, Timer timer) {
this.trader = trader;
this.timer = timer;
}
@Override
public void run() {
long time = trader.event();
time /= 100;
this.cancel();
timer.schedule(new TimerTaskImpl(trader, timer), time);
}
}
*/
}

View File

@ -26,15 +26,21 @@
package traders;
import gui.Globals;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import org.json.JSONArray;
import org.json.JSONObject;
import sesim.AccountData;
//import sesim.AccountData;
import sesim.AutoTrader;
import sesim.AutoTraderBase;
import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.Exchange;
import sesim.Exchange.Account;
import sesim.Exchange.Order;
import sesim.OrderData;
import sesim.Quote;
@ -42,7 +48,9 @@ import sesim.Quote;
*
* @author 7u83 <7u83@mail.ru>
*/
public class RandomTraderA extends AutoTraderBase {
public class RandomTraderA extends AutoTraderBase {
public Float[] initial_delay = {0f, 5.0f};
public Float[] sell_volume = {100f, 100f};
public Float[] sell_limit = {-2f, 2f};
@ -54,6 +62,7 @@ public class RandomTraderA extends AutoTraderBase {
public Long[] buy_wait = {10000L, 50000L};
public Long[] wait_after_buy = {10L, 30L};
final String INITIAL_DELAY = "initla_delay";
final String SELL_VOLUME = "sell_volume";
final String BUY_VOLUME = "buy_volume";
final String SELL_LIMIT = "sell_limit";
@ -65,7 +74,8 @@ public class RandomTraderA extends AutoTraderBase {
@Override
public void start() {
se.timer.startTimerEvent(this, 0);
long delay = (long) (getRandom(initial_delay[0], initial_delay[1]) * 1000);
se.timer.startTimerEvent(this, delay);
}
@Override
@ -76,11 +86,6 @@ public class RandomTraderA extends AutoTraderBase {
}
/* @Override
public AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
return null;
}
*/
@Override
public String getDisplayName() {
return null;
@ -94,6 +99,7 @@ public class RandomTraderA extends AutoTraderBase {
@Override
public JSONObject getConfig() {
JSONObject jo = new JSONObject();
jo.put(INITIAL_DELAY, initial_delay);
jo.put(SELL_VOLUME, sell_volume);
jo.put(BUY_VOLUME, buy_volume);
jo.put(SELL_LIMIT, sell_limit);
@ -132,17 +138,20 @@ public class RandomTraderA extends AutoTraderBase {
return;
}
String cname = cfg.get(SELL_VOLUME).getClass().getName();
try {
initial_delay = to_float(cfg.getJSONArray(INITIAL_DELAY));
sell_volume = to_float(cfg.getJSONArray(SELL_VOLUME));
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_long(cfg.getJSONArray(SELL_WAIT));
buy_wait = to_long(cfg.getJSONArray(BUY_WAIT));
sell_volume = to_float(cfg.getJSONArray(SELL_VOLUME));
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_long(cfg.getJSONArray(SELL_WAIT));
buy_wait = to_long(cfg.getJSONArray(BUY_WAIT));
wait_after_sell = to_long(cfg.getJSONArray(WAIT_AFTER_SELL));
wait_after_buy = to_long(cfg.getJSONArray(WAIT_AFTER_BUY));
} catch (Exception e) {
wait_after_sell = to_long(cfg.getJSONArray(WAIT_AFTER_SELL));
wait_after_buy = to_long(cfg.getJSONArray(WAIT_AFTER_BUY));
}
}
@ -154,14 +163,19 @@ public class RandomTraderA extends AutoTraderBase {
public long cancelOrders() {
int n = se.getNumberOfOpenOrders(account_id);
if (n > 0) {
AccountData ad = se.getAccountData(account_id);
Iterator<OrderData> it = ad.orders.iterator();
while (it.hasNext()) {
OrderData od = it.next();
boolean rc = se.cancelOrder(account_id, od.id);
}
Account ad = se.getAccount(account_id);
Set <Long>keys = ad.getOrders().keySet();
Iterator<Long> it = keys.iterator();
while (it.hasNext()) {
// Order od = it.next();
boolean rc = se.cancelOrder(account_id, it.next());
}
}
return n;
}
protected enum Action {
@ -177,14 +191,32 @@ public class RandomTraderA extends AutoTraderBase {
}
Action mode=Action.RANDOM;
long doTrade() {
cancelOrders();
Action a = getAction();
switch (a) {
case BUY:
return doBuy() + 1;
case BUY: {
boolean rc = doBuy();
if (rc) {
mode = Action.BUY;
return getRandom(buy_wait);
}
return 5000;
}
case SELL:
return doSell() + 1;
{
boolean rc = doSell();
if (rc){
mode = Action.SELL;
return getRandom(sell_wait);
}
return 5000;
}
}
return 0;
@ -211,6 +243,7 @@ public class RandomTraderA extends AutoTraderBase {
}
double getStart() {
return Globals.se.fairValue;
}
@ -229,60 +262,55 @@ public class RandomTraderA extends AutoTraderBase {
return getRandom(min, max);
}
public long doBuy() {
public boolean doBuy() {
// RandomTraderConfig myoldconfig = (RandomTraderConfig) this.oldconfig;
AccountData ad = this.se.getAccountData(account_id);
// AccountData ad = this.se.getAccountData(account_id);
Account ad = se.getAccount(account_id);
Exchange.OrderType type = Exchange.OrderType.BUYLIMIT;
if (ad == null) {
//System.out.printf("%s: myconf = 0 \n", this.getName());
return 0;
return false;
}
// how much money we ant to invest?
double money = getRandomAmmount(ad.money, buy_volume);
double money = getRandomAmmount(ad.getMoney(), buy_volume);
money = se.roundMoney(money);
Quote q = se.getCurrentPrice();
double lp = q == null ? getStart() : q.price;
double limit;
limit = lp + getRandomAmmount(lp, buy_limit);
limit = se.roundMoney(limit);
// 10
// 24 13
// System.out.printf("MyLimit: %f\n",limit);
long volume = (long) (money / limit);
if (volume <= 0) {
volume = 1;
limit = money;
double volume = money / limit;
volume = se.roundShares(volume);
if (volume <= 0 || money <= 0) {
return false;
}
// double volume = (money / (limit * 1));
// if (volume <= 0) {
// return 0;
// }
//System.out.printf("%s: create order %s %f\n", this.getName(),type.toString(),limit);
se.createOrder(account_id, type, volume, limit);
return getRandom(buy_wait);
return true;
}
public long doSell() {
public boolean doSell() {
// RandomTraderConfig myoldconfig = (RandomTraderConfig) this.oldconfig;
AccountData ad = this.se.getAccountData(account_id);
//AccountData ad = this.se.getAccountData(account_id);
Account ad = se.getAccount(account_id);
Exchange.OrderType type = Exchange.OrderType.SELLLIMIT;
//System.out.printf("%s: calling rand for volume\n", this.getName());
// how much money we ant to envest?
double volume = (long) getRandomAmmount(ad.shares, sell_volume);
// how much shares we ant to sell?
double volume = getRandomAmmount(ad.getShares(), sell_volume);
volume = se.roundShares(volume);
// double lp = 100.0; //se.getBestLimit(type);
Quote q = se.getCurrentPrice();
@ -290,19 +318,18 @@ public class RandomTraderA extends AutoTraderBase {
double limit;
limit = lp + getRandomAmmount(lp, sell_limit);
se.roundMoney(limit);
// long volume = (long) (money / (limit * 1));
if (volume <= 0) {
// System.out.print("SellVolume 0\n");
return 5000;
if (volume <= 0 || limit <=0) {
return false;
}
// System.out.print("Volume is:"+volume+"\n");
// System.out.print("My Ammount is: "+volume+" My limit si:"+limit+ "\n");
//System.out.printf("%s: create order %s %f\n", this.getName(),type.toString(),limit);
se.createOrder(account_id, type, volume, limit);
return true;
return getRandom(sell_wait);
}

View File

@ -57,7 +57,8 @@ public class RandomTraderConfig extends AutoTraderConfigBase implements AutoTrad
if (cfg != null) {
this.putConfig(cfg);
}
return new traders.RandomTrader(se, id, name, money, shares, this);
return null;
//return new traders.RandomTrader(se, id, name, money, shares, this);
}
@Override
@ -67,7 +68,8 @@ public class RandomTraderConfig extends AutoTraderConfigBase implements AutoTrad
@Override
public AutoTraderGui getGui() {
return new RandomTraderGui(this);
return null;
//return new RandomTraderGui(this);
}
final String SELL_VOLUME = "sell_volume";

View File

@ -1,465 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JTextField" name="jTextField1">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField1"/>
</Properties>
</Component>
</NonVisualComponents>
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel24" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel22" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel23" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel21" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="waitAfterSellMin" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="waitAfterBuyMin" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel19" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel20" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="waitAfterSellMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="waitAfterBuyMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel9" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel12" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel10" pref="175" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel11" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel18" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel15" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="sellVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel13" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</Group>
<EmptySpace min="43" pref="43" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buyVolMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="sellVolMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="sellVolMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buyLimitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="buyLimitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="sellLimitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="sellLimitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buyWaitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel16" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel15" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buyWaitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="sellWaitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="sellWaitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel17" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="waitAfterBuyMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="waitAfterBuyMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel19" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel23" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="waitAfterSellMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="waitAfterSellMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel24" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="37" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<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.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.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.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.Long" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyLimitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyLimitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellLimitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellLimitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterBuyMin">
<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"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterSellMin">
<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"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterSellMax">
<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"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterBuyMax">
<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"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyVolMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyVolMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellVolMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellVolMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Volume to buy (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Volume to sell (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Buy limit (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Sel limit (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel15">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Buy order wait (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel16">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel17">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel18">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Sell order wait (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel19">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel20">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel21">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel22">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel23">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Wait after buy (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel24">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Wait after sell (in ms):"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -1,446 +0,0 @@
/*
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package traders;
import javax.swing.JDialog;
import org.json.JSONObject;
import sesim.AutoTraderGui;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class RandomTraderGui extends AutoTraderGui {
private RandomTraderConfig cfg;
/**
* Creates new form RandomTraderConfigForm
*/
public RandomTraderGui(RandomTraderConfig cfg) {
initComponents();
this.cfg = cfg;
JDialog d;
this.buyVolMin.setValue(cfg.buy_volume[0]);
this.buyVolMax.setValue(cfg.buy_volume[1]);
this.sellVolMin.setValue(cfg.sell_volume[0]);
this.sellVolMax.setValue(cfg.sell_volume[1]);
this.buyLimitMin.setValue(cfg.buy_limit[0]);
this.buyLimitMax.setValue(cfg.buy_limit[1]);
this.sellLimitMin.setValue(cfg.sell_limit[0]);
this.sellLimitMax.setValue(cfg.sell_limit[1]);
this.buyWaitMin.setValue(cfg.buy_wait[0]);
this.buyWaitMax.setValue(cfg.buy_wait[1]);
this.sellWaitMin.setValue(cfg.sell_wait[0]);
this.sellWaitMax.setValue(cfg.sell_wait[1]);
this.waitAfterBuyMin.setValue(cfg.wait_after_buy[0]);
this.waitAfterBuyMax.setValue(cfg.wait_after_buy[1]);
this.waitAfterSellMin.setValue(cfg.wait_after_sell[0]);
this.waitAfterSellMax.setValue(cfg.wait_after_sell[1]);
}
@Override
public void save() {
cfg.buy_volume[0] = (Float) this.buyVolMin.getValue();
cfg.buy_volume[1] = (Float) this.buyVolMax.getValue();
cfg.sell_volume[0] = (Float) this.sellVolMin.getValue();
cfg.sell_volume[1] = (Float) this.sellVolMax.getValue();
cfg.buy_limit[0] = (Float) this.buyLimitMin.getValue();
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] = (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] = (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());
// cfg.buy_volume[1] = Float.parseFloat(this.buyVolMax.getText());
// cfg.sell_volume[0] = Float.parseFloat(this.sellVolMin.getText());
// cfg.sell_volume[1] = Float.parseFloat(this.sellVolMax.getText());
JSONObject j = cfg.getConfig();
System.out.printf("JSON: %s\n", j.toString(3));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
buyWaitMin = new javax.swing.JSpinner();
sellWaitMin = new javax.swing.JSpinner();
sellWaitMax = new javax.swing.JSpinner();
buyWaitMax = new javax.swing.JSpinner();
buyLimitMin = new javax.swing.JSpinner();
buyLimitMax = new javax.swing.JSpinner();
sellLimitMax = new javax.swing.JSpinner();
sellLimitMin = new javax.swing.JSpinner();
waitAfterBuyMin = new javax.swing.JSpinner();
waitAfterSellMin = new javax.swing.JSpinner();
waitAfterSellMax = new javax.swing.JSpinner();
waitAfterBuyMax = new javax.swing.JSpinner();
buyVolMin = new javax.swing.JSpinner();
buyVolMax = new javax.swing.JSpinner();
sellVolMax = new javax.swing.JSpinner();
sellVolMin = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jTextField1.setText("jTextField1");
setBorder(null);
buyWaitMin.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
sellWaitMin.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
sellWaitMax.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
buyWaitMax.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
buyLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
buyLimitMax.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
sellLimitMax.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
sellLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
waitAfterBuyMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
waitAfterSellMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
waitAfterSellMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
waitAfterBuyMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
buyVolMin.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
buyVolMax.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
sellVolMax.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
sellVolMin.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
jLabel1.setText("min:");
jLabel2.setText("max:");
jLabel2.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel3.setText("min:");
jLabel4.setText("max:");
jLabel5.setText("max:");
jLabel5.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel6.setText("max:");
jLabel7.setText("min:");
jLabel8.setText("min:");
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Volume to buy (in %):");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Volume to sell (in %):");
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel11.setText("Buy limit (in %):");
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel12.setText("Sel limit (in %):");
jLabel13.setText("max:");
jLabel13.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel14.setText("max:");
jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel15.setText("Buy order wait (in ms):");
jLabel16.setText("min:");
jLabel17.setText("min:");
jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel18.setText("Sell order wait (in ms):");
jLabel19.setText("max:");
jLabel19.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel20.setText("max:");
jLabel21.setText("min:");
jLabel22.setText("min:");
jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel23.setText("Wait after buy (in ms):");
jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel24.setText("Wait after sell (in ms):");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel22))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel21)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(waitAfterSellMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterBuyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel19)
.addComponent(jLabel20))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(waitAfterSellMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterBuyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel8))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel3))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel17))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel16)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(sellVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel13)
.addComponent(jLabel14))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGap(43, 43, 43))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sellVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel10))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buyLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(jLabel7)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sellLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel8)
.addComponent(jLabel12))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buyWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(jLabel16)
.addComponent(jLabel15)
.addComponent(buyWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sellWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14)
.addComponent(jLabel17)
.addComponent(jLabel18))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(waitAfterBuyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterBuyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel19)
.addComponent(jLabel21)
.addComponent(jLabel23))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(waitAfterSellMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterSellMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel20)
.addComponent(jLabel22)
.addComponent(jLabel24))
.addContainerGap(37, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JSpinner buyLimitMax;
private javax.swing.JSpinner buyLimitMin;
private javax.swing.JSpinner buyVolMax;
private javax.swing.JSpinner buyVolMin;
private javax.swing.JSpinner buyWaitMax;
private javax.swing.JSpinner buyWaitMin;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField1;
private javax.swing.JSpinner sellLimitMax;
private javax.swing.JSpinner sellLimitMin;
private javax.swing.JSpinner sellVolMax;
private javax.swing.JSpinner sellVolMin;
private javax.swing.JSpinner sellWaitMax;
private javax.swing.JSpinner sellWaitMin;
private javax.swing.JSpinner waitAfterBuyMax;
private javax.swing.JSpinner waitAfterBuyMin;
private javax.swing.JSpinner waitAfterSellMax;
private javax.swing.JSpinner waitAfterSellMin;
// End of variables declaration//GEN-END:variables
}

View File

@ -60,7 +60,7 @@
<Component id="waitAfterBuyMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel9" max="32767" attributes="0"/>
@ -92,49 +92,61 @@
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel27" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel26" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="sellVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="initialDelayMin" min="-2" pref="98" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="sellVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel13" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel13" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<Component id="jLabel25" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="initialDelayMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</Group>
@ -147,7 +159,15 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="initialDelayMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="initialDelayMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel25" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel26" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel27" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buyVolMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
@ -211,7 +231,7 @@
<Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel24" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="37" max="32767" attributes="0"/>
<EmptySpace pref="41" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -461,5 +481,36 @@
<Property name="text" type="java.lang.String" value="Wait after sell (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="initialDelayMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="0.0" numberType="java.lang.Float" stepSize="0.1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="initialDelayMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="0.0" numberType="java.lang.Float" stepSize="0.1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel25">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel26">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel27">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Initial delay (in seconds):"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -46,6 +46,9 @@ public class RandomTraderGuiA extends AutoTraderGui {
JDialog d;
this.initialDelayMin.setValue(cfg.initial_delay[0]);
this.initialDelayMax.setValue(cfg.initial_delay[1]);
this.buyVolMin.setValue(cfg.buy_volume[0]);
this.buyVolMax.setValue(cfg.buy_volume[1]);
this.sellVolMin.setValue(cfg.sell_volume[0]);
@ -71,6 +74,9 @@ public class RandomTraderGuiA extends AutoTraderGui {
@Override
public void save() {
cfg.initial_delay[0] = (Float) this.initialDelayMin.getValue();
cfg.initial_delay[1] = (Float) this.initialDelayMax.getValue();
cfg.buy_volume[0] = (Float) this.buyVolMin.getValue();
cfg.buy_volume[1] = (Float) this.buyVolMax.getValue();
cfg.sell_volume[0] = (Float) this.sellVolMin.getValue();
@ -83,12 +89,11 @@ public class RandomTraderGuiA extends AutoTraderGui {
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] = (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());
// cfg.buy_volume[1] = Float.parseFloat(this.buyVolMax.getText());
@ -148,6 +153,11 @@ public class RandomTraderGuiA extends AutoTraderGui {
jLabel22 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
initialDelayMin = new javax.swing.JSpinner();
initialDelayMax = new javax.swing.JSpinner();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
jLabel27 = new javax.swing.JLabel();
jTextField1.setText("jTextField1");
@ -245,6 +255,18 @@ public class RandomTraderGuiA extends AutoTraderGui {
jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel24.setText("Wait after sell (in ms):");
initialDelayMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, 0.0f, null, 0.1f));
initialDelayMax.setModel(new javax.swing.SpinnerNumberModel(0.0f, 0.0f, null, 0.1f));
jLabel25.setText("max:");
jLabel25.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel26.setText("min:");
jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel27.setText("Initial delay (in seconds):");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@ -299,47 +321,63 @@ public class RandomTraderGuiA extends AutoTraderGui {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel16)))
.addComponent(jLabel16))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel26)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(sellVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(initialDelayMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(sellVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel13)
.addComponent(jLabel14))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel13)
.addComponent(jLabel14))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel25))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(initialDelayMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))))))))
.addGap(43, 43, 43))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(initialDelayMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(initialDelayMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel25)
.addComponent(jLabel26)
.addComponent(jLabel27))
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
@ -395,7 +433,7 @@ public class RandomTraderGuiA extends AutoTraderGui {
.addComponent(jLabel20)
.addComponent(jLabel22)
.addComponent(jLabel24))
.addContainerGap(37, Short.MAX_VALUE))
.addContainerGap(41, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@ -407,6 +445,8 @@ public class RandomTraderGuiA extends AutoTraderGui {
private javax.swing.JSpinner buyVolMin;
private javax.swing.JSpinner buyWaitMax;
private javax.swing.JSpinner buyWaitMin;
private javax.swing.JSpinner initialDelayMax;
private javax.swing.JSpinner initialDelayMin;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
@ -424,6 +464,9 @@ public class RandomTraderGuiA extends AutoTraderGui {
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;

View File

@ -1,98 +0,0 @@
/*
* Copyright (c) 2016, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package traders;
import sesim.AccountData;
import sesim.Exchange;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class SwitchingTrader extends RandomTrader {
private int mode;
public SwitchingTrader(Exchange se, long id, String name, double money, double shares, RandomTraderConfig config) {
super(se, id, name, money, shares, config);
}
Action action = Action.RANDOM;
@Override
protected Action getAction() {
if (action == Action.RANDOM) {
action = super.getAction();
if ("Bob".equals(name)){
System.out.print("Bobs Action\n"+action);
}
return action;
}
AccountData ad = se.getAccountData(account_id);
if (action == Action.BUY && ad.money <= 0) {
action = Action.SELL;
}
if (action == Action.SELL && ad.shares <= 0) {
action = Action.BUY;
}
return action;
}
@Override
long doTrade(){
cancelOrders();
Action a = getAction();
long r;
switch (a){
case BUY:
r = doBuy();
if (r==0)
action=Action.SELL;
return r;
case SELL:
r= doSell();
if (r==0)
action=Action.BUY;
return r;
}
return 0;
}
}

View File

@ -1,69 +0,0 @@
/*
* Copyright (c) 2016, 7u83 <7u83@mail.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package traders;
import org.json.JSONObject;
import sesim.AutoTrader;
import sesim.AutoTraderConfig;
import sesim.Exchange;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTraderConfig {
@Override
public AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
return new traders.SwitchingTrader(se, id, name, money, shares, this);
}
public SwitchingTraderConfig() {
sell_volume = new Float[]{17f, 100f};
sell_limit = new Float[]{-30f, 1f};
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 Long[]{1L, 5L};
wait_after_buy = new Long[]{1L, 5L};
}
@Override
public String getDisplayName() {
return "SwitchingTrader";
}
@Override
public boolean getDevelStatus() {
return true;
}
}

View File

@ -57,17 +57,6 @@ public class Test {
System.out.print("haha\n");
}
static void print_account(AccountData ad) {
System.out.print(
"Account ID:"
+ ad.id
+ " Ballance:"
+ ad.money
+ " Shares:"
+ ad.shares
+ "\n"
);
}
static public String getFullClassName(String classFileName) throws IOException {
File file = new File(classFileName);