From 3fa00df06e175d9f03589c3a3dc610a9f6b05dd4 Mon Sep 17 00:00:00 2001
From: 7u83 <7u83@maiol.ru>
Date: Sun, 9 Apr 2017 08:50:45 +0200
Subject: [PATCH] Removed old AutoTrader stuff
---
nbproject/project.properties | 2 +-
src/gui/EditAutoTraderList.java | 4 +-
src/gui/EditStrategies.java | 2 -
src/gui/SeSimApplication.java | 2 +-
src/gui/Statistics.form | 37 +++++-
src/gui/Statistics.java | 28 ++++-
src/sesim/AutoTraderBase.java | 8 +-
src/sesim/AutoTraderConfig.java | 49 --------
src/sesim/AutoTraderConfigBase.java | 45 -------
src/sesim/AutoTraderList.java | 50 --------
src/sesim/AutoTraderRunConfig.java | 39 ------
src/sesim/OldAutoTrader.java | 95 ---------------
src/traders/ManTrader/ManTrader.java | 12 +-
src/traders/RandomTraderB.java | 2 +-
src/traders/RandomTraderConfig.java | 176 ---------------------------
15 files changed, 73 insertions(+), 478 deletions(-)
delete mode 100644 src/sesim/AutoTraderConfig.java
delete mode 100644 src/sesim/AutoTraderConfigBase.java
delete mode 100644 src/sesim/AutoTraderList.java
delete mode 100644 src/sesim/AutoTraderRunConfig.java
delete mode 100644 src/sesim/OldAutoTrader.java
delete mode 100644 src/traders/RandomTraderConfig.java
diff --git a/nbproject/project.properties b/nbproject/project.properties
index 864fce9..ae85217 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -1,4 +1,4 @@
-#Sun, 09 Apr 2017 00:33:50 +0200
+#Sun, 09 Apr 2017 08:50:11 +0200
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
diff --git a/src/gui/EditAutoTraderList.java b/src/gui/EditAutoTraderList.java
index 56e080b..4c787bb 100644
--- a/src/gui/EditAutoTraderList.java
+++ b/src/gui/EditAutoTraderList.java
@@ -41,7 +41,7 @@ import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import org.json.JSONArray;
import org.json.JSONObject;
-import sesim.AutoTraderConfig;
+//import sesim.AutoTraderConfig;
/**
*
@@ -139,7 +139,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
for (int r = 0; r < model.getRowCount(); r++) {
Boolean e = (Boolean) list.getValueAt(r, list.getColumn("Enabled").getModelIndex());
- if (e==null){
+ if (e == null) {
continue;
}
if (!e) {
diff --git a/src/gui/EditStrategies.java b/src/gui/EditStrategies.java
index 23170ff..8845f0c 100644
--- a/src/gui/EditStrategies.java
+++ b/src/gui/EditStrategies.java
@@ -36,8 +36,6 @@ import java.util.logging.Logger;
import javax.swing.JPanel;
import org.json.JSONArray;
import org.json.JSONObject;
-
-import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.AutoTraderInterface;
diff --git a/src/gui/SeSimApplication.java b/src/gui/SeSimApplication.java
index ae6cddd..e2147a7 100644
--- a/src/gui/SeSimApplication.java
+++ b/src/gui/SeSimApplication.java
@@ -54,7 +54,7 @@ import javax.swing.filechooser.FileNameExtensionFilter;
import org.json.JSONArray;
import org.json.JSONObject;
-import sesim.AutoTraderConfig;
+
import sesim.AutoTraderInterface;
import sesim.Exchange;
import sesim.Scheduler;
diff --git a/src/gui/Statistics.form b/src/gui/Statistics.form
index 8b754e1..3ac1fe9 100644
--- a/src/gui/Statistics.form
+++ b/src/gui/Statistics.form
@@ -3,8 +3,8 @@
diff --git a/src/gui/Statistics.java b/src/gui/Statistics.java
index 96d59aa..94d714a 100644
--- a/src/gui/Statistics.java
+++ b/src/gui/Statistics.java
@@ -47,21 +47,43 @@ public class Statistics extends javax.swing.JPanel {
// //GEN-BEGIN:initComponents
private void initComponents() {
- setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTable1 = new javax.swing.JTable();
+
+ setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+
+ jTable1.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+ {null, null, null, null},
+ {null, null, null, null},
+ {null, null, null, null},
+ {null, null, null, null}
+ },
+ new String [] {
+ "Title 1", "Title 2", "Title 3", "Title 4"
+ }
+ ));
+ jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 380, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(0, 128, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 280, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(0, 23, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTable jTable1;
// End of variables declaration//GEN-END:variables
}
diff --git a/src/sesim/AutoTraderBase.java b/src/sesim/AutoTraderBase.java
index a804940..93d9cf5 100644
--- a/src/sesim/AutoTraderBase.java
+++ b/src/sesim/AutoTraderBase.java
@@ -29,18 +29,18 @@ import org.json.JSONObject;
import sesim.Scheduler.TimerTaskRunner;
/**
- *
+ *
* @author 7u83 <7u83@mail.ru>
*/
public abstract class AutoTraderBase implements AutoTraderInterface, TimerTaskRunner {
protected double account_id;
protected Exchange se;
- protected AutoTraderConfig config;
+ // protected AutoTraderConfig config;
protected String name;
- public AutoTraderBase(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
+/* public AutoTraderBase(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
account_id = se.createAccount(money, shares);
Exchange.Account a = se.getAccount(account_id);
@@ -51,7 +51,7 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTaskRu
this.id = id;
}
-
+*/
public AutoTraderBase() {
se = null;
id = 0;
diff --git a/src/sesim/AutoTraderConfig.java b/src/sesim/AutoTraderConfig.java
deleted file mode 100644
index 457cf81..0000000
--- a/src/sesim/AutoTraderConfig.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2017, tobias
- * 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 javax.swing.JPanel;
-import org.json.JSONObject;
-
-/**
- *
- * @author 7u83
- */
-public abstract interface AutoTraderConfig {
-
- public abstract OldAutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares);
-
- public abstract String getDisplayName();
-
- public abstract AutoTraderGui getGui();
-
- public abstract JSONObject getConfig();
-
- public abstract void putConfig(JSONObject cfg);
-
- public abstract boolean getDevelStatus();
-
-}
diff --git a/src/sesim/AutoTraderConfigBase.java b/src/sesim/AutoTraderConfigBase.java
deleted file mode 100644
index c91eced..0000000
--- a/src/sesim/AutoTraderConfigBase.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2017, tobias
- * 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 org.json.JSONObject;
-
-/**
- *
- * @author tobias
- */
-public abstract class AutoTraderConfigBase implements AutoTraderConfig{
-
-
-
- @Override
- public boolean getDevelStatus() {
- return true;
- }
-
-
-}
-
\ No newline at end of file
diff --git a/src/sesim/AutoTraderList.java b/src/sesim/AutoTraderList.java
deleted file mode 100644
index 9d1b5b6..0000000
--- a/src/sesim/AutoTraderList.java
+++ /dev/null
@@ -1,50 +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 sesim;
-
-import java.util.SortedSet;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- *
- * @author 7u83 <7u83@mail.ru>
- */
-public class AutoTraderList {
-
- SortedSet traders;
-
- AutoTraderList(){
-
- }
-
- List getTraders(){
-
-
- return new ArrayList();
- }
-
-}
diff --git a/src/sesim/AutoTraderRunConfig.java b/src/sesim/AutoTraderRunConfig.java
deleted file mode 100644
index 2c1eafd..0000000
--- a/src/sesim/AutoTraderRunConfig.java
+++ /dev/null
@@ -1,39 +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;
-
-/**
- *
- * @author 7u83 <7u83@mail.ru>
- */
-public class AutoTraderRunConfig {
- AutoTraderConfig config;
- int num_traders;
- String trader_name;
- double initial_money;
- double initial_shares;
-
-}
diff --git a/src/sesim/OldAutoTrader.java b/src/sesim/OldAutoTrader.java
deleted file mode 100644
index d152dd4..0000000
--- a/src/sesim/OldAutoTrader.java
+++ /dev/null
@@ -1,95 +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 sesim;
-
-import org.json.JSONObject;
-import sesim.Exchange.Account;
-
-/**
- *
- * @author 7u83
- */
-public abstract class OldAutoTrader implements Scheduler.TimerTaskRunner {
-
- protected double account_id;
- protected Exchange se;
- protected AutoTraderConfig config;
-
- protected String name;
-
- public OldAutoTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
- account_id = se.createAccount(money, shares);
- Account a = se.getAccount(account_id);
-
- // a.owner=this;
-
- this.se = se;
- this.config = config;
- this.name = name;
- this.id=id;
-
- }
-
- public OldAutoTrader(){
- se=null;
- id=0;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public long getID(){
- return id;
- }
- private long id;
-
- public Exchange.Account getAccount(){
- return se.getAccount(account_id);
- }
-
- public void init(Exchange se,long id,String name, double money, double shares, JSONObject cfg){
- this.account_id=se.createAccount(money, shares);
-// se.getAccount(account_id).owner=this;
- this.se = se;
- this.name = name;
- this.id=id;
-
-
- }
-
- public Exchange getSE(){
- return se;
- }
-
- public abstract void start();
-
-}
diff --git a/src/traders/ManTrader/ManTrader.java b/src/traders/ManTrader/ManTrader.java
index 09639cb..6d82ce4 100644
--- a/src/traders/ManTrader/ManTrader.java
+++ b/src/traders/ManTrader/ManTrader.java
@@ -31,8 +31,8 @@ import javax.swing.JDialog;
import org.json.JSONObject;
import sesim.AutoTraderBase;
-import sesim.AutoTraderConfigBase;
-import sesim.AutoTraderConfig;
+
+//import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.AutoTraderInterface;
import sesim.Exchange;
@@ -45,10 +45,10 @@ import sesim.Exchange.OrderStatus;
*/
public class ManTrader extends AutoTraderBase implements AccountListener, AutoTraderInterface{
- public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
- // super(se, id, name, money, shares, null);
- super();
- }
+// public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
+// // super(se, id, name, money, shares, null);
+// super();
+// }
public ManTrader() {
super();
diff --git a/src/traders/RandomTraderB.java b/src/traders/RandomTraderB.java
index 2c80be2..67eb215 100644
--- a/src/traders/RandomTraderB.java
+++ b/src/traders/RandomTraderB.java
@@ -37,7 +37,7 @@ import org.json.JSONObject;
//import sesim.AccountData;
import sesim.AutoTraderBase;
-import sesim.AutoTraderConfig;
+
import sesim.AutoTraderGui;
import sesim.Exchange;
import sesim.Exchange.Account;
diff --git a/src/traders/RandomTraderConfig.java b/src/traders/RandomTraderConfig.java
deleted file mode 100644
index 7df98d1..0000000
--- a/src/traders/RandomTraderConfig.java
+++ /dev/null
@@ -1,176 +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 org.json.JSONArray;
-import org.json.JSONObject;
-
-import sesim.AutoTraderConfigBase;
-import sesim.AutoTraderConfig;
-import sesim.AutoTraderGui;
-import sesim.Exchange;
-import sesim.OldAutoTrader;
-
-/**
- *
- * @author 7u83
- */
-public class RandomTraderConfig extends AutoTraderConfigBase implements AutoTraderConfig {
-
- public Float[] sell_volume = {100f, 100f};
- public Float[] sell_limit = {-0.1f, 0.10101f};
- 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 Long[] buy_wait = {10000L, 50000L};
- public Long[] wait_after_buy = {10L, 30L};
-
- @Override
- public OldAutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
- if (cfg != null) {
- this.putConfig(cfg);
- }
- return null;
- //return new traders.RandomTrader(se, id, name, money, shares, this);
- }
-
- @Override
- public String getDisplayName() {
- return "Random A";
- }
-
- @Override
- public AutoTraderGui getGui() {
- return null;
- //return new RandomTraderGui(this);
- }
-
- final String SELL_VOLUME = "sell_volume";
- final String BUY_VOLUME = "buy_volume";
- final String SELL_LIMIT = "sell_limit";
- final String BUY_LIMIT = "buy_limit";
- final String SELL_WAIT = "sell_wait";
- final String BUY_WAIT = "buy_wait";
- final String WAIT_AFTER_SELL = "sell_wait_after";
- final String WAIT_AFTER_BUY = "buy_wait_after";
-
- @Override
- public JSONObject getConfig() {
- JSONObject jo = new JSONObject();
- jo.put(SELL_VOLUME, sell_volume);
- jo.put(BUY_VOLUME, buy_volume);
- jo.put(SELL_LIMIT, sell_limit);
- jo.put(BUY_LIMIT, buy_limit);
- jo.put(SELL_WAIT, sell_wait);
- jo.put(BUY_WAIT, buy_wait);
- jo.put(WAIT_AFTER_SELL, wait_after_sell);
- jo.put(WAIT_AFTER_BUY, wait_after_buy);
- jo.put("base",this.getClass().getCanonicalName());
-
- return jo;
- }
-
- /* private T to(Double o){
- if (Float==T){
- System.out.printf("Double ret %", o.floatValue());
- return new T(3);
- }
- return null;
- }
- */
- private Float[] to_float(JSONArray a) {
- Float[] ret = new Float[a.length()];
- for (int i = 0; i < a.length(); i++) {
- ret[i] = new Float(a.getDouble(i));
-
- }
- return ret;
- }
-
- private Integer[] to_integer(JSONArray a) {
- Integer[] ret = new Integer[a.length()];
- for (int i = 0; i < a.length(); i++) {
- ret[i] = a.getInt(i);
-
- }
- 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()];
- // Float x[] = new Float[2];
-
- for (int i = 0; i < a.length(); i++) {
- ret[i] = (Number) a.get(i);
- }
- return ret;
- }
-
- public void putConfig(JSONObject cfg) {
- if (cfg == null) {
- return;
- }
-
- // System.out.printf("Putconfig %s\n", cfg.toString(4));
-
- String cname = cfg.get(SELL_VOLUME).getClass().getName();
-
- // JSONArray a = cfg.getJSONArray(SELL_VOLUME);
- // System.out.printf("Array = %s \n", cname);
-
- 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));
-
- }
-
- @Override
- public boolean getDevelStatus() {
- return false;
-
- }
-}