Work on manual trading console

This commit is contained in:
7u83 2017-02-07 01:53:43 +01:00
parent 5de1ca26c7
commit 346607fec3
22 changed files with 989 additions and 141 deletions

View File

@ -6,11 +6,6 @@ The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout. therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether. Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--> -->
<config-data xmlns="http://www.netbeans.org/ns/maven-config-data/1">
<configurations>
<configuration id="TRelease" profiles=""/>
</configurations>
</config-data>
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!-- <!--
Properties that influence various parts of the IDE, especially code formatting and the like. Properties that influence various parts of the IDE, especially code formatting and the like.

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
</goals>
<properties>
<jnlp.args>-classpath %classpath ${packageClassName}</jnlp.args>
<jnlp.jnlputable>java</jnlp.jnlputable>
</properties>
</action>
</actions>

View File

@ -2,14 +2,83 @@
<actions> <actions>
<action> <action>
<actionName>run</actionName> <actionName>run</actionName>
<displayName>Tube</displayName> <packagings>
<packaging>jar</packaging>
</packagings>
<goals> <goals>
<goal>process-classes</goal> <goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:jnlp</goal> <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals> </goals>
<properties> <properties>
<exec.args>-classpath %classpath ${packageClassName}</exec.args> <exec.args>-classpath %classpath gui.NewMDIApplication</exec.args>
<exec.executable>java</exec.executable> <exec.executable>java</exec.executable>
</properties> </properties>
</action> </action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath gui.NewMDIApplication</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath gui.NewMDIApplication</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>build</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>webstart:jnlp-single</goal>
</goals>
<properties>
<jar.finalName>sesim</jar.finalName>
<createChecksum>true</createChecksum>
<updateReleaseInfo>true</updateReleaseInfo>
<jnlp.archive>sesimj</jnlp.archive>
<jnlp.canUnsign>true</jnlp.canUnsign>
</properties>
</action>
<action>
<actionName>rebuild</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>nbm:standalone-zip</goal>
</goals>
<properties>
<jar.finalName>sesim</jar.finalName>
<createChecksum>true</createChecksum>
<updateReleaseInfo>true</updateReleaseInfo>
<jnlp.archive>sesim</jnlp.archive>
<webstart.verbose>true</webstart.verbose>
<netbeans.branding.token>SeSim</netbeans.branding.token>
<project>SeSim</project>
</properties>
</action>
</actions> </actions>

View File

@ -43,4 +43,13 @@
<exec.executable>java</exec.executable> <exec.executable>java</exec.executable>
</properties> </properties>
</action> </action>
<action>
<actionName>build</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>install</goal>
</goals>
</action>
</actions> </actions>

View File

