More work on Strategy editor
This commit is contained in:
parent
bd10e72756
commit
c6c5ed2931
5
pom.xml
5
pom.xml
@ -23,6 +23,11 @@
|
|||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20160810</version>
|
<version>20160810</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>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
@ -16,31 +16,13 @@
|
|||||||
<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="0" attributes="0">
|
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="115" max="-2" attributes="0"/>
|
|
||||||
<Component id="jFormattedTextField1" min="-2" pref="94" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace pref="197" max="32767" 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="0" attributes="0">
|
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
|
|
||||||
<Component id="jFormattedTextField1" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace pref="249" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
|
||||||
<Component class="javax.swing.JFormattedTextField" name="jFormattedTextField1">
|
|
||||||
<Properties>
|
|
||||||
<Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor">
|
|
||||||
<Format format="#0.00%" subtype="-1" type="3"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
</SubComponents>
|
|
||||||
</Form>
|
</Form>
|
@ -23,18 +23,18 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package traders;
|
package gui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public class RandomTraderConfigForm extends javax.swing.JPanel {
|
public class Clock extends javax.swing.JPanel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form RandomTraderConfigForm
|
* Creates new form Clock
|
||||||
*/
|
*/
|
||||||
public RandomTraderConfigForm() {
|
public Clock() {
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,31 +47,19 @@ public class RandomTraderConfigForm extends javax.swing.JPanel {
|
|||||||
// <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() {
|
||||||
|
|
||||||
jFormattedTextField1 = new javax.swing.JFormattedTextField();
|
|
||||||
|
|
||||||
jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00%"))));
|
|
||||||
jFormattedTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
|
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGap(0, 400, Short.MAX_VALUE)
|
||||||
.addGap(115, 115, 115)
|
|
||||||
.addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addContainerGap(197, Short.MAX_VALUE))
|
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGap(0, 300, Short.MAX_VALUE)
|
||||||
.addGap(24, 24, 24)
|
|
||||||
.addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addContainerGap(249, Short.MAX_VALUE))
|
|
||||||
);
|
);
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JFormattedTextField jFormattedTextField1;
|
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
@ -39,6 +39,10 @@
|
|||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
@ -52,7 +56,9 @@
|
|||||||
<Component id="lafComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="lafComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="lafLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="lafLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace pref="236" max="32767" attributes="0"/>
|
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||||
|
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="200" max="32767" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
@ -114,5 +120,13 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JCheckBox" name="jCheckBox1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Development Traders"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBox1ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -27,8 +27,12 @@ package gui;
|
|||||||
|
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -38,20 +42,25 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
UIManager.LookAndFeelInfo[] lafInfo;
|
UIManager.LookAndFeelInfo[] lafInfo;
|
||||||
|
|
||||||
|
LookAndFeel old_laf;
|
||||||
|
LookAndFeel new_laf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form EditPreferencesDialog
|
* Creates new form EditPreferencesDialog
|
||||||
*/
|
*/
|
||||||
public EditPreferencesDialog(java.awt.Frame parent, boolean modal) {
|
public EditPreferencesDialog(java.awt.Frame parent, boolean modal) {
|
||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
initComponents();
|
initComponents();
|
||||||
this.setLocationRelativeTo(MainWin.instance);
|
this.setLocationRelativeTo(this.getParent());
|
||||||
|
|
||||||
|
old_laf = UIManager.getLookAndFeel();
|
||||||
|
|
||||||
|
|
||||||
lafInfo = UIManager.getInstalledLookAndFeels();
|
lafInfo = UIManager.getInstalledLookAndFeels();
|
||||||
lafComboBox.removeAllItems();
|
lafComboBox.removeAllItems();
|
||||||
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
||||||
lafComboBox.addItem(lafInfo1.getName());
|
lafComboBox.addItem(lafInfo1.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
|
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +78,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
cancelButton = new javax.swing.JButton();
|
cancelButton = new javax.swing.JButton();
|
||||||
applyButton = new javax.swing.JButton();
|
applyButton = new javax.swing.JButton();
|
||||||
okButton = new javax.swing.JButton();
|
okButton = new javax.swing.JButton();
|
||||||
|
jCheckBox1 = new javax.swing.JCheckBox();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
@ -105,6 +115,13 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jCheckBox1.setText("Development Traders");
|
||||||
|
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jCheckBox1ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
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(
|
||||||
@ -122,7 +139,10 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(applyButton)
|
.addComponent(applyButton)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(cancelButton)))
|
.addComponent(cancelButton))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jCheckBox1)
|
||||||
|
.addGap(0, 0, Short.MAX_VALUE)))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
@ -132,7 +152,9 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(lafLabel))
|
.addComponent(lafLabel))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 236, Short.MAX_VALUE)
|
.addGap(18, 18, 18)
|
||||||
|
.addComponent(jCheckBox1)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 200, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(cancelButton)
|
.addComponent(cancelButton)
|
||||||
.addComponent(applyButton)
|
.addComponent(applyButton)
|
||||||
@ -148,37 +170,34 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
}//GEN-LAST:event_lafComboBoxActionPerformed
|
}//GEN-LAST:event_lafComboBoxActionPerformed
|
||||||
|
|
||||||
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
||||||
|
if (old_laf!=new_laf){
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(old_laf);
|
||||||
|
} catch (UnsupportedLookAndFeelException ex) {
|
||||||
|
Logger.getLogger(EditPreferencesDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
resetUI();
|
||||||
|
}
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
}//GEN-LAST:event_cancelButtonActionPerformed
|
||||||
|
|
||||||
private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
|
void resetUI(){
|
||||||
String selected = (String) this.lafComboBox.getSelectedItem();
|
for (Window w : Window.getWindows()) {
|
||||||
|
|
||||||
System.out.printf("Selected %s\n", selected);
|
|
||||||
|
|
||||||
Globals.setLookAndFeel(selected);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
for (UIManager.LookAndFeelInfo lafInfo1 : this.lafInfo) {
|
|
||||||
if (lafInfo1.getName().equals(selected)) {
|
|
||||||
String lafClassName = lafInfo1.getClassName();
|
|
||||||
try {
|
|
||||||
UIManager.setLookAndFeel(lafClassName);
|
|
||||||
break;
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (Window w : Window.getWindows()) {
|
|
||||||
System.out.print("Setting frame\n");
|
System.out.print("Setting frame\n");
|
||||||
SwingUtilities.updateComponentTreeUI(w);
|
SwingUtilities.updateComponentTreeUI(w);
|
||||||
w.pack();
|
w.pack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
|
||||||
|
|
||||||
|
String selected = (String) this.lafComboBox.getSelectedItem();
|
||||||
|
|
||||||
|
|
||||||
|
Globals.setLookAndFeel(selected);
|
||||||
|
new_laf=UIManager.getLookAndFeel();
|
||||||
|
resetUI();
|
||||||
|
|
||||||
}
|
|
||||||
}//GEN-LAST:event_applyButtonActionPerformed
|
}//GEN-LAST:event_applyButtonActionPerformed
|
||||||
|
|
||||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||||
@ -188,6 +207,10 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
}//GEN-LAST:event_okButtonActionPerformed
|
}//GEN-LAST:event_okButtonActionPerformed
|
||||||
|
|
||||||
|
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
|
||||||
|
// TODO add your handling code here:
|
||||||
|
}//GEN-LAST:event_jCheckBox1ActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
*/
|
*/
|
||||||
@ -233,6 +256,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JButton applyButton;
|
private javax.swing.JButton applyButton;
|
||||||
private javax.swing.JButton cancelButton;
|
private javax.swing.JButton cancelButton;
|
||||||
|
private javax.swing.JCheckBox jCheckBox1;
|
||||||
private javax.swing.JComboBox<String> lafComboBox;
|
private javax.swing.JComboBox<String> lafComboBox;
|
||||||
private javax.swing.JLabel lafLabel;
|
private javax.swing.JLabel lafLabel;
|
||||||
private javax.swing.JButton okButton;
|
private javax.swing.JButton okButton;
|
||||||
|
@ -30,8 +30,12 @@
|
|||||||
<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"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jToggleButton1" alignment="1" min="-2" max="-2" attributes="0"/>
|
<Group type="102" alignment="1" attributes="0">
|
||||||
<Component id="jComboBox1" alignment="1" min="-2" pref="361" max="-2" attributes="0"/>
|
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="jComboBoxStrategySelector" alignment="1" min="-2" pref="361" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
@ -43,18 +47,21 @@
|
|||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jComboBox1" min="-2" max="-2" attributes="0"/>
|
<Component id="jComboBoxStrategySelector" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="guiPanel" max="32767" attributes="0"/>
|
<Component id="guiPanel" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jToggleButton1" min="-2" max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JComboBox" name="jComboBox1">
|
<Component class="javax.swing.JComboBox" name="jComboBoxStrategySelector">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||||
<StringArray count="4">
|
<StringArray count="4">
|
||||||
@ -66,17 +73,12 @@
|
|||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBoxStrategySelectorActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JToggleButton" name="jToggleButton1">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" value="jToggleButton1"/>
|
|
||||||
</Properties>
|
|
||||||
</Component>
|
|
||||||
<Container class="javax.swing.JPanel" name="guiPanel">
|
<Container class="javax.swing.JPanel" name="guiPanel">
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||||
@ -102,8 +104,8 @@
|
|||||||
<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="jLabel1" pref="262" max="32767" attributes="0"/>
|
<Component id="jLabel1" pref="229" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -119,5 +121,18 @@
|
|||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Save"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton2">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
@ -26,26 +26,32 @@
|
|||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
|
import sesim.AutoTraderGui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public class EditTradingStrategies extends javax.swing.JDialog {
|
public class EditStrategies extends javax.swing.JDialog {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form EditTradingStrategies
|
* Creates new form EditTradingStrategies
|
||||||
*/
|
*/
|
||||||
public EditTradingStrategies(java.awt.Frame parent, boolean modal) {
|
public EditStrategies(java.awt.Frame parent, boolean modal) {
|
||||||
super(parent, modal);
|
super(parent, modal);
|
||||||
initComponents();
|
initComponents();
|
||||||
|
this.setLocationRelativeTo(this.getParent());
|
||||||
|
|
||||||
this.jComboBox1.removeAllItems();
|
this.jComboBoxStrategySelector.removeAllItems();
|
||||||
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
||||||
for (int i = 0; i < sn.size(); i++) {
|
for (int i = 0; i < sn.size(); i++) {
|
||||||
this.jComboBox1.addItem(sn.get(i));
|
this.jComboBoxStrategySelector.addItem(sn.get(i));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +62,23 @@ public class EditTradingStrategies extends javax.swing.JDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JSONArray loadStrategyConfigs(){
|
||||||
|
|
||||||
|
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
||||||
|
|
||||||
|
|
||||||
|
String cfglist = Globals.prefs.get("StrategyCFG", "[]");
|
||||||
|
JSONArray cfgs = new JSONArray(cfglist);
|
||||||
|
|
||||||
|
Logger.getGlobal().info(cfglist);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return cfgs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called from within the constructor to initialize the form.
|
* 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
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
@ -65,23 +88,22 @@ public class EditTradingStrategies 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() {
|
||||||
|
|
||||||
jComboBox1 = new javax.swing.JComboBox<>();
|
jComboBoxStrategySelector = new javax.swing.JComboBox<>();
|
||||||
jToggleButton1 = new javax.swing.JToggleButton();
|
|
||||||
guiPanel = new javax.swing.JPanel();
|
guiPanel = new javax.swing.JPanel();
|
||||||
defaultGuiPanel = new javax.swing.JPanel();
|
defaultGuiPanel = new javax.swing.JPanel();
|
||||||
jLabel1 = new javax.swing.JLabel();
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
jButton1 = new javax.swing.JButton();
|
||||||
|
jButton2 = new javax.swing.JButton();
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
jComboBoxStrategySelector.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||||
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
|
jComboBoxStrategySelector.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
jComboBox1ActionPerformed(evt);
|
jComboBoxStrategySelectorActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jToggleButton1.setText("jToggleButton1");
|
|
||||||
|
|
||||||
guiPanel.setLayout(new java.awt.BorderLayout());
|
guiPanel.setLayout(new java.awt.BorderLayout());
|
||||||
|
|
||||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||||
@ -100,12 +122,21 @@ public class EditTradingStrategies extends javax.swing.JDialog {
|
|||||||
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
|
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
|
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
|
||||||
.addContainerGap())
|
.addGap(39, 39, 39))
|
||||||
);
|
);
|
||||||
|
|
||||||
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
||||||
|
|
||||||
|
jButton1.setText("Save");
|
||||||
|
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton1ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jButton2.setText("Cancel");
|
||||||
|
|
||||||
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(
|
||||||
@ -117,48 +148,71 @@ public class EditTradingStrategies extends javax.swing.JDialog {
|
|||||||
.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)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jToggleButton1, javax.swing.GroupLayout.Alignment.TRAILING)
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
.addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
.addComponent(jButton1)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton2))
|
||||||
|
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||||
.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(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jComboBoxStrategySelector, 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)
|
||||||
.addComponent(guiPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(guiPanel, 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)
|
||||||
.addComponent(jToggleButton1)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(jButton1)
|
||||||
|
.addComponent(jButton2))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
|
|
||||||
System.out.printf("Now Strategie Dialog to open\n");
|
AutoTraderGui acgui;
|
||||||
AutoTraderConfig ac = Globals.tloader.getStrategy((String) this.jComboBox1.getSelectedItem());
|
AutoTraderConfig ac;
|
||||||
|
|
||||||
|
private void jComboBoxStrategySelectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStrategySelectorActionPerformed
|
||||||
|
// System.out.printf("Now Strategie Dialog to open\n");
|
||||||
|
ac = Globals.tloader.getStrategy((String) this.jComboBoxStrategySelector.getSelectedItem());
|
||||||
if (ac == null) {
|
if (ac == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JPanel gui = ac.getGui();
|
acgui = ac.getGui();
|
||||||
guiPanel.removeAll();
|
guiPanel.removeAll();
|
||||||
if (gui != null) {
|
if (acgui != null) {
|
||||||
// javax.swing.GroupLayout guil = (javax.swing.GroupLayout) this.guiPanel.getLayout();
|
// javax.swing.GroupLayout guil = (javax.swing.GroupLayout) this.guiPanel.getLayout();
|
||||||
|
|
||||||
guiPanel.add(gui, java.awt.BorderLayout.CENTER);
|
guiPanel.add(acgui, java.awt.BorderLayout.CENTER);
|
||||||
|
|
||||||
// this.guiPanel;
|
// this.guiPanel;
|
||||||
gui.setVisible(true);
|
acgui.setVisible(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
guiPanel.add(this.defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
guiPanel.add(this.defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
System.out.printf("Setted the dings\n", "");
|
System.out.printf("Setted the dings\n", "");
|
||||||
|
JSONObject jo = ac.getConfig();
|
||||||
|
if (jo != null) {
|
||||||
|
System.out.printf("%s\n", jo.toString(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AutoTrader at = ac.createTrader(Globals.se, jo, 100, 100);
|
||||||
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}//GEN-LAST:event_jComboBox1ActionPerformed
|
}//GEN-LAST:event_jComboBoxStrategySelectorActionPerformed
|
||||||
|
|
||||||
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||||
|
acgui.save();
|
||||||
|
|
||||||
|
|
||||||
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
@ -177,20 +231,21 @@ public class EditTradingStrategies extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
} catch (InstantiationException ex) {
|
} catch (InstantiationException ex) {
|
||||||
java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||||
java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
/* Create and display the dialog */
|
/* Create and display the dialog */
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
EditTradingStrategies dialog = new EditTradingStrategies(new javax.swing.JFrame(), true);
|
EditStrategies dialog = new EditStrategies(new javax.swing.JFrame(), true);
|
||||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||||
@ -205,8 +260,9 @@ public class EditTradingStrategies extends javax.swing.JDialog {
|
|||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JPanel defaultGuiPanel;
|
private javax.swing.JPanel defaultGuiPanel;
|
||||||
private javax.swing.JPanel guiPanel;
|
private javax.swing.JPanel guiPanel;
|
||||||
private javax.swing.JComboBox<String> jComboBox1;
|
private javax.swing.JButton jButton1;
|
||||||
|
private javax.swing.JButton jButton2;
|
||||||
|
private javax.swing.JComboBox<String> jComboBoxStrategySelector;
|
||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JLabel jLabel1;
|
||||||
private javax.swing.JToggleButton jToggleButton1;
|
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
@ -26,6 +26,7 @@
|
|||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
import chart.NewMDIApplication;
|
import chart.NewMDIApplication;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import sesim.AutoTraderLoader;
|
import sesim.AutoTraderLoader;
|
||||||
@ -66,6 +67,7 @@ public class Globals {
|
|||||||
|
|
||||||
static AutoTraderLoader tloader=new AutoTraderLoader();
|
static AutoTraderLoader tloader=new AutoTraderLoader();
|
||||||
|
|
||||||
|
static final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
53
src/main/java/gui/LoggerDialog.form
Normal file
53
src/main/java/gui/LoggerDialog.form
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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">
|
||||||
|
<Component id="jScrollPane1" alignment="1" pref="400" 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.JTextArea" name="logArea">
|
||||||
|
<Properties>
|
||||||
|
<Property name="editable" type="boolean" value="false"/>
|
||||||
|
<Property name="columns" type="int" value="20"/>
|
||||||
|
<Property name="rows" type="int" value="5"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
156
src/main/java/gui/LoggerDialog.java
Normal file
156
src/main/java/gui/LoggerDialog.java
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* 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.logging.Handler;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class LoggerDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form LoggerDialog
|
||||||
|
*/
|
||||||
|
public LoggerDialog(java.awt.Frame parent, boolean modal) {
|
||||||
|
super(parent, modal);
|
||||||
|
initComponents();
|
||||||
|
|
||||||
|
this.setTitle("Logger Window");
|
||||||
|
|
||||||
|
class LogHandler extends Handler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(LogRecord record) {
|
||||||
|
String str = record.getMessage();
|
||||||
|
logArea.append(str);
|
||||||
|
logArea.append("\n");
|
||||||
|
|
||||||
|
// System.out.printf("SRTR WAS: %s",str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws SecurityException {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
LogHandler handler = new LogHandler();
|
||||||
|
Globals.LOGGER.addHandler(handler);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
logArea = new javax.swing.JTextArea();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
logArea.setEditable(false);
|
||||||
|
logArea.setColumns(20);
|
||||||
|
logArea.setRows(5);
|
||||||
|
jScrollPane1.setViewportView(logArea);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
|
||||||
|
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(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (InstantiationException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
/* Create and display the dialog */
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
LoggerDialog dialog = new LoggerDialog(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 javax.swing.JScrollPane jScrollPane1;
|
||||||
|
private javax.swing.JTextArea logArea;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -246,7 +246,7 @@ public class MainWin extends javax.swing.JFrame {
|
|||||||
// rcfg1.sell_limit[0]=-1;
|
// rcfg1.sell_limit[0]=-1;
|
||||||
// rcfg1.sell_limit[1]=1;
|
// rcfg1.sell_limit[1]=1;
|
||||||
|
|
||||||
AutoTrader rt1 = rcfg1.createTrader(Globals.se, 1000000, 1000000);
|
AutoTrader rt1 = rcfg1.createTrader(Globals.se, null, 1000000, 1000000);
|
||||||
Globals.se.traders.add(rt1);
|
Globals.se.traders.add(rt1);
|
||||||
rt1.setName("Alice");
|
rt1.setName("Alice");
|
||||||
rt1.start();
|
rt1.start();
|
||||||
@ -260,7 +260,7 @@ public class MainWin extends javax.swing.JFrame {
|
|||||||
RandomTraderConfig cfg= new RandomTraderConfig();
|
RandomTraderConfig cfg= new RandomTraderConfig();
|
||||||
|
|
||||||
for (int i=0; i<30; i++){
|
for (int i=0; i<30; i++){
|
||||||
AutoTrader randt = cfg.createTrader(Globals.se, 100000, 100000);
|
AutoTrader randt = cfg.createTrader(Globals.se,null, 100000, 100000);
|
||||||
|
|
||||||
Globals.se.traders.add(randt);
|
Globals.se.traders.add(randt);
|
||||||
randt.setName("Bob");
|
randt.setName("Bob");
|
||||||
|
@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||||
<NonVisualComponents>
|
<NonVisualComponents>
|
||||||
|
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||||
|
<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.JTextArea" name="jTextArea1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="columns" type="int" value="20"/>
|
||||||
|
<Property name="rows" type="int" value="5"/>
|
||||||
|
<Property name="text" type="java.lang.String" value="Hakke"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
<Menu class="javax.swing.JMenuBar" name="menuBar">
|
<Menu class="javax.swing.JMenuBar" name="menuBar">
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Menu class="javax.swing.JMenu" name="fileMenu">
|
<Menu class="javax.swing.JMenu" name="fileMenu">
|
||||||
@ -67,6 +83,8 @@
|
|||||||
<Property name="text" type="java.lang.String" value="Copy"/>
|
<Property name="text" type="java.lang.String" value="Copy"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator1">
|
||||||
|
</MenuItem>
|
||||||
<MenuItem class="javax.swing.JMenuItem" name="pasteMenuItem">
|
<MenuItem class="javax.swing.JMenuItem" name="pasteMenuItem">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="mnemonic" type="int" value="115"/>
|
<Property name="mnemonic" type="int" value="115"/>
|
||||||
@ -85,6 +103,8 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteMenuItemActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteMenuItemActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator2">
|
||||||
|
</MenuItem>
|
||||||
<MenuItem class="javax.swing.JMenuItem" name="editPreferences">
|
<MenuItem class="javax.swing.JMenuItem" name="editPreferences">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="mnemonic" type="int" value="112"/>
|
<Property name="mnemonic" type="int" value="112"/>
|
||||||
@ -109,6 +129,14 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="LogWindow"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</MenuItem>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu class="javax.swing.JMenu" name="helpMenu">
|
<Menu class="javax.swing.JMenu" name="helpMenu">
|
||||||
@ -166,13 +194,13 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jToolBar1" max="32767" attributes="0"/>
|
<Component id="jToolBar1" pref="797" max="32767" attributes="0"/>
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="orderBookPanel1" min="-2" max="-2" attributes="0"/>
|
<Component id="orderBookPanel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jScrollPane1" pref="729" max="32767" attributes="0"/>
|
<Component id="jScrollPane1" min="-2" pref="550" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -182,8 +210,8 @@
|
|||||||
<Component id="jToolBar1" min="-2" pref="60" max="-2" attributes="0"/>
|
<Component id="jToolBar1" min="-2" pref="60" 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="orderBookPanel1" max="32767" attributes="0"/>
|
<Component id="orderBookPanel1" pref="466" max="32767" attributes="0"/>
|
||||||
<Component id="jScrollPane1" pref="466" max="32767" attributes="0"/>
|
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
@ -241,12 +269,12 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<EmptySpace min="0" pref="723" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<EmptySpace min="0" pref="460" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -28,6 +28,9 @@ package gui;
|
|||||||
import java.awt.Dialog;
|
import java.awt.Dialog;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Handler;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@ -54,7 +57,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
public void startTraders() {
|
public void startTraders() {
|
||||||
|
|
||||||
AutoTraderConfig cfg1 = new RandomTraderConfig();
|
AutoTraderConfig cfg1 = new RandomTraderConfig();
|
||||||
AutoTrader rt1 = cfg1.createTrader(Globals.se, 100000, 100000);
|
AutoTrader rt1 = cfg1.createTrader(Globals.se, null, 100000, 100000);
|
||||||
Globals.se.traders.add(rt1);
|
Globals.se.traders.add(rt1);
|
||||||
|
|
||||||
rt1.setName("Alice");
|
rt1.setName("Alice");
|
||||||
@ -63,7 +66,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
AutoTraderConfig cfg2 = new RandomTraderConfig();
|
AutoTraderConfig cfg2 = new RandomTraderConfig();
|
||||||
|
|
||||||
for (int i = 0; i < 700; i++) {
|
for (int i = 0; i < 700; i++) {
|
||||||
AutoTrader randt = cfg2.createTrader(Globals.se, 10000, 10000);
|
AutoTrader randt = cfg2.createTrader(Globals.se, null, 100, 100);
|
||||||
|
|
||||||
Globals.se.traders.add(randt);
|
Globals.se.traders.add(randt);
|
||||||
randt.setName("Bob");
|
randt.setName("Bob");
|
||||||
@ -81,6 +84,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
// <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() {
|
||||||
|
|
||||||
|
jScrollPane2 = new javax.swing.JScrollPane();
|
||||||
|
jTextArea1 = new javax.swing.JTextArea();
|
||||||
jToolBar1 = new javax.swing.JToolBar();
|
jToolBar1 = new javax.swing.JToolBar();
|
||||||
jButton1 = new javax.swing.JButton();
|
jButton1 = new javax.swing.JButton();
|
||||||
jButton2 = new javax.swing.JButton();
|
jButton2 = new javax.swing.JButton();
|
||||||
@ -97,15 +102,23 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
editMenu = new javax.swing.JMenu();
|
editMenu = new javax.swing.JMenu();
|
||||||
cutMenuItem = new javax.swing.JMenuItem();
|
cutMenuItem = new javax.swing.JMenuItem();
|
||||||
copyMenuItem = new javax.swing.JMenuItem();
|
copyMenuItem = new javax.swing.JMenuItem();
|
||||||
|
jSeparator1 = new javax.swing.JPopupMenu.Separator();
|
||||||
pasteMenuItem = new javax.swing.JMenuItem();
|
pasteMenuItem = new javax.swing.JMenuItem();
|
||||||
deleteMenuItem = new javax.swing.JMenuItem();
|
deleteMenuItem = new javax.swing.JMenuItem();
|
||||||
|
jSeparator2 = new javax.swing.JPopupMenu.Separator();
|
||||||
editPreferences = new javax.swing.JMenuItem();
|
editPreferences = new javax.swing.JMenuItem();
|
||||||
jMenu1 = new javax.swing.JMenu();
|
jMenu1 = new javax.swing.JMenu();
|
||||||
jMenuItem2 = new javax.swing.JMenuItem();
|
jMenuItem2 = new javax.swing.JMenuItem();
|
||||||
|
jMenuItem3 = new javax.swing.JMenuItem();
|
||||||
helpMenu = new javax.swing.JMenu();
|
helpMenu = new javax.swing.JMenu();
|
||||||
contentMenuItem = new javax.swing.JMenuItem();
|
contentMenuItem = new javax.swing.JMenuItem();
|
||||||
aboutMenuItem = new javax.swing.JMenuItem();
|
aboutMenuItem = new javax.swing.JMenuItem();
|
||||||
|
|
||||||
|
jTextArea1.setColumns(20);
|
||||||
|
jTextArea1.setRows(5);
|
||||||
|
jTextArea1.setText("Hakke");
|
||||||
|
jScrollPane2.setViewportView(jTextArea1);
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||||
setPreferredSize(new java.awt.Dimension(800, 561));
|
setPreferredSize(new java.awt.Dimension(800, 561));
|
||||||
@ -142,11 +155,11 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
chart1.setLayout(chart1Layout);
|
chart1.setLayout(chart1Layout);
|
||||||
chart1Layout.setHorizontalGroup(
|
chart1Layout.setHorizontalGroup(
|
||||||
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 723, Short.MAX_VALUE)
|
.addGap(0, 300, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
chart1Layout.setVerticalGroup(
|
chart1Layout.setVerticalGroup(
|
||||||
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 460, Short.MAX_VALUE)
|
.addGap(0, 300, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
jScrollPane1.setViewportView(chart1);
|
jScrollPane1.setViewportView(chart1);
|
||||||
@ -197,6 +210,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
copyMenuItem.setMnemonic('y');
|
copyMenuItem.setMnemonic('y');
|
||||||
copyMenuItem.setText("Copy");
|
copyMenuItem.setText("Copy");
|
||||||
editMenu.add(copyMenuItem);
|
editMenu.add(copyMenuItem);
|
||||||
|
editMenu.add(jSeparator1);
|
||||||
|
|
||||||
pasteMenuItem.setMnemonic('s');
|
pasteMenuItem.setMnemonic('s');
|
||||||
pasteMenuItem.setText("Strategies ...");
|
pasteMenuItem.setText("Strategies ...");
|
||||||
@ -215,6 +229,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
editMenu.add(deleteMenuItem);
|
editMenu.add(deleteMenuItem);
|
||||||
|
editMenu.add(jSeparator2);
|
||||||
|
|
||||||
editPreferences.setMnemonic('p');
|
editPreferences.setMnemonic('p');
|
||||||
editPreferences.setText("Preferences ...");
|
editPreferences.setText("Preferences ...");
|
||||||
@ -237,6 +252,14 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
});
|
});
|
||||||
jMenu1.add(jMenuItem2);
|
jMenu1.add(jMenuItem2);
|
||||||
|
|
||||||
|
jMenuItem3.setText("LogWindow");
|
||||||
|
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jMenuItem3ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jMenu1.add(jMenuItem3);
|
||||||
|
|
||||||
menuBar.add(jMenu1);
|
menuBar.add(jMenu1);
|
||||||
|
|
||||||
helpMenu.setMnemonic('h');
|
helpMenu.setMnemonic('h');
|
||||||
@ -263,13 +286,13 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
getContentPane().setLayout(layout);
|
getContentPane().setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 797, Short.MAX_VALUE)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(orderBookPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(orderBookPanel1, 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)
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 729, Short.MAX_VALUE)
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addContainerGap())
|
.addContainerGap(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)
|
||||||
@ -277,8 +300,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, 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(orderBookPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(orderBookPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE))
|
.addComponent(jScrollPane1))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -301,6 +324,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}//GEN-LAST:event_jButton1ActionPerformed
|
}//GEN-LAST:event_jButton1ActionPerformed
|
||||||
|
|
||||||
private void editPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editPreferencesActionPerformed
|
private void editPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editPreferencesActionPerformed
|
||||||
|
Globals.LOGGER.info("Edit prefs...");
|
||||||
|
|
||||||
Dialog d = new gui.EditPreferencesDialog(this, rootPaneCheckingEnabled);
|
Dialog d = new gui.EditPreferencesDialog(this, rootPaneCheckingEnabled);
|
||||||
d.setVisible(rootPaneCheckingEnabled);
|
d.setVisible(rootPaneCheckingEnabled);
|
||||||
}//GEN-LAST:event_editPreferencesActionPerformed
|
}//GEN-LAST:event_editPreferencesActionPerformed
|
||||||
@ -319,18 +344,30 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}//GEN-LAST:event_jButton2ActionPerformed
|
}//GEN-LAST:event_jButton2ActionPerformed
|
||||||
|
|
||||||
private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed
|
private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed
|
||||||
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this,true);
|
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this, true);
|
||||||
ed.setVisible(rootPaneCheckingEnabled);
|
ed.setVisible(rootPaneCheckingEnabled);
|
||||||
|
|
||||||
|
|
||||||
}//GEN-LAST:event_deleteMenuItemActionPerformed
|
}//GEN-LAST:event_deleteMenuItemActionPerformed
|
||||||
|
|
||||||
private void pasteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteMenuItemActionPerformed
|
private void pasteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteMenuItemActionPerformed
|
||||||
EditTradingStrategies s = new EditTradingStrategies(this,true);
|
EditStrategies s = new EditStrategies(this, true);
|
||||||
s.setVisible(rootPaneCheckingEnabled);
|
s.setVisible(rootPaneCheckingEnabled);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}//GEN-LAST:event_pasteMenuItemActionPerformed
|
}//GEN-LAST:event_pasteMenuItemActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
private final LoggerDialog log_d = new LoggerDialog(this,false);
|
||||||
|
|
||||||
|
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
|
||||||
|
log_d.setVisible(!log_d.isShowing());
|
||||||
|
|
||||||
|
|
||||||
|
}//GEN-LAST:event_jMenuItem3ActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
* @throws java.lang.IllegalAccessException
|
* @throws java.lang.IllegalAccessException
|
||||||
@ -344,19 +381,17 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Class<?> c = sesim.Exchange.class;
|
Class<?> c = sesim.Exchange.class;
|
||||||
Globals.prefs=Preferences.userNodeForPackage(c);
|
Globals.prefs = Preferences.userNodeForPackage(c);
|
||||||
|
|
||||||
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
|
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
|
||||||
|
|
||||||
/* try {
|
/* try {
|
||||||
// Set cross-platform Java L&F (also called "Metal")
|
// Set cross-platform Java L&F (also called "Metal")
|
||||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
|
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
|
||||||
} catch (UnsupportedLookAndFeelException | ClassNotFoundException |
|
} catch (UnsupportedLookAndFeelException | ClassNotFoundException |
|
||||||
InstantiationException | IllegalAccessException e) {
|
InstantiationException | IllegalAccessException e) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
ArrayList<Class<AutoTraderConfig>> traders;
|
ArrayList<Class<AutoTraderConfig>> traders;
|
||||||
traders = null;
|
traders = null;
|
||||||
|
|
||||||
@ -399,7 +434,12 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
private javax.swing.JMenu jMenu1;
|
private javax.swing.JMenu jMenu1;
|
||||||
private javax.swing.JMenuItem jMenuItem1;
|
private javax.swing.JMenuItem jMenuItem1;
|
||||||
private javax.swing.JMenuItem jMenuItem2;
|
private javax.swing.JMenuItem jMenuItem2;
|
||||||
|
private javax.swing.JMenuItem jMenuItem3;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
private javax.swing.JScrollPane jScrollPane2;
|
||||||
|
private javax.swing.JPopupMenu.Separator jSeparator1;
|
||||||
|
private javax.swing.JPopupMenu.Separator jSeparator2;
|
||||||
|
private javax.swing.JTextArea jTextArea1;
|
||||||
private javax.swing.JToolBar jToolBar1;
|
private javax.swing.JToolBar jToolBar1;
|
||||||
private javax.swing.JMenuBar menuBar;
|
private javax.swing.JMenuBar menuBar;
|
||||||
private javax.swing.JMenuItem openMenuItem;
|
private javax.swing.JMenuItem openMenuItem;
|
||||||
|
@ -26,14 +26,16 @@
|
|||||||
package sesim;
|
package sesim;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83
|
* @author 7u83
|
||||||
*/
|
*/
|
||||||
public abstract interface AutoTraderConfig {
|
public abstract interface AutoTraderConfig {
|
||||||
public abstract AutoTrader createTrader(Exchange se, double money, double shares);
|
public abstract AutoTrader createTrader(Exchange se, JSONObject cfg,double money, double shares);
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
public abstract JPanel getGui();
|
public abstract AutoTraderGui getGui();
|
||||||
|
public abstract JSONObject getConfig();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
39
src/main/java/sesim/AutoTraderGui.java
Normal file
39
src/main/java/sesim/AutoTraderGui.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package sesim;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class AutoTraderGui extends JPanel{
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -212,12 +212,16 @@ public class AutoTraderLoader {
|
|||||||
for (int i = 0; i < traders.size(); i++) {
|
for (int i = 0; i < traders.size(); i++) {
|
||||||
try {
|
try {
|
||||||
AutoTraderConfig ac = traders.get(i).newInstance();
|
AutoTraderConfig ac = traders.get(i).newInstance();
|
||||||
if (ac.getName().endsWith(name)) {
|
|
||||||
|
if (ac.getName().equals(name)) {
|
||||||
return ac;
|
return ac;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class RandomTrader extends AutoTrader {
|
|||||||
return (max - min) * r + min;
|
return (max - min) * r + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getRandom(int[] minmax) {
|
protected int getRandom(Integer[] minmax) {
|
||||||
return (int) Math.round(getRandom(minmax[0], minmax[1]));
|
return (int) Math.round(getRandom(minmax[0], minmax[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ public class RandomTrader extends AutoTrader {
|
|||||||
* @param minmax
|
* @param minmax
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected double getRandomAmmount(double val, float[] minmax) {
|
protected double getRandomAmmount(double val, Float[] minmax) {
|
||||||
double min = val * minmax[0] / 100.0;
|
double min = val * minmax[0] / 100.0;
|
||||||
double max = val * minmax[1] / 100.0;
|
double max = val * minmax[1] / 100.0;
|
||||||
return getRandom(min, max);
|
return getRandom(min, max);
|
||||||
@ -181,7 +181,7 @@ public class RandomTrader extends AutoTrader {
|
|||||||
|
|
||||||
se.createOrder(account_id, type, volume, limit);
|
se.createOrder(account_id, type, volume, limit);
|
||||||
|
|
||||||
return getRandom(myconfig.buy_order_wait);
|
return getRandom(myconfig.buy_wait);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ public class RandomTrader extends AutoTrader {
|
|||||||
// System.out.print("My Ammount is: "+volume+" My limit si:"+limit+ "\n");
|
// System.out.print("My Ammount is: "+volume+" My limit si:"+limit+ "\n");
|
||||||
se.createOrder(account_id, type, volume, limit);
|
se.createOrder(account_id, type, volume, limit);
|
||||||
|
|
||||||
return getRandom(myconfig.sell_order_wait);
|
return getRandom(myconfig.sell_wait);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,11 @@
|
|||||||
package traders;
|
package traders;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
|
import sesim.AutoTraderGui;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,18 +39,21 @@ import sesim.Exchange;
|
|||||||
*/
|
*/
|
||||||
public class RandomTraderConfig implements AutoTraderConfig {
|
public class RandomTraderConfig implements AutoTraderConfig {
|
||||||
|
|
||||||
public float[] sell_volume = {100, 100};
|
public Float[] sell_volume = {77f, 100f};
|
||||||
public float[] sell_limit = {-5f, 5f};
|
public Float[] sell_limit = {-5.3f, 5f};
|
||||||
public int[] sell_order_wait = {10000, 50000};
|
public Integer[] sell_wait = {10000, 50000};
|
||||||
public int[] wait_after_sell = {10, 30};
|
public Integer[] wait_after_sell = {10, 30};
|
||||||
|
|
||||||
public float[] buy_volume = {100, 100};
|
public Float[] buy_volume = {100f, 100f};
|
||||||
public float[] buy_limit = {-5f, 5f};
|
public Float[] buy_limit = {-5f, 5f};
|
||||||
public int[] buy_order_wait = {10000, 50000};
|
public Integer[] buy_wait = {10000, 50000};
|
||||||
public int[] wait_after_buy = {10, 30};
|
public Integer[] wait_after_buy = {10, 30};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoTrader createTrader(Exchange se, double money, double shares) {
|
public AutoTrader createTrader(Exchange se, JSONObject cfg, double money, double shares) {
|
||||||
|
if (cfg != null) {
|
||||||
|
this.putConfig(cfg);
|
||||||
|
}
|
||||||
return new traders.RandomTrader(se, money, shares, this);
|
return new traders.RandomTrader(se, money, shares, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +63,36 @@ public class RandomTraderConfig implements AutoTraderConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JPanel getGui() {
|
public AutoTraderGui getGui() {
|
||||||
return new RandomTraderConfigForm();
|
return new RandomTraderGui(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String SELL_VOLUME = "sell_volume";
|
||||||
|
final String BUY_VOLUME = "buy_volume";
|
||||||
|
final String SELL_LIMIT = "sell_limit";
|
||||||
|
final String BUY_LIMIT = "buy_limit";
|
||||||
|
final String SELL_WAIT = "sell_wait";
|
||||||
|
final String BUY_WAIT = "wait_wait";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getConfig() {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put(SELL_VOLUME, sell_volume);
|
||||||
|
jo.put(BUY_VOLUME, buy_volume);
|
||||||
|
jo.put(SELL_LIMIT, sell_limit);
|
||||||
|
jo.put(BUY_LIMIT, buy_limit);
|
||||||
|
jo.put(SELL_WAIT, sell_wait);
|
||||||
|
jo.put(BUY_WAIT, buy_wait);
|
||||||
|
return jo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putConfig(JSONObject cfg) {
|
||||||
|
sell_volume = (Float[]) cfg.get(SELL_VOLUME);
|
||||||
|
buy_volume = (Float[]) cfg.get(BUY_VOLUME);
|
||||||
|
sell_limit = (Float[]) cfg.get(SELL_LIMIT);
|
||||||
|
buy_limit = (Float[]) cfg.get(BUY_LIMIT);
|
||||||
|
sell_wait = (Integer[]) cfg.get(SELL_WAIT);
|
||||||
|
buy_wait = (Integer[]) cfg.get(SELL_WAIT);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
126
src/main/java/traders/RandomTraderGui.form
Normal file
126
src/main/java/traders/RandomTraderGui.form
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||||
|
<Border info="null"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||||
|
<Component id="jLabel2" max="32767" attributes="0"/>
|
||||||
|
<Component id="jLabel1" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="1" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="-2" pref="108" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="-2" pref="96" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buy_volume_min" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="buy_volume_max" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="0" pref="93" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jLabel1" alignment="3" min="-2" pref="27" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="buy_volume_min" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="buy_volume_max" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jLabel2" alignment="3" min="-2" pref="27" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace pref="205" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Volume to buy (in percent)"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Volume to sell (in percent):"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="max."/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="max."/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="min."/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel6">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="min."/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JTextField" name="buy_volume_min">
|
||||||
|
<Properties>
|
||||||
|
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||||
|
<Property name="text" type="java.lang.String" value="100.5"/>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buy_volume_minActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JTextField" name="buy_volume_max">
|
||||||
|
<Properties>
|
||||||
|
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||||
|
<Property name="text" type="java.lang.String" value="100.5"/>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buy_volume_maxActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
177
src/main/java/traders/RandomTraderGui.java
Normal file
177
src/main/java/traders/RandomTraderGui.java
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package traders;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import sesim.AutoTraderGui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class RandomTraderGui extends AutoTraderGui {
|
||||||
|
|
||||||
|
private RandomTraderConfig cfg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form RandomTraderConfigForm
|
||||||
|
*/
|
||||||
|
public RandomTraderGui(RandomTraderConfig cfg) {
|
||||||
|
initComponents();
|
||||||
|
this.cfg = cfg;
|
||||||
|
|
||||||
|
JDialog d;
|
||||||
|
|
||||||
|
this.buy_volume_min.setText(cfg.buy_volume[0].toString());
|
||||||
|
this.buy_volume_max.setText(cfg.buy_volume[1].toString());
|
||||||
|
|
||||||
|
// .secfg.buy_volume[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
cfg.buy_volume[0] = Float.parseFloat(this.buy_volume_min.getText());
|
||||||
|
cfg.buy_volume[1] = Float.parseFloat(this.buy_volume_max.getText());
|
||||||
|
JSONObject j = cfg.getConfig();
|
||||||
|
System.out.printf("JSON: %s\n", j.toString(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
jLabel2 = new javax.swing.JLabel();
|
||||||
|
jLabel3 = new javax.swing.JLabel();
|
||||||
|
jLabel4 = new javax.swing.JLabel();
|
||||||
|
jLabel5 = new javax.swing.JLabel();
|
||||||
|
jLabel6 = new javax.swing.JLabel();
|
||||||
|
buy_volume_min = new javax.swing.JTextField();
|
||||||
|
buy_volume_max = new javax.swing.JTextField();
|
||||||
|
|
||||||
|
setBorder(null);
|
||||||
|
|
||||||
|
jLabel1.setText("Volume to buy (in percent)");
|
||||||
|
|
||||||
|
jLabel2.setText("Volume to sell (in percent):");
|
||||||
|
|
||||||
|
jLabel3.setText("max.");
|
||||||
|
|
||||||
|
jLabel4.setText("max.");
|
||||||
|
|
||||||
|
jLabel5.setText("min.");
|
||||||
|
|
||||||
|
jLabel6.setText("min.");
|
||||||
|
|
||||||
|
buy_volume_min.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
|
||||||
|
buy_volume_min.setText("100.5");
|
||||||
|
buy_volume_min.setToolTipText("");
|
||||||
|
buy_volume_min.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buy_volume_minActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buy_volume_max.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
|
||||||
|
buy_volume_max.setText("100.5");
|
||||||
|
buy_volume_max.setToolTipText("");
|
||||||
|
buy_volume_max.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
buy_volume_maxActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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, false)
|
||||||
|
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
.addGap(12, 12, 12)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jLabel6)
|
||||||
|
.addGap(108, 108, 108)
|
||||||
|
.addComponent(jLabel4)
|
||||||
|
.addGap(96, 96, 96))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jLabel5)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buy_volume_min, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jLabel3)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(buy_volume_max, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 93, Short.MAX_VALUE))))
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(35, 35, 35)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(jLabel3)
|
||||||
|
.addComponent(jLabel5)
|
||||||
|
.addComponent(buy_volume_min, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(buy_volume_max, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(jLabel6)
|
||||||
|
.addComponent(jLabel4))
|
||||||
|
.addContainerGap(205, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void buy_volume_minActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buy_volume_minActionPerformed
|
||||||
|
// TODO add your handling code here:
|
||||||
|
}//GEN-LAST:event_buy_volume_minActionPerformed
|
||||||
|
|
||||||
|
private void buy_volume_maxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buy_volume_maxActionPerformed
|
||||||
|
// TODO add your handling code here:
|
||||||
|
}//GEN-LAST:event_buy_volume_maxActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JTextField buy_volume_max;
|
||||||
|
private javax.swing.JTextField buy_volume_min;
|
||||||
|
private javax.swing.JLabel jLabel1;
|
||||||
|
private javax.swing.JLabel jLabel2;
|
||||||
|
private javax.swing.JLabel jLabel3;
|
||||||
|
private javax.swing.JLabel jLabel4;
|
||||||
|
private javax.swing.JLabel jLabel5;
|
||||||
|
private javax.swing.JLabel jLabel6;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -26,8 +26,10 @@
|
|||||||
package traders;
|
package traders;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import org.json.JSONObject;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
|
import sesim.AutoTraderGui;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +39,7 @@ import sesim.Exchange;
|
|||||||
public class SuperTraderConfig implements AutoTraderConfig{
|
public class SuperTraderConfig implements AutoTraderConfig{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoTrader createTrader(Exchange se, double money, double shares) {
|
public AutoTrader createTrader(Exchange se, JSONObject cfg, double money, double shares) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,12 @@ public class SuperTraderConfig implements AutoTraderConfig{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JPanel getGui() {
|
public AutoTraderGui getGui() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getConfig() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package traders;
|
package traders;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
@ -36,7 +37,7 @@ import sesim.Exchange;
|
|||||||
public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTraderConfig{
|
public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTraderConfig{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoTrader createTrader(Exchange se, double money, double shares) {
|
public AutoTrader createTrader(Exchange se, JSONObject cfg, double money, double shares) {
|
||||||
|
|
||||||
return new traders.SwitchingTrader(se, money, shares, this);
|
return new traders.SwitchingTrader(se, money, shares, this);
|
||||||
|
|
||||||
@ -44,15 +45,15 @@ public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTra
|
|||||||
|
|
||||||
public SwitchingTraderConfig() {
|
public SwitchingTraderConfig() {
|
||||||
|
|
||||||
sell_volume = new float[]{100, 100};
|
sell_volume = new Float[]{17f, 100f};
|
||||||
sell_limit = new float[]{-30, 1};
|
sell_limit = new Float[]{-30f, 1f};
|
||||||
sell_order_wait = new int[]{1, 5};
|
sell_wait = new Integer[]{1, 5};
|
||||||
wait_after_sell = new int[]{1, 5};
|
wait_after_sell = new Integer[]{1, 5};
|
||||||
|
|
||||||
buy_volume = new float[]{100, 100};
|
buy_volume = new Float[]{18f, 100f};
|
||||||
buy_limit = new float[]{-1, 30};
|
buy_limit = new Float[]{-1f, 30f};
|
||||||
buy_order_wait = new int[]{1, 5};
|
buy_wait = new Integer[]{1, 5};
|
||||||
wait_after_buy = new int[]{1, 5};
|
wait_after_buy = new Integer[]{1, 5};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user