Removed old AutoTrader stuff
This commit is contained in:
parent
6ae62ba294
commit
3fa00df06e
@ -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=
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -3,8 +3,8 @@
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder/>
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
@ -23,13 +23,42 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="380" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" min="-2" pref="270" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="128" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="280" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" min="-2" pref="275" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="23" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="jTable1">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||
<Table columnCount="4" rowCount="4">
|
||||
<Column editable="true" title="Title 1" type="java.lang.Object"/>
|
||||
<Column editable="true" title="Title 2" type="java.lang.Object"/>
|
||||
<Column editable="true" title="Title 3" type="java.lang.Object"/>
|
||||
<Column editable="true" title="Title 4" type="java.lang.Object"/>
|
||||
</Table>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -47,21 +47,43 @@ public class Statistics extends javax.swing.JPanel {
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
|
||||
);
|
||||
}// </editor-fold>//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
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 <OldAutoTrader> traders;
|
||||
|
||||
AutoTraderList(){
|
||||
|
||||
}
|
||||
|
||||
List getTraders(){
|
||||
|
||||
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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 extends Number> 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;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user