@ -33,6 +33,11 @@
<artifactId>pgslookandfeel</artifactId> <artifactId>pgslookandfeel</artifactId>
<version>1.1.4</version> <version>1.1.4</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-api-1.7</artifactId>
<version>1.5</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -41,7 +41,8 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
public final void initChart(){ public final void initChart(){
data = new OHLCData(60000*30); // data = new OHLCData(60000*30);
data = new OHLCData(60000);
} }
/** /**

View File

@ -93,7 +93,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
JSONObject rowobj = traders.getJSONObject(row); JSONObject rowobj = traders.getJSONObject(row);
for (int col = 0; col < list.getColumnCount(); col++) { for (int col = 0; col < list.getColumnCount(); col++) {
String h = this.getColumnHeader(col); String h = this.getColumnHeader(col);
System.out.printf("Doing stuff for %s\n", h); // System.out.printf("Doing stuff for %s\n", h);
String val = null; String val = null;
try { try {

View File

@ -49,7 +49,7 @@
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/> <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="jBaseLabel" pref="263" max="32767" attributes="0"/> <Component id="jBaseLabel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jComboBoxStrategySelector" min="-2" pref="361" max="-2" attributes="0"/> <Component id="jComboBoxStrategySelector" min="-2" pref="361" max="-2" attributes="0"/>
</Group> </Group>
@ -67,7 +67,7 @@
<Component id="jBaseLabel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jBaseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="425" max="32767" attributes="0"/> <Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/> <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="jSaveButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jSaveButton" alignment="3" min="-2" max="-2" attributes="0"/>

View File

@ -295,6 +295,7 @@ public final class EditStrategies extends javax.swing.JDialog {
acgui.setVisible(true); acgui.setVisible(true);
} else { } else {
System.out.printf("Adding default gui panel\n");
guiPanel.add(this.defaultGuiPanel, java.awt.BorderLayout.CENTER); guiPanel.add(this.defaultGuiPanel, java.awt.BorderLayout.CENTER);
} }
this.revalidate(); this.revalidate();
@ -314,7 +315,9 @@ public final class EditStrategies extends javax.swing.JDialog {
private void jSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSaveButtonActionPerformed private void jSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSaveButtonActionPerformed
acgui.save(); if (acgui!=null)
acgui.save();
JSONObject o = ac.getConfig(); JSONObject o = ac.getConfig();
String item = (String) this.jComboBoxStrategySelector.getSelectedItem(); String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
@ -391,6 +394,9 @@ System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
AutoTraderConfig ac = Globals.tloader.getStrategyBase(sd.result.base); AutoTraderConfig ac = Globals.tloader.getStrategyBase(sd.result.base);
JSONObject cfg = ac.getConfig(); JSONObject cfg = ac.getConfig();
System.out.printf("Initial cfg %s\n", cfg.toString(2));
cfg.put("base", ac.getClass().getCanonicalName());
Globals.saveStrategy(sd.result.name, cfg); Globals.saveStrategy(sd.result.name, cfg);
this.initComboBox(); this.initComboBox();
}//GEN-LAST:event_jNewButtonActionPerformed }//GEN-LAST:event_jNewButtonActionPerformed

View File

@ -34,6 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.UIManager; import javax.swing.UIManager;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -45,6 +46,8 @@ import sesim.AutoTraderLoader;
*/ */
public class Globals { public class Globals {
public static JFrame frame;
static final String STRATEGYPREFS = "Strategies"; static final String STRATEGYPREFS = "Strategies";
static final String TRADERPREFS = "Traders"; static final String TRADERPREFS = "Traders";

View File

@ -262,7 +262,7 @@
<Component id="jPanel2" min="-2" max="-2" attributes="0"/> <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jChartScrollPane" pref="301" max="32767" attributes="0"/> <Component id="jChartScrollPane" max="32767" attributes="0"/>
<Component id="orderBookPanel" max="32767" attributes="0"/> <Component id="orderBookPanel" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>

View File

@ -55,60 +55,74 @@ public class NewMDIApplication extends javax.swing.JFrame {
*/ */
public NewMDIApplication() { public NewMDIApplication() {
initComponents(); initComponents();
Globals.frame=this;
this.setLocationRelativeTo(this); this.setLocationRelativeTo(this);
this.setTitle("SeSim - Stock Exchange Simmulator"); this.setTitle("SeSim - Stock Exchange Simmulator");
} }
AutoTrader createTraderNew(Exchange se,long id,String name, double money, double shares, JSONObject cfg) {
System.out.printf("!!!! creating new\n");
String base = cfg.getString("base");
AutoTrader ac = (AutoTrader)Globals.tloader.getStrategyBase(base);
((AutoTraderConfig)ac).putConfig(cfg);
ac.init(se, id, name, money, shares, cfg);
return ac;
}
public void startTraders() { public void startTraders() {
JSONArray tlist = Globals.getTraders(); JSONArray tlist = Globals.getTraders();
Double moneyTotal=0.0; Double moneyTotal = 0.0;
Double sharesTotal=0.0; Double sharesTotal = 0.0;
long id=0; long id = 0;
for (int i=0; i<tlist.length();i++){ for (int i = 0; i < tlist.length(); i++) {
JSONObject t=tlist.getJSONObject(i); JSONObject t = tlist.getJSONObject(i);
String strategy_name = t.getString("Strategy"); String strategy_name = t.getString("Strategy");
JSONObject strategy = Globals.getStrategy(strategy_name); JSONObject strategy = Globals.getStrategy(strategy_name);
String base = strategy.getString("base"); String base = strategy.getString("base");
AutoTraderConfig ac = Globals.tloader.getStrategyBase(base); AutoTraderConfig ac = Globals.tloader.getStrategyBase(base);
System.out.printf("Load Strat: %s\n",strategy_name); System.out.printf("Load Strat: %s\n", strategy_name);
System.out.printf("Base %s\n", base); System.out.printf("Base %s\n", base);
Integer count = t.getInt("Count"); Integer count = t.getInt("Count");
Double shares = t.getDouble("Shares"); Double shares = t.getDouble("Shares");
Double money = t.getDouble("Money"); Double money = t.getDouble("Money");
Boolean enabled = t.getBoolean("Enabled"); Boolean enabled = t.getBoolean("Enabled");
if (!enabled) if (!enabled) {
continue; continue;
}
System.out.printf("Count: %d Shares: %f Money %f\n", count,shares,money); System.out.printf("Count: %d Shares: %f Money %f\n", count, shares, money);
for (int i1 = 0; i1 < count; i1++) {
AutoTrader trader = ac.createTrader(Globals.se, strategy, id++, t.getString("Name") + i1, money, shares);
if (trader == null) {
System.out.printf("shoudl create new\n");
trader = this.createTraderNew(Globals.se, id, t.getString("Name") + i1, money, shares, strategy);
}
for (int i1=0;i1<count;i1++){
AutoTrader trader = ac.createTrader(Globals.se, strategy, id++, t.getString("Name")+i1,money, shares);
Globals.se.traders.add(trader); Globals.se.traders.add(trader);
// trader.setName(t.getString("Name")+i1); // trader.setName(t.getString("Name")+i1);
moneyTotal+=money; moneyTotal += money;
sharesTotal+=shares; sharesTotal += shares;
// trader.start(); // trader.start();
} }
} }
Globals.se.fairValue=moneyTotal/sharesTotal; Globals.se.fairValue = moneyTotal / sharesTotal;
Globals.se.fairValue=15.0; Globals.se.fairValue = 15.0;
for (int i=0; i<Globals.se.traders.size(); i++){ for (int i = 0; i < Globals.se.traders.size(); i++) {
Globals.se.traders.get(i).start(); Globals.se.traders.get(i).start();
} }
} }
/** /**
@ -453,7 +467,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jChartScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE) .addComponent(jChartScrollPane)
.addComponent(orderBookPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(orderBookPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap()) .addContainerGap())
); );
@ -471,39 +485,38 @@ public class NewMDIApplication extends javax.swing.JFrame {
}//GEN-LAST:event_aboutMenuItemActionPerformed }//GEN-LAST:event_aboutMenuItemActionPerformed
void pauseSim() {
void pauseSim(){
Globals.se.timer.pause(); Globals.se.timer.pause();
} }
void startSim(){ void startSim() {
resetSim(); resetSim();
this.stopButton.setEnabled(true); this.stopButton.setEnabled(true);
this.startTraders(); this.startTraders();
Globals.se.timer.setPause(false); Globals.se.timer.setPause(false);
Globals.se.timer.start(); Globals.se.timer.start();
Globals.se.timer.setAcceleration((Double)this.accelSpinner.getValue()); Globals.se.timer.setAcceleration((Double) this.accelSpinner.getValue());
this.clock.invalidate(); this.clock.invalidate();
this.clock.repaint(); this.clock.repaint();
} }
void stopSim(){ void stopSim() {
Globals.se.timer.terminate(); Globals.se.timer.terminate();
this.stopButton.setEnabled(false); this.stopButton.setEnabled(false);
} }
void resetSim(){ void resetSim() {
Globals.se.terminate(); Globals.se.terminate();
Globals.se.reset(); Globals.se.reset();
chart.initChart(); chart.initChart();
chart.invalidate(); chart.invalidate();
chart.repaint(); chart.repaint();
this.orderBookPanel.invalidate(); this.orderBookPanel.invalidate();
this.orderBookPanel.repaint(); this.orderBookPanel.repaint();
} }
@ -532,12 +545,9 @@ public class NewMDIApplication extends javax.swing.JFrame {
s.setVisible(rootPaneCheckingEnabled); s.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_pasteMenuItemActionPerformed }//GEN-LAST:event_pasteMenuItemActionPerformed
private final LoggerDialog log_d = new LoggerDialog(this, false);
private final LoggerDialog log_d = new LoggerDialog(this,false);
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
log_d.setVisible(!log_d.isShowing()); log_d.setVisible(!log_d.isShowing());
@ -552,47 +562,41 @@ public class NewMDIApplication extends javax.swing.JFrame {
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("SeSim Files","sesim"); FileNameExtensionFilter filter = new FileNameExtensionFilter("SeSim Files", "sesim");
fc.setFileFilter(filter); fc.setFileFilter(filter);
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION){
return; return;
} }
File f = fc.getSelectedFile(); File f = fc.getSelectedFile();
String [] e = ((FileNameExtensionFilter)fc.getFileFilter()).getExtensions(); String[] e = ((FileNameExtensionFilter) fc.getFileFilter()).getExtensions();
System.out.printf("Abs: %s\n", f.getAbsoluteFile()); System.out.printf("Abs: %s\n", f.getAbsoluteFile());
String fn=f.getAbsolutePath(); String fn = f.getAbsolutePath();
if (!f.getAbsolutePath().endsWith(e[0])) {
if (!f.getAbsolutePath().endsWith(e[0])){ f = new File(f.getAbsolutePath() + "." + e[0]);
f = new File(f.getAbsolutePath()+"."+e[0]);
} }
Globals.saveFile(f); Globals.saveFile(f);
System.out.printf("Sel File: %s \n", f.getAbsolutePath());
System.out.printf("Sel File: %s \n",f.getAbsolutePath());
}//GEN-LAST:event_saveAsMenuItemActionPerformed }//GEN-LAST:event_saveAsMenuItemActionPerformed
private void editExchangeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editExchangeMenuItemActionPerformed private void editExchangeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editExchangeMenuItemActionPerformed
EditExchangeDialog ed=new EditExchangeDialog((Frame) this.getParent(),true); EditExchangeDialog ed = new EditExchangeDialog((Frame) this.getParent(), true);
int rc = ed.showdialog(); int rc = ed.showdialog();
// System.out.printf("EDRET: %d\n",rc); // System.out.printf("EDRET: %d\n",rc);
}//GEN-LAST:event_editExchangeMenuItemActionPerformed }//GEN-LAST:event_editExchangeMenuItemActionPerformed
private void viewClockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewClockActionPerformed private void viewClockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewClockActionPerformed
ClockDialog cd = new ClockDialog(this,true); ClockDialog cd = new ClockDialog(this, true);
cd.setVisible(rootPaneCheckingEnabled); cd.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_viewClockActionPerformed }//GEN-LAST:event_viewClockActionPerformed
@ -614,7 +618,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
}//GEN-LAST:event_simMenuStopActionPerformed }//GEN-LAST:event_simMenuStopActionPerformed
private void accelSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_accelSpinnerStateChanged private void accelSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_accelSpinnerStateChanged
Double val = (Double)this.accelSpinner.getValue(); Double val = (Double) this.accelSpinner.getValue();
Globals.se.timer.setAcceleration(val); Globals.se.timer.setAcceleration(val);
}//GEN-LAST:event_accelSpinnerStateChanged }//GEN-LAST:event_accelSpinnerStateChanged
@ -665,12 +669,13 @@ public class NewMDIApplication extends javax.swing.JFrame {
} }
for (Class<AutoTraderConfig> at_class : traders) { for (Class<AutoTraderConfig> at_class : traders) {
System.out.printf("Class = %s\n",at_class.getName()); System.out.printf("Class = %s\n", at_class.getName());
if (Modifier.isAbstract(at_class.getModifiers())) { if (Modifier.isAbstract(at_class.getModifiers())) {
continue; continue;
} }
AutoTraderConfig cfg = at_class.newInstance(); AutoTraderConfig cfg = at_class.newInstance();
System.out.printf("Have a Trader with name: %s\n", cfg.getDisplayName()); System.out.printf("Have a Trader with name: %s\n", cfg.getDisplayName());
} }

View File

@ -25,6 +25,7 @@
*/ */
package sesim; package sesim;
import org.json.JSONObject;
import sesim.Exchange.Account; import sesim.Exchange.Account;
/** /**
@ -52,6 +53,11 @@ public abstract class AutoTrader implements Scheduler.TimerTask {
} }
public AutoTrader(){
se=null;
id=0;
}
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@ -64,12 +70,26 @@ public abstract class AutoTrader implements Scheduler.TimerTask {
public long getID(){ public long getID(){
return id; return id;
} }
private final long id; private long id;
public Exchange.Account getAccount(){ public Exchange.Account getAccount(){
return se.getAccount(account_id); 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(); public abstract void start();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, tobias * Copyright (c) 2017, 7u83 <7u83@mail.ru>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -25,21 +25,18 @@
*/ */
package sesim; package sesim;
import org.json.JSONObject;
/** /**
* *
* @author tobias * @author 7u83 <7u83@mail.ru>
*/ */
public abstract class AutoTraderBase implements AutoTraderConfig{ public abstract class AutoTraderBase extends AutoTrader implements AutoTraderConfig{
// public AutoTraderBase(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
// super(se, id, name, money, shares, config);
// }
@Override
public boolean getDevelStatus() {
return true;
}
} }

View File

@ -0,0 +1,45 @@
/*
* 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;
}
}

View File

@ -0,0 +1,102 @@
/*
* 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.ManTrader;
import gui.Globals;
import org.json.JSONObject;
import sesim.AutoTrader;
import sesim.AutoTraderBase;
import sesim.AutoTraderConfigBase;
import sesim.AutoTraderConfig;
import sesim.AutoTraderGui;
import sesim.Exchange;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ManTrader extends AutoTraderBase implements AutoTraderConfig {
public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
// super(se, id, name, money, shares, null);
super();
}
public ManTrader() {
}
ManTraderConsoleDialog consoleDialog;
@Override
public void start() {
se.timer.startTimerEvent(this, 0);
consoleDialog = new ManTraderConsoleDialog(Globals.frame, false);
consoleDialog.getConsole().trader=this;
consoleDialog.setVisible(true);
}
@Override
public long timerTask() {
System.out.printf("TimerTask\n");
return 1000;
}
@Override
public AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
return null;
}
@Override
public String getDisplayName() {
return null;
}
@Override
public AutoTraderGui getGui() {
return null;
}
@Override
public JSONObject getConfig() {
System.out.printf("return new json object\n");
return new JSONObject();
}
@Override
public void putConfig(JSONObject cfg) {
return;
}
@Override
public boolean getDevelStatus() {
return true;
}
}

View File

@ -0,0 +1,83 @@
/*
* 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.ManTrader;
import org.json.JSONObject;
import sesim.AutoTrader;
import sesim.AutoTraderBase;
import sesim.AutoTraderConfigBase;
import sesim.AutoTraderGui;
import sesim.Exchange;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ManTraderConfig extends AutoTraderBase{
@Override
public void start() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public long timerTask() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public String getDisplayName() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public AutoTraderGui getGui() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public JSONObject getConfig() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void putConfig(JSONObject cfg) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean getDevelStatus() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<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" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="buyButton" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="sellButton" min="-2" pref="191" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
<Component id="volumeSpinner" min="-2" pref="108" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" pref="88" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="limitSpinner" min="-2" pref="108" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="moneyText" min="-2" pref="330" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="8" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace 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 max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="98" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="moneyText" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="29" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="limitSpinner" 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="volumeSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buyButton" pref="72" max="32767" attributes="0"/>
<Component id="sellButton" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" 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>
<Component class="javax.swing.JSpinner" name="limitSpinner">
<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.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Limit:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Volume:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="volumeSpinner">
<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.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buyButton">
<Properties>
<Property name="text" type="java.lang.String" value="Buy"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buyButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="sellButton">
<Properties>
<Property name="text" type="java.lang.String" value="Sell"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sellButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Money:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="moneyText">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel4"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,195 @@
/*
* 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.ManTrader;
import sesim.AutoTrader;
import sesim.Exchange;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ManTraderConsole extends javax.swing.JPanel {
public AutoTrader trader;
/**
* Creates new form ManTraderConsole
*/
public ManTraderConsole() {
initComponents();
}
/**
* 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() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
limitSpinner = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
volumeSpinner = new javax.swing.JSpinner();
buyButton = new javax.swing.JButton();
sellButton = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
moneyText = new javax.swing.JLabel();
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);
limitSpinner.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, null, 1.0d));
jLabel1.setText("Limit:");
jLabel2.setText("Volume:");
volumeSpinner.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, null, 1.0d));
buyButton.setText("Buy");
buyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buyButtonActionPerformed(evt);
}
});
sellButton.setText("Sell");
sellButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sellButtonActionPerformed(evt);
}
});
jLabel3.setText("Money:");
moneyText.setText("jLabel4");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(buyButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sellButton, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(44, 44, 44)
.addComponent(volumeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(limitSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(moneyText, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 8, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(moneyText))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(limitSpinner, 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(volumeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buyButton, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)
.addComponent(sellButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void buyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buyButtonActionPerformed
Double limit = (Double)this.limitSpinner.getValue();
Double volume = (Double)this.volumeSpinner.getValue();
System.out.printf("Should buy: %f %f\n",volume,limit);
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.BID, volume, limit);
System.out.printf("The retval is %d",createOrder);
}//GEN-LAST:event_buyButtonActionPerformed
private void sellButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sellButtonActionPerformed
Double limit = (Double)this.limitSpinner.getValue();
Double volume = (Double)this.volumeSpinner.getValue();
System.out.printf("Should buy: %f %f\n",volume,limit);
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.ASK, volume, limit);
System.out.printf("The retval is %d",createOrder);
}//GEN-LAST:event_sellButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buyButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JSpinner limitSpinner;
private javax.swing.JLabel moneyText;
private javax.swing.JButton sellButton;
private javax.swing.JSpinner volumeSpinner;
// End of variables declaration//GEN-END:variables
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<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="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="console" pref="383" max="32767" attributes="0"/>
<EmptySpace 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 max="-2" attributes="0"/>
<Component id="console" pref="280" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="traders.ManTrader.ManTraderConsole" name="console">
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,127 @@
/*
* 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.ManTrader;
import javax.swing.JPanel;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class ManTraderConsoleDialog extends javax.swing.JDialog {
/**
* Creates new form ManTraderConsole
*/
public ManTraderConsoleDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
public ManTraderConsole getConsole(){
return this.console;
}
/**
* 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() {
console = new traders.ManTrader.ManTraderConsole();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(console, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(console, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ManTraderConsoleDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ManTraderConsoleDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ManTraderConsoleDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ManTraderConsoleDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
ManTraderConsoleDialog dialog = new ManTraderConsoleDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private traders.ManTrader.ManTraderConsole console;
// End of variables declaration//GEN-END:variables
}

View File

@ -31,7 +31,7 @@ import javax.swing.JPanel;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import sesim.AutoTrader; import sesim.AutoTrader;
import sesim.AutoTraderBase; import sesim.AutoTraderConfigBase;
import sesim.AutoTraderConfig; import sesim.AutoTraderConfig;
import sesim.AutoTraderGui; import sesim.AutoTraderGui;
import sesim.Exchange; import sesim.Exchange;
@ -40,7 +40,7 @@ import sesim.Exchange;
* *
* @author 7u83 * @author 7u83
*/ */
public class RandomTraderConfig extends AutoTraderBase implements AutoTraderConfig { public class RandomTraderConfig extends AutoTraderConfigBase implements AutoTraderConfig {
public Float[] sell_volume = {100f, 100f}; public Float[] sell_volume = {100f, 100f};
public Float[] sell_limit = {-0.1f, 0.10101f}; public Float[] sell_limit = {-0.1f, 0.10101f};