Work on manual trading
This commit is contained in:
parent
4090947001
commit
6039c95d6a
5
pom.xml
5
pom.xml
@ -38,6 +38,11 @@
|
|||||||
<artifactId>keytool-api-1.7</artifactId>
|
<artifactId>keytool-api-1.7</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jdesktop</groupId>
|
||||||
|
<artifactId>beansbinding</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
@ -44,8 +44,8 @@
|
|||||||
</Group>
|
</Group>
|
||||||
<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="jSpinner2" alignment="1" min="-2" pref="70" max="-2" attributes="0"/>
|
<Component id="moneyDecimalsSpinner" alignment="1" min="-2" pref="70" max="-2" attributes="0"/>
|
||||||
<Component id="jSpinner1" alignment="1" min="-2" pref="70" max="-2" attributes="0"/>
|
<Component id="sharesDecimalsSpinner" alignment="1" min="-2" pref="70" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
@ -58,18 +58,18 @@
|
|||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jSpinner1" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
<Component id="sharesDecimalsSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
||||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jSpinner2" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
<Component id="moneyDecimalsSpinner" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
|
||||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace pref="32" max="32767" attributes="0"/>
|
<EmptySpace pref="32" max="32767" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JSpinner" name="jSpinner1">
|
<Component class="javax.swing.JSpinner" name="sharesDecimalsSpinner">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
<SpinnerModel initial="0" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
<SpinnerModel initial="0" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||||
@ -89,7 +89,7 @@
|
|||||||
<Property name="text" type="java.lang.String" value="Number of decimals for shares:"/>
|
<Property name="text" type="java.lang.String" value="Number of decimals for shares:"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JSpinner" name="jSpinner2">
|
<Component class="javax.swing.JSpinner" name="moneyDecimalsSpinner">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
<SpinnerModel initial="2" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
<SpinnerModel initial="2" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||||
@ -106,14 +106,17 @@
|
|||||||
<Property name="mnemonic" type="int" value="99"/>
|
<Property name="mnemonic" type="int" value="99"/>
|
||||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="jButton2">
|
<Component class="javax.swing.JButton" name="okButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="mnemonic" type="int" value="111"/>
|
<Property name="mnemonic" type="int" value="111"/>
|
||||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
@ -38,6 +40,9 @@ public class EditExchangeDialog extends javax.swing.JDialog {
|
|||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
initComponents();
|
initComponents();
|
||||||
this.setLocationRelativeTo(parent);
|
this.setLocationRelativeTo(parent);
|
||||||
|
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
||||||
|
this.moneyDecimalsSpinner.setValue(jo.getInt(Globals.se.CFG_MONEY_DECIMALS));
|
||||||
|
this.sharesDecimalsSpinner.setValue(jo.getInt(Globals.se.CFG_SHARES_DECIMALS));
|
||||||
}
|
}
|
||||||
|
|
||||||
int showdialog() {
|
int showdialog() {
|
||||||
@ -54,34 +59,39 @@ public class EditExchangeDialog extends javax.swing.JDialog {
|
|||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
jSpinner1 = new javax.swing.JSpinner();
|
sharesDecimalsSpinner = new javax.swing.JSpinner();
|
||||||
jLabel1 = new javax.swing.JLabel();
|
jLabel1 = new javax.swing.JLabel();
|
||||||
jSpinner2 = new javax.swing.JSpinner();
|
moneyDecimalsSpinner = new javax.swing.JSpinner();
|
||||||
jLabel2 = new javax.swing.JLabel();
|
jLabel2 = new javax.swing.JLabel();
|
||||||
jButton1 = new javax.swing.JButton();
|
jButton1 = new javax.swing.JButton();
|
||||||
jButton2 = new javax.swing.JButton();
|
okButton = new javax.swing.JButton();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
setTitle("SeSim ExchangeSettings");
|
setTitle("SeSim ExchangeSettings");
|
||||||
setMinimumSize(new java.awt.Dimension(300, 142));
|
setMinimumSize(new java.awt.Dimension(300, 142));
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
jSpinner1.setModel(new javax.swing.SpinnerNumberModel(0, 0, 10, 1));
|
sharesDecimalsSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 10, 1));
|
||||||
|
|
||||||
jLabel1.setText("Number of decimals for shares:");
|
jLabel1.setText("Number of decimals for shares:");
|
||||||
|
|
||||||
jSpinner2.setModel(new javax.swing.SpinnerNumberModel(2, 0, 10, 1));
|
moneyDecimalsSpinner.setModel(new javax.swing.SpinnerNumberModel(2, 0, 10, 1));
|
||||||
|
|
||||||
jLabel2.setText("Number of decimals for money:");
|
jLabel2.setText("Number of decimals for money:");
|
||||||
|
|
||||||
jButton1.setMnemonic('c');
|
jButton1.setMnemonic('c');
|
||||||
jButton1.setText("Cancel");
|
jButton1.setText("Cancel");
|
||||||
|
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
jButton2.setMnemonic('o');
|
|
||||||
jButton2.setText("Ok");
|
|
||||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
jButton2ActionPerformed(evt);
|
jButton1ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
okButton.setMnemonic('o');
|
||||||
|
okButton.setText("Ok");
|
||||||
|
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
okButtonActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -94,7 +104,7 @@ public class EditExchangeDialog extends javax.swing.JDialog {
|
|||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGap(0, 0, Short.MAX_VALUE)
|
||||||
.addComponent(jButton2)
|
.addComponent(okButton)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(jButton1))
|
.addComponent(jButton1))
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
@ -103,8 +113,8 @@ public class EditExchangeDialog extends javax.swing.JDialog {
|
|||||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.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(jSpinner2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(moneyDecimalsSpinner, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jSpinner1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
.addComponent(sharesDecimalsSpinner, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
@ -112,25 +122,34 @@ public class EditExchangeDialog extends javax.swing.JDialog {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addGap(15, 15, 15)
|
.addGap(15, 15, 15)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(sharesDecimalsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jLabel1))
|
.addComponent(jLabel1))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(moneyDecimalsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jLabel2))
|
.addComponent(jLabel2))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jButton1)
|
.addComponent(jButton1)
|
||||||
.addComponent(jButton2))
|
.addComponent(okButton))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||||
// Globals.prefs.put("money_decimals", value);
|
JSONObject jo = new JSONObject();
|
||||||
}//GEN-LAST:event_jButton2ActionPerformed
|
jo.put(Globals.se.CFG_MONEY_DECIMALS, (Integer) this.moneyDecimalsSpinner.getValue());
|
||||||
|
jo.put(Globals.se.CFG_SHARES_DECIMALS, (Integer) this.sharesDecimalsSpinner.getValue());
|
||||||
|
System.out.printf("EC: %s\n", jo.toString(3));
|
||||||
|
Globals.prefs.put("Exchange", jo.toString());
|
||||||
|
dispose();
|
||||||
|
}//GEN-LAST:event_okButtonActionPerformed
|
||||||
|
|
||||||
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||||
|
dispose();
|
||||||
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
@ -177,10 +196,10 @@ public class EditExchangeDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton jButton1;
|
private javax.swing.JButton jButton1;
|
||||||
private javax.swing.JButton jButton2;
|
|
||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JLabel jLabel1;
|
||||||
private javax.swing.JLabel jLabel2;
|
private javax.swing.JLabel jLabel2;
|
||||||
private javax.swing.JSpinner jSpinner1;
|
private javax.swing.JSpinner moneyDecimalsSpinner;
|
||||||
private javax.swing.JSpinner jSpinner2;
|
private javax.swing.JButton okButton;
|
||||||
|
private javax.swing.JSpinner sharesDecimalsSpinner;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ import java.util.logging.Logger;
|
|||||||
import javax.swing.JPanel;
|
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.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.AutoTraderGui;
|
import sesim.AutoTraderGui;
|
||||||
import sesim.AutoTraderInterface;
|
import sesim.AutoTraderInterface;
|
||||||
|
@ -27,7 +27,7 @@ package gui;
|
|||||||
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import sesim.AutoTrader;
|
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
import traders.*;
|
import traders.*;
|
||||||
|
|
||||||
|
@ -243,16 +243,12 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
|
||||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
|
||||||
<Group type="102" attributes="0">
|
|
||||||
<Component id="orderBookPanel" min="-2" pref="233" max="-2" attributes="0"/>
|
<Component id="orderBookPanel" min="-2" pref="233" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jChartScrollPane" max="32767" attributes="0"/>
|
<Component id="jChartScrollPane" max="32767" attributes="0"/>
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
|
@ -39,7 +39,7 @@ import javax.swing.UIManager;
|
|||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import sesim.AutoTrader;
|
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.AutoTraderInterface;
|
import sesim.AutoTraderInterface;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
@ -73,8 +73,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
public void startTraders() {
|
public void startTraders() {
|
||||||
|
|
||||||
Globals.se.setMoneyDecimals(8);
|
// Globals.se.setMoneyDecimals(8);
|
||||||
Globals.se.setSharesDecimals(0);
|
// Globals.se.setSharesDecimals(0);
|
||||||
|
|
||||||
JSONArray tlist = Globals.getTraders();
|
JSONArray tlist = Globals.getTraders();
|
||||||
|
|
||||||
@ -458,13 +458,11 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(orderBookPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(orderBookPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(jChartScrollPane)))
|
.addComponent(jChartScrollPane)
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
|
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
@ -497,7 +495,12 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
void startSim() {
|
void startSim() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resetSim();
|
resetSim();
|
||||||
|
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
||||||
|
Globals.se.putConfig(jo);
|
||||||
|
|
||||||
this.stopButton.setEnabled(true);
|
this.stopButton.setEnabled(true);
|
||||||
|
|
||||||
this.orderBookPanel.invalidate();
|
this.orderBookPanel.invalidate();
|
||||||
|
@ -38,12 +38,14 @@
|
|||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JTable" name="order_table">
|
<Component class="javax.swing.JTable" name="order_table">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
|
||||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||||
<Table columnCount="4" rowCount="4">
|
<Table columnCount="5" rowCount="4">
|
||||||
<Column editable="true" title="ID" type="java.lang.Long"/>
|
<Column editable="false" title="ID" type="java.lang.Long"/>
|
||||||
<Column editable="true" title="Type" type="java.lang.String"/>
|
<Column editable="false" title="Type" type="java.lang.String"/>
|
||||||
<Column editable="true" title="Price" type="java.lang.Double"/>
|
<Column editable="false" title="Limit" type="java.lang.Double"/>
|
||||||
<Column editable="true" title="Volume" type="java.lang.Double"/>
|
<Column editable="false" title="Volume" type="java.lang.Double"/>
|
||||||
|
<Column editable="false" title="Status" type="java.lang.String"/>
|
||||||
</Table>
|
</Table>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -25,9 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import sesim.Exchange.Account;
|
import sesim.Exchange.Account;
|
||||||
|
import sesim.Exchange.Order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -39,20 +43,29 @@ public class OrdersList extends javax.swing.JPanel {
|
|||||||
DefaultTableModel model;
|
DefaultTableModel model;
|
||||||
|
|
||||||
public final void updateModel() {
|
public final void updateModel() {
|
||||||
if (null==account)
|
if (null == account) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
account.getOrders().forEach(new BiConsumer() {
|
|
||||||
@Override
|
|
||||||
public void accept(Object k, Object u) {
|
|
||||||
System.out.printf("Key: %d\n", (Long)k);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
Iterator<Map.Entry<Long, Order>> it = account.getOrders().entrySet().iterator();
|
||||||
|
model.setRowCount(account.getOrders().size());
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry e = it.next();
|
||||||
|
Long k = (Long) e.getKey();
|
||||||
|
Order o = (Order) e.getValue();
|
||||||
|
|
||||||
|
model.setValueAt(k, row, 0);
|
||||||
|
|
||||||
|
model.setValueAt(((Order) o).getType().toString(), row, 1);
|
||||||
|
|
||||||
|
model.setValueAt(((Order) o).getLimit(), row, 2);
|
||||||
|
model.setValueAt(((Order) o).getVolume(), row, 3);
|
||||||
|
model.setValueAt(((Order) o).getOrderStatus().toString(), row, 4);
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
this.order_table.getRowSorter().allRowsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,24 +89,32 @@ public class OrdersList extends javax.swing.JPanel {
|
|||||||
jScrollPane1 = new javax.swing.JScrollPane();
|
jScrollPane1 = new javax.swing.JScrollPane();
|
||||||
order_table = new javax.swing.JTable();
|
order_table = new javax.swing.JTable();
|
||||||
|
|
||||||
|
order_table.setAutoCreateRowSorter(true);
|
||||||
order_table.setModel(new javax.swing.table.DefaultTableModel(
|
order_table.setModel(new javax.swing.table.DefaultTableModel(
|
||||||
new Object [][] {
|
new Object [][] {
|
||||||
{null, null, null, null},
|
{null, null, null, null, null},
|
||||||
{null, null, null, null},
|
{null, null, null, null, null},
|
||||||
{null, null, null, null},
|
{null, null, null, null, null},
|
||||||
{null, null, null, null}
|
{null, null, null, null, null}
|
||||||
},
|
},
|
||||||
new String [] {
|
new String [] {
|
||||||
"ID", "Type", "Price", "Volume"
|
"ID", "Type", "Limit", "Volume", "Status"
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Class[] types = new Class [] {
|
Class[] types = new Class [] {
|
||||||
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class
|
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.String.class
|
||||||
|
};
|
||||||
|
boolean[] canEdit = new boolean [] {
|
||||||
|
false, false, false, false, false
|
||||||
};
|
};
|
||||||
|
|
||||||
public Class getColumnClass(int columnIndex) {
|
public Class getColumnClass(int columnIndex) {
|
||||||
return types [columnIndex];
|
return types [columnIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||||
|
return canEdit [columnIndex];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
jScrollPane1.setViewportView(order_table);
|
jScrollPane1.setViewportView(order_table);
|
||||||
|
|
||||||
|
28
src/main/java/gui/TestPanel.form
Normal file
28
src/main/java/gui/TestPanel.form
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" 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">
|
||||||
|
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
</Form>
|
65
src/main/java/gui/TestPanel.java
Normal file
65
src/main/java/gui/TestPanel.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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 gui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class TestPanel extends TraderListPanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form TestPanel
|
||||||
|
*/
|
||||||
|
public TestPanel() {
|
||||||
|
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() {
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
this.setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 400, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 300, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||||
|
<Property name="title" type="java.lang.String" value="Trader List"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<SyntheticProperties>
|
<SyntheticProperties>
|
||||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
@ -23,25 +24,17 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Component id="traderListPanel22" alignment="1" pref="574" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="traderListPanel1" max="32767" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="1" attributes="0">
|
<Component id="traderListPanel22" alignment="0" pref="312" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="traderListPanel1" pref="294" max="32767" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="gui.TraderListPanel" name="traderListPanel1">
|
<Component class="gui.TraderListPanel2" name="traderListPanel22">
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -52,25 +52,20 @@ public class TraderListDialog extends javax.swing.JDialog {
|
|||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
traderListPanel1 = new gui.TraderListPanel();
|
traderListPanel22 = new gui.TraderListPanel2();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
setTitle("Trader List");
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addComponent(traderListPanel22, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 574, Short.MAX_VALUE)
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(traderListPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addContainerGap())
|
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(traderListPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE)
|
|
||||||
.addContainerGap())
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
@ -120,6 +115,6 @@ public class TraderListDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private gui.TraderListPanel traderListPanel1;
|
private gui.TraderListPanel2 traderListPanel22;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
</Table>
|
</Table>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="traderListMouseClicked"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -36,7 +36,7 @@ import javax.swing.ListModel;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.JTableHeader;
|
import javax.swing.table.JTableHeader;
|
||||||
import sesim.AutoTrader;
|
|
||||||
import sesim.AutoTraderInterface;
|
import sesim.AutoTraderInterface;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
import sesim.Scheduler;
|
import sesim.Scheduler;
|
||||||
@ -247,6 +247,11 @@ public class TraderListPanel extends javax.swing.JPanel {
|
|||||||
"Title 1", "Title 2", "Title 3", "Title 4"
|
"Title 1", "Title 2", "Title 3", "Title 4"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
traderList.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||||
|
traderListMouseClicked(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
traderListScroller.setViewportView(traderList);
|
traderListScroller.setViewportView(traderList);
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
@ -261,6 +266,10 @@ public class TraderListPanel extends javax.swing.JPanel {
|
|||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void traderListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_traderListMouseClicked
|
||||||
|
|
||||||
|
}//GEN-LAST:event_traderListMouseClicked
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JTable traderList;
|
private javax.swing.JTable traderList;
|
||||||
|
56
src/main/java/gui/TraderListPanel2.form
Normal file
56
src/main/java/gui/TraderListPanel2.form
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" 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">
|
||||||
|
<Component id="jScrollPane1" alignment="1" pref="537" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="jScrollPane1" alignment="0" pref="300" max="32767" attributes="0"/>
|
||||||
|
</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="list">
|
||||||
|
<Properties>
|
||||||
|
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
|
||||||
|
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||||
|
<Table columnCount="5" rowCount="5">
|
||||||
|
<Column editable="false" title="ID" type="java.lang.Long"/>
|
||||||
|
<Column editable="false" title="Name" type="java.lang.String"/>
|
||||||
|
<Column editable="false" title="Money" type="java.lang.Double"/>
|
||||||
|
<Column editable="false" title="Shares" type="java.lang.Double"/>
|
||||||
|
<Column editable="false" title="Wealth" type="java.lang.Double"/>
|
||||||
|
</Table>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="listMouseClicked"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
181
src/main/java/gui/TraderListPanel2.java
Normal file
181
src/main/java/gui/TraderListPanel2.java
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
/*
|
||||||
|
* 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 gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import sesim.AutoTraderInterface;
|
||||||
|
import sesim.Exchange;
|
||||||
|
import sesim.Exchange.Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class TraderListPanel2 extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
DefaultTableModel model;
|
||||||
|
|
||||||
|
final void updateModel() {
|
||||||
|
if (Globals.se == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Globals.se.traders == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sesim.Quote q = Globals.se.getLastQuoete();
|
||||||
|
double price = q == null ? 0 : q.price;
|
||||||
|
|
||||||
|
int size = Globals.se.traders.size();
|
||||||
|
model.setRowCount(size);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
AutoTraderInterface at = Globals.se.traders.get(i);
|
||||||
|
Account a = at.getAccount();
|
||||||
|
model.setValueAt(i, i, 0);
|
||||||
|
model.setValueAt(at.getName(), i, 1);
|
||||||
|
model.setValueAt(a.getMoney(), i, 2);
|
||||||
|
model.setValueAt(a.getShares(), i, 3);
|
||||||
|
|
||||||
|
double wealth = a.getShares() * price + a.getMoney();
|
||||||
|
model.setValueAt(wealth, i, 4);
|
||||||
|
}
|
||||||
|
list.getRowSorter().allRowsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
TimerTask updater;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form TraderListPanel2
|
||||||
|
*/
|
||||||
|
public TraderListPanel2() {
|
||||||
|
initComponents();
|
||||||
|
model = (DefaultTableModel) list.getModel();
|
||||||
|
updateModel();
|
||||||
|
|
||||||
|
Timer timer = new Timer();
|
||||||
|
updater = new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateModel();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
timer.schedule(updater, 0, 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
list = new javax.swing.JTable();
|
||||||
|
|
||||||
|
list.setAutoCreateRowSorter(true);
|
||||||
|
list.setModel(new javax.swing.table.DefaultTableModel(
|
||||||
|
new Object [][] {
|
||||||
|
{null, null, null, null, null},
|
||||||
|
{null, null, null, null, null},
|
||||||
|
{null, null, null, null, null},
|
||||||
|
{null, null, null, null, null},
|
||||||
|
{null, null, null, null, null}
|
||||||
|
},
|
||||||
|
new String [] {
|
||||||
|
"ID", "Name", "Money", "Shares", "Wealth"
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Class[] types = new Class [] {
|
||||||
|
java.lang.Long.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
|
||||||
|
};
|
||||||
|
boolean[] canEdit = new boolean [] {
|
||||||
|
false, false, false, false, false
|
||||||
|
};
|
||||||
|
|
||||||
|
public Class getColumnClass(int columnIndex) {
|
||||||
|
return types [columnIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||||
|
return canEdit [columnIndex];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
list.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||||
|
listMouseClicked(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jScrollPane1.setViewportView(list);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
this.setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void listMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listMouseClicked
|
||||||
|
if (evt.getClickCount() == 2) {
|
||||||
|
int index = list.rowAtPoint(evt.getPoint());
|
||||||
|
|
||||||
|
index = list.getRowSorter().convertRowIndexToModel(index);
|
||||||
|
Integer tid = (Integer)model.getValueAt(index, 0);
|
||||||
|
System.out.printf("Trader ID %d\n", tid);
|
||||||
|
|
||||||
|
JDialog console = Globals.se.traders.get(tid).getGuiConsole();
|
||||||
|
if (console == null)
|
||||||
|
return;
|
||||||
|
console.setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}//GEN-LAST:event_listMouseClicked
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
private javax.swing.JTable list;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -45,7 +45,6 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTask{
|
|||||||
Exchange.Account a = se.getAccount(account_id);
|
Exchange.Account a = se.getAccount(account_id);
|
||||||
|
|
||||||
// a.owner=this;
|
// a.owner=this;
|
||||||
|
|
||||||
this.se = se;
|
this.se = se;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -83,7 +82,6 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTask{
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Exchange getSE() {
|
public Exchange getSE() {
|
||||||
@ -92,8 +90,4 @@ public abstract class AutoTraderBase implements AutoTraderInterface, TimerTask{
|
|||||||
|
|
||||||
public abstract void start();
|
public abstract void start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public abstract interface AutoTraderConfig {
|
public abstract interface AutoTraderConfig {
|
||||||
|
|
||||||
public abstract AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares);
|
public abstract OldAutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares);
|
||||||
|
|
||||||
public abstract String getDisplayName();
|
public abstract String getDisplayName();
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package sesim;
|
package sesim;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +40,8 @@ public interface AutoTraderInterface {
|
|||||||
|
|
||||||
public abstract AutoTraderGui getGui();
|
public abstract AutoTraderGui getGui();
|
||||||
|
|
||||||
|
public abstract JDialog getGuiConsole();
|
||||||
|
|
||||||
public abstract JSONObject getConfig();
|
public abstract JSONObject getConfig();
|
||||||
|
|
||||||
public abstract void putConfig(JSONObject cfg);
|
public abstract void putConfig(JSONObject cfg);
|
||||||
|
@ -35,7 +35,7 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class AutoTraderList {
|
public class AutoTraderList {
|
||||||
|
|
||||||
SortedSet <AutoTrader> traders;
|
SortedSet <OldAutoTrader> traders;
|
||||||
|
|
||||||
AutoTraderList(){
|
AutoTraderList(){
|
||||||
|
|
||||||
|
@ -60,11 +60,21 @@ public class Exchange {
|
|||||||
|
|
||||||
public ArrayList<AutoTraderInterface> traders;
|
public ArrayList<AutoTraderInterface> traders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface AccountListener {
|
||||||
|
|
||||||
|
public void accountUpdated(Account a, Order o);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a trading account
|
* Implements a trading account
|
||||||
*/
|
*/
|
||||||
public class Account implements Comparable {
|
public class Account implements Comparable {
|
||||||
|
|
||||||
|
private AccountListener listener = null;
|
||||||
|
|
||||||
private final double id;
|
private final double id;
|
||||||
private double shares;
|
private double shares;
|
||||||
private double money;
|
private double money;
|
||||||
@ -105,6 +115,17 @@ public class Exchange {
|
|||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setListener(AccountListener al) {
|
||||||
|
this.listener = al;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Order o) {
|
||||||
|
if (listener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listener.accountUpdated(this, o);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTraders(JSONArray traderdefs) {
|
public void createTraders(JSONArray traderdefs) {
|
||||||
@ -128,6 +149,13 @@ public class Exchange {
|
|||||||
return a.id;
|
return a.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum OrderStatus {
|
||||||
|
OPEN,
|
||||||
|
PARTIALLY_EXECUTED,
|
||||||
|
CLOSED,
|
||||||
|
CANCELED
|
||||||
|
}
|
||||||
|
|
||||||
class OrderComparator implements Comparator<Order> {
|
class OrderComparator implements Comparator<Order> {
|
||||||
|
|
||||||
OrderType type;
|
OrderType type;
|
||||||
@ -182,6 +210,7 @@ public class Exchange {
|
|||||||
|
|
||||||
public class Order {
|
public class Order {
|
||||||
|
|
||||||
|
OrderStatus status;
|
||||||
OrderType type;
|
OrderType type;
|
||||||
private double limit;
|
private double limit;
|
||||||
private double volume;
|
private double volume;
|
||||||
@ -198,6 +227,7 @@ public class Exchange {
|
|||||||
this.volume = roundShares(volume);
|
this.volume = roundShares(volume);
|
||||||
this.initial_volume = this.volume;
|
this.initial_volume = this.volume;
|
||||||
this.created = timer.currentTimeMillis();
|
this.created = timer.currentTimeMillis();
|
||||||
|
this.status=OrderStatus.OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getID() {
|
public long getID() {
|
||||||
@ -228,6 +258,11 @@ public class Exchange {
|
|||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OrderStatus getOrderStatus(){
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,8 +357,25 @@ public class Exchange {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final String CFG_MONEY_DECIMALS = "money_decimals";
|
||||||
|
public final String CFG_SHARES_DECIMALS = "shares_decimals";
|
||||||
|
|
||||||
|
public void putConfig(JSONObject cfg) {
|
||||||
|
this.setMoneyDecimals(cfg.getInt(CFG_MONEY_DECIMALS));
|
||||||
|
this.setSharesDecimals(cfg.getInt(CFG_SHARES_DECIMALS));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Quote getCurrentPrice() {
|
public Quote getCurrentPrice() {
|
||||||
|
|
||||||
|
/* if (!this.quoteHistory.isEmpty()){
|
||||||
|
Quote q = this.quoteHistory.pollLast();
|
||||||
|
System.out.printf("Quote: %f\n", q.price);
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
*/
|
||||||
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
|
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
|
||||||
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
||||||
|
|
||||||
@ -420,7 +472,6 @@ public class Exchange {
|
|||||||
// long time = 0;
|
// long time = 0;
|
||||||
//double theprice = 12.9;
|
//double theprice = 12.9;
|
||||||
// long orderid = 1;
|
// long orderid = 1;
|
||||||
|
|
||||||
double lastprice = 100.0;
|
double lastprice = 100.0;
|
||||||
long lastsvolume;
|
long lastsvolume;
|
||||||
|
|
||||||
@ -451,7 +502,10 @@ public class Exchange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Quote getLastQuoete() {
|
public Quote getLastQuoete() {
|
||||||
return this.quoteHistory.last();
|
if (this.quoteHistory.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.quoteHistory.pollLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transferMoneyAndShares(Account src, Account dst, double money, double shares) {
|
private void transferMoneyAndShares(Account src, Account dst, double money, double shares) {
|
||||||
@ -459,6 +513,7 @@ public class Exchange {
|
|||||||
dst.money += money;
|
dst.money += money;
|
||||||
src.shares -= shares;
|
src.shares -= shares;
|
||||||
dst.shares += shares;
|
dst.shares += shares;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cancelOrder(double account_id, long order_id) {
|
public boolean cancelOrder(double account_id, long order_id) {
|
||||||
@ -516,6 +571,8 @@ public class Exchange {
|
|||||||
|
|
||||||
private void removeOrderIfExecuted(Order o) {
|
private void removeOrderIfExecuted(Order o) {
|
||||||
if (o.volume != 0) {
|
if (o.volume != 0) {
|
||||||
|
o.status=OrderStatus.PARTIALLY_EXECUTED;
|
||||||
|
o.account.update(o);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,14 +582,18 @@ public class Exchange {
|
|||||||
|
|
||||||
book.remove(book.first());
|
book.remove(book.first());
|
||||||
|
|
||||||
|
o.status=OrderStatus.CLOSED;
|
||||||
|
o.account.update(o);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkSLOrders(double price) {
|
void checkSLOrders(double price) {
|
||||||
SortedSet<Order> sl = order_books.get(OrderType.STOPLOSS);
|
SortedSet<Order> sl = order_books.get(OrderType.STOPLOSS);
|
||||||
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
|
||||||
|
|
||||||
if (sl.isEmpty())
|
if (sl.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Order s = sl.first();
|
Order s = sl.first();
|
||||||
if (price <= s.limit) {
|
if (price <= s.limit) {
|
||||||
@ -556,16 +617,11 @@ public class Exchange {
|
|||||||
SortedSet<Order> ul_buy = order_books.get(OrderType.BUY);
|
SortedSet<Order> ul_buy = order_books.get(OrderType.BUY);
|
||||||
SortedSet<Order> ul_sell = order_books.get(OrderType.SELL);
|
SortedSet<Order> ul_sell = order_books.get(OrderType.SELL);
|
||||||
|
|
||||||
|
|
||||||
double volume_total = 0;
|
double volume_total = 0;
|
||||||
double money_total = 0;
|
double money_total = 0;
|
||||||
|
|
||||||
while (!bid.isEmpty() && !ask.isEmpty()) {
|
while (!bid.isEmpty() && !ask.isEmpty()) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Order b = bid.first();
|
Order b = bid.first();
|
||||||
Order a = ask.first();
|
Order a = ask.first();
|
||||||
|
|
||||||
@ -581,17 +637,19 @@ public class Exchange {
|
|||||||
//System.out.printf("Price %f Vol %f\n", price,volume);
|
//System.out.printf("Price %f Vol %f\n", price,volume);
|
||||||
// Transfer money and shares
|
// Transfer money and shares
|
||||||
transferMoneyAndShares(b.account, a.account, volume * price, -volume);
|
transferMoneyAndShares(b.account, a.account, volume * price, -volume);
|
||||||
//System.out.print("Transfer Shares was called with volume "+volume+"\n");
|
|
||||||
|
|
||||||
// Update volume
|
// Update volume
|
||||||
b.volume -= volume;
|
b.volume -= volume;
|
||||||
a.volume -= volume;
|
a.volume -= volume;
|
||||||
|
|
||||||
|
// a.account.update(a);
|
||||||
|
// b.account.update(b);
|
||||||
|
|
||||||
//System.out.printf("In %f (%f) < %f (%f)\n",b.limit,b.volume,a.limit,a.volume);
|
//System.out.printf("In %f (%f) < %f (%f)\n",b.limit,b.volume,a.limit,a.volume);
|
||||||
volume_total += volume;
|
volume_total += volume;
|
||||||
money_total += price * volume;
|
money_total += price * volume;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
num_trades++;
|
num_trades++;
|
||||||
|
|
||||||
removeOrderIfExecuted(a);
|
removeOrderIfExecuted(a);
|
||||||
@ -646,6 +704,7 @@ public class Exchange {
|
|||||||
|
|
||||||
addOrderToBook(o);
|
addOrderToBook(o);
|
||||||
a.orders.put(o.id, o);
|
a.orders.put(o.id, o);
|
||||||
|
a.update(o);
|
||||||
|
|
||||||
this.executeOrders();
|
this.executeOrders();
|
||||||
|
|
||||||
@ -714,7 +773,6 @@ public class Exchange {
|
|||||||
return ad;
|
return ad;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ArrayList<OrderData> getOpenOrders(double account_id) {
|
public ArrayList<OrderData> getOpenOrders(double account_id) {
|
||||||
|
|
||||||
Account a = accounts.get(account_id);
|
Account a = accounts.get(account_id);
|
||||||
|
@ -32,7 +32,7 @@ import sesim.Exchange.Account;
|
|||||||
*
|
*
|
||||||
* @author 7u83
|
* @author 7u83
|
||||||
*/
|
*/
|
||||||
public abstract class AutoTrader implements Scheduler.TimerTask {
|
public abstract class OldAutoTrader implements Scheduler.TimerTask {
|
||||||
|
|
||||||
protected double account_id;
|
protected double account_id;
|
||||||
protected Exchange se;
|
protected Exchange se;
|
||||||
@ -40,7 +40,7 @@ public abstract class AutoTrader implements Scheduler.TimerTask {
|
|||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
public AutoTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
|
public OldAutoTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
|
||||||
account_id = se.createAccount(money, shares);
|
account_id = se.createAccount(money, shares);
|
||||||
Account a = se.getAccount(account_id);
|
Account a = se.getAccount(account_id);
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public abstract class AutoTrader implements Scheduler.TimerTask {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoTrader(){
|
public OldAutoTrader(){
|
||||||
se=null;
|
se=null;
|
||||||
id=0;
|
id=0;
|
||||||
}
|
}
|
@ -109,18 +109,14 @@ public class Scheduler extends Thread {
|
|||||||
public long currentTimeMillis1() {
|
public long currentTimeMillis1() {
|
||||||
|
|
||||||
long diff = System.currentTimeMillis() - last_time_millis;
|
long diff = System.currentTimeMillis() - last_time_millis;
|
||||||
|
|
||||||
// diff = 12199999L;
|
|
||||||
last_time_millis += diff;
|
last_time_millis += diff;
|
||||||
|
if (diff==0)
|
||||||
|
diff++;
|
||||||
if (pause) {
|
if (pause) {
|
||||||
return (long) this.current_time_millis;
|
return (long) this.current_time_millis;
|
||||||
}
|
}
|
||||||
|
this.current_time_millis += ((double)diff) * this.acceleration;
|
||||||
this.current_time_millis += diff * this.acceleration;
|
|
||||||
//System.out.printf("Current TM: %f\n", this.current_time_millis);
|
|
||||||
return (long) this.current_time_millis;
|
return (long) this.current_time_millis;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long currentTimeMillis() {
|
public long currentTimeMillis() {
|
||||||
@ -214,8 +210,10 @@ public class Scheduler extends Thread {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
//return 0;
|
||||||
//return (t - currentTimeMillis())/(long)this.acceleration;
|
long n =(t - currentTimeMillis())/(long)this.acceleration;
|
||||||
|
System.out.printf("Return wait %d\n",n);
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,19 +27,21 @@ package traders.ManTrader;
|
|||||||
|
|
||||||
import gui.Globals;
|
import gui.Globals;
|
||||||
import gui.OrdersList;
|
import gui.OrdersList;
|
||||||
|
import javax.swing.JDialog;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import sesim.AutoTrader;
|
|
||||||
import sesim.AutoTraderBase;
|
import sesim.AutoTraderBase;
|
||||||
import sesim.AutoTraderConfigBase;
|
import sesim.AutoTraderConfigBase;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.AutoTraderGui;
|
import sesim.AutoTraderGui;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
|
import sesim.Exchange.AccountListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public class ManTrader extends AutoTraderBase {
|
public class ManTrader extends AutoTraderBase implements AccountListener{
|
||||||
|
|
||||||
public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
|
public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
|
||||||
// super(se, id, name, money, shares, null);
|
// super(se, id, name, money, shares, null);
|
||||||
@ -47,9 +49,14 @@ public class ManTrader extends AutoTraderBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ManTrader() {
|
public ManTrader() {
|
||||||
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void init(Exchange se, long id, String name, double money, double shares, JSONObject cfg){
|
||||||
|
super.init(se, id, name, money, shares, cfg);
|
||||||
|
getAccount().setListener(this);
|
||||||
|
}
|
||||||
ManTraderConsoleDialog consoleDialog;
|
ManTraderConsoleDialog consoleDialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,11 +81,7 @@ public class ManTrader extends AutoTraderBase {
|
|||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
|
||||||
public AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
@ -106,4 +109,17 @@ public class ManTrader extends AutoTraderBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JDialog getGuiConsole() {
|
||||||
|
return this.consoleDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accountUpdated(Exchange.Account a, Exchange.Order o) {
|
||||||
|
//this.consoleDialog.cons
|
||||||
|
System.out.printf("AccountListener called\n");
|
||||||
|
|
||||||
|
this.consoleDialog.getConsole().getOrderListPanel().updateModel();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package traders.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 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.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -19,7 +19,7 @@
|
|||||||
<Group type="102" alignment="1" attributes="0">
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="1" attributes="0">
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
<Component id="ordersList1" max="32767" attributes="0"/>
|
<Component id="ordersList" max="32767" attributes="0"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Group type="103" groupAlignment="1" attributes="0">
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
@ -56,7 +56,7 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="ordersList1" min="-2" pref="148" max="-2" attributes="0"/>
|
<Component id="ordersList" min="-2" pref="148" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
@ -141,7 +141,7 @@
|
|||||||
<Property name="text" type="java.lang.String" value="jLabel4"/>
|
<Property name="text" type="java.lang.String" value="jLabel4"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="gui.OrdersList" name="ordersList1">
|
<Component class="gui.OrdersList" name="ordersList">
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="stopLossButton">
|
<Component class="javax.swing.JButton" name="stopLossButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
@ -26,9 +26,7 @@
|
|||||||
package traders.ManTrader;
|
package traders.ManTrader;
|
||||||
|
|
||||||
import gui.OrdersList;
|
import gui.OrdersList;
|
||||||
import javax.swing.JTable;
|
|
||||||
import sesim.AutoTrader;
|
|
||||||
import sesim.AutoTraderInterface;
|
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +38,8 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
public ManTrader trader;
|
public ManTrader trader;
|
||||||
|
|
||||||
public OrdersList getOrderListPanel(){
|
public OrdersList getOrderListPanel(){
|
||||||
return this.ordersList1;
|
|
||||||
|
return this.ordersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +47,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
*/
|
*/
|
||||||
public ManTraderConsole() {
|
public ManTraderConsole() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
// this.ordersList1.account=trader.getAccount();
|
// this.ordersList1.account=trader.getAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
sellButton = new javax.swing.JButton();
|
sellButton = new javax.swing.JButton();
|
||||||
jLabel3 = new javax.swing.JLabel();
|
jLabel3 = new javax.swing.JLabel();
|
||||||
moneyText = new javax.swing.JLabel();
|
moneyText = new javax.swing.JLabel();
|
||||||
ordersList1 = new gui.OrdersList();
|
ordersList = new gui.OrdersList();
|
||||||
stopLossButton = new javax.swing.JButton();
|
stopLossButton = new javax.swing.JButton();
|
||||||
|
|
||||||
limitSpinner.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, null, 1.0d));
|
limitSpinner.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, null, 1.0d));
|
||||||
@ -111,7 +111,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(ordersList1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(ordersList, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||||
@ -139,7 +139,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(ordersList1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(ordersList, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jLabel3)
|
.addComponent(jLabel3)
|
||||||
@ -174,6 +174,9 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.BUYLIMIT, volume, limit);
|
long createOrder = trader.getSE().createOrder(trader.getAccount().getID(), Exchange.OrderType.BUYLIMIT, volume, limit);
|
||||||
System.out.printf("The retval is %d",createOrder);
|
System.out.printf("The retval is %d",createOrder);
|
||||||
|
|
||||||
|
this.ordersList.account=this.trader.getAccount();
|
||||||
|
this.ordersList.updateModel();
|
||||||
|
|
||||||
|
|
||||||
}//GEN-LAST:event_buyButtonActionPerformed
|
}//GEN-LAST:event_buyButtonActionPerformed
|
||||||
|
|
||||||
@ -205,7 +208,7 @@ public class ManTraderConsole extends javax.swing.JPanel {
|
|||||||
private javax.swing.JLabel jLabel3;
|
private javax.swing.JLabel jLabel3;
|
||||||
private javax.swing.JSpinner limitSpinner;
|
private javax.swing.JSpinner limitSpinner;
|
||||||
private javax.swing.JLabel moneyText;
|
private javax.swing.JLabel moneyText;
|
||||||
private gui.OrdersList ordersList1;
|
private gui.OrdersList ordersList;
|
||||||
private javax.swing.JButton sellButton;
|
private javax.swing.JButton sellButton;
|
||||||
private javax.swing.JButton stopLossButton;
|
private javax.swing.JButton stopLossButton;
|
||||||
private javax.swing.JSpinner volumeSpinner;
|
private javax.swing.JSpinner volumeSpinner;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="console" pref="280" max="32767" attributes="0"/>
|
<Component id="console" pref="328" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -67,14 +67,14 @@ public class ManTraderConsoleDialog extends javax.swing.JDialog {
|
|||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(console, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
|
.addComponent(console, javax.swing.GroupLayout.PREFERRED_SIZE, 383, Short.MAX_VALUE)
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(console, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
|
.addComponent(console, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -31,10 +31,11 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
import javax.swing.JDialog;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
//import sesim.AccountData;
|
//import sesim.AccountData;
|
||||||
import sesim.AutoTrader;
|
|
||||||
import sesim.AutoTraderBase;
|
import sesim.AutoTraderBase;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.AutoTraderGui;
|
import sesim.AutoTraderGui;
|
||||||
@ -178,6 +179,11 @@ public class RandomTraderA extends AutoTraderBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JDialog getGuiConsole() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected enum Action {
|
protected enum Action {
|
||||||
BUY, SELL, RANDOM
|
BUY, SELL, RANDOM
|
||||||
}
|
}
|
||||||
@ -276,16 +282,19 @@ public class RandomTraderA extends AutoTraderBase {
|
|||||||
|
|
||||||
// how much money we ant to invest?
|
// how much money we ant to invest?
|
||||||
double money = getRandomAmmount(ad.getMoney(), buy_volume);
|
double money = getRandomAmmount(ad.getMoney(), buy_volume);
|
||||||
money = se.roundMoney(money);
|
|
||||||
|
|
||||||
Quote q = se.getCurrentPrice();
|
Quote q = se.getCurrentPrice();
|
||||||
double lp = q == null ? getStart() : q.price;
|
double lp = q == null ? getStart() : q.price;
|
||||||
|
|
||||||
double limit;
|
double limit;
|
||||||
limit = lp + getRandomAmmount(lp, buy_limit);
|
limit = lp + getRandomAmmount(lp, buy_limit);
|
||||||
limit = se.roundMoney(limit);
|
|
||||||
|
|
||||||
double volume = money / limit;
|
double volume = money / limit;
|
||||||
|
|
||||||
|
// System.out.printf("Volume : %f", volume);
|
||||||
|
|
||||||
|
limit = se.roundMoney(limit);
|
||||||
volume = se.roundShares(volume);
|
volume = se.roundShares(volume);
|
||||||
|
|
||||||
if (volume <= 0 || money <= 0) {
|
if (volume <= 0 || money <= 0) {
|
||||||
|
@ -25,16 +25,15 @@
|
|||||||
*/
|
*/
|
||||||
package traders;
|
package traders;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
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.AutoTraderConfigBase;
|
import sesim.AutoTraderConfigBase;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.AutoTraderGui;
|
import sesim.AutoTraderGui;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
|
import sesim.OldAutoTrader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -53,7 +52,7 @@ public class RandomTraderConfig extends AutoTraderConfigBase implements AutoTrad
|
|||||||
public Long[] wait_after_buy = {10L, 30L};
|
public Long[] wait_after_buy = {10L, 30L};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
|
public OldAutoTrader createTrader(Exchange se, JSONObject cfg, long id, String name, double money, double shares) {
|
||||||
if (cfg != null) {
|
if (cfg != null) {
|
||||||
this.putConfig(cfg);
|
this.putConfig(cfg);
|
||||||
}
|
}
|
||||||
|
@ -296,28 +296,28 @@
|
|||||||
<Component class="javax.swing.JSpinner" name="waitAfterBuyMin">
|
<Component class="javax.swing.JSpinner" name="waitAfterBuyMin">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
|
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JSpinner" name="waitAfterSellMin">
|
<Component class="javax.swing.JSpinner" name="waitAfterSellMin">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
|
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JSpinner" name="waitAfterSellMax">
|
<Component class="javax.swing.JSpinner" name="waitAfterSellMax">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
|
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JSpinner" name="waitAfterBuyMax">
|
<Component class="javax.swing.JSpinner" name="waitAfterBuyMax">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||||
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
|
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Long" stepSize="1000" type="number"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
@ -46,6 +46,7 @@ public class RandomTraderGuiA extends AutoTraderGui {
|
|||||||
|
|
||||||
JDialog d;
|
JDialog d;
|
||||||
|
|
||||||
|
try {
|
||||||
this.initialDelayMin.setValue(cfg.initial_delay[0]);
|
this.initialDelayMin.setValue(cfg.initial_delay[0]);
|
||||||
this.initialDelayMax.setValue(cfg.initial_delay[1]);
|
this.initialDelayMax.setValue(cfg.initial_delay[1]);
|
||||||
|
|
||||||
@ -68,8 +69,10 @@ public class RandomTraderGuiA extends AutoTraderGui {
|
|||||||
|
|
||||||
this.waitAfterSellMin.setValue(cfg.wait_after_sell[0]);
|
this.waitAfterSellMin.setValue(cfg.wait_after_sell[0]);
|
||||||
this.waitAfterSellMax.setValue(cfg.wait_after_sell[1]);
|
this.waitAfterSellMax.setValue(cfg.wait_after_sell[1]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
@ -179,13 +182,13 @@ public class RandomTraderGuiA extends AutoTraderGui {
|
|||||||
|
|
||||||
sellLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
|
sellLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
|
||||||
|
|
||||||
waitAfterBuyMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
|
waitAfterBuyMin.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
|
||||||
|
|
||||||
waitAfterSellMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
|
waitAfterSellMin.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
|
||||||
|
|
||||||
waitAfterSellMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
|
waitAfterSellMax.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
|
||||||
|
|
||||||
waitAfterBuyMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
|
waitAfterBuyMax.setModel(new javax.swing.SpinnerNumberModel(0L, 0L, null, 1000L));
|
||||||
|
|
||||||
buyVolMin.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
|
buyVolMin.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user