Strategy editor almost finished

This commit is contained in:
7u83 2017-01-29 22:21:12 +01:00
parent c6c5ed2931
commit 78faaa59a2
14 changed files with 1441 additions and 354 deletions

View File

@ -55,7 +55,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
// int item_width = 10;
//int items = 350;
//long ntime = 0;
OHLCData data = new OHLCData(6000);
OHLCData data = new OHLCData(16000);
OHLCDataItem current = null;

View File

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="No config available"/>
</Properties>
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
@ -24,23 +32,29 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace pref="275" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="guiPanel" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" 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>
<Component id="jRemoveButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSaveButton" min="-2" max="-2" attributes="0"/>
<EmptySpace 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"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
</Group>
<Component id="jComboBoxStrategySelector" alignment="1" min="-2" pref="361" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -48,15 +62,22 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jComboBoxStrategySelector" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="guiPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace pref="459" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jSaveButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jRemoveButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
@ -79,60 +100,70 @@
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Container class="javax.swing.JPanel" name="guiPanel">
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="defaultGuiPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Container class="javax.swing.JPanel" name="guiPanel">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" pref="492" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" pref="229" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="No config available"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="defaultGuiPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="612" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="435" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButton1">
<Component class="javax.swing.JButton" name="jSaveButton">
<Properties>
<Property name="mnemonic" type="int" value="115"/>
<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"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jSaveButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
<Property name="mnemonic" type="int" value="99"/>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="mnemonic" type="int" value="97"/>
<Property name="text" type="java.lang.String" value="Save as ..."/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jRemoveButton">
<Properties>
<Property name="mnemonic" type="int" value="114"/>
<Property name="text" type="java.lang.String" value="Remove"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRemoveButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -25,7 +25,12 @@
*/
package gui;
import java.awt.Frame;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.logging.Logger;
import javax.swing.JPanel;
import org.json.JSONArray;
@ -38,7 +43,24 @@ import sesim.AutoTraderGui;
*
* @author 7u83 <7u83@mail.ru>
*/
public class EditStrategies extends javax.swing.JDialog {
public final class EditStrategies extends javax.swing.JDialog {
TreeMap<String, JSONObject> strategies = new TreeMap();
void initComboBox() {
this.reloadStrategyConfigs();
this.jComboBoxStrategySelector.removeAllItems();
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
Iterator<String> i = strategies.keySet().iterator();
while (i.hasNext()) {
this.jComboBoxStrategySelector.addItem(i.next());
}
}
/**
* Creates new form EditTradingStrategies
@ -48,12 +70,7 @@ public class EditStrategies extends javax.swing.JDialog {
initComponents();
this.setLocationRelativeTo(this.getParent());
this.jComboBoxStrategySelector.removeAllItems();
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
for (int i = 0; i < sn.size(); i++) {
this.jComboBoxStrategySelector.addItem(sn.get(i));
}
initComboBox();
}
@ -61,22 +78,37 @@ public class EditStrategies extends javax.swing.JDialog {
ArrayList<Class<AutoTraderConfig>> s = Globals.tloader.getTraders();
}
JSONArray loadStrategyConfigs(){
final String STRATEGYPREFS = "Strategies";
void reloadStrategyConfigs() {
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
strategies = new TreeMap();
for (String s : sn) {
JSONObject e = new JSONObject();
// System.out.printf("String put %s\n", s);
this.strategies.put(s, null);
String cfglist = Globals.prefs.get("StrategyCFG", "[]");
JSONArray cfgs = new JSONArray(cfglist);
Logger.getGlobal().info(cfglist);
}
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
JSONObject cfgs = new JSONObject(cfglist);
return cfgs;
Iterator<String> i = cfgs.keys();
while (i.hasNext()) {
String k = i.next();
JSONObject o = cfgs.getJSONObject(k);
strategies.put(k, o);
}
}
/**
@ -88,12 +120,18 @@ public class EditStrategies extends javax.swing.JDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jComboBoxStrategySelector = new javax.swing.JComboBox<>();
jScrollPane1 = new javax.swing.JScrollPane();
guiPanel = new javax.swing.JPanel();
defaultGuiPanel = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jSaveButton = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jRemoveButton = new javax.swing.JButton();
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("No config available");
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -106,90 +144,139 @@ public class EditStrategies extends javax.swing.JDialog {
guiPanel.setLayout(new java.awt.BorderLayout());
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("No config available");
javax.swing.GroupLayout defaultGuiPanelLayout = new javax.swing.GroupLayout(defaultGuiPanel);
defaultGuiPanel.setLayout(defaultGuiPanelLayout);
defaultGuiPanelLayout.setHorizontalGroup(
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE)
.addContainerGap())
.addGap(0, 612, Short.MAX_VALUE)
);
defaultGuiPanelLayout.setVerticalGroup(
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
.addGap(39, 39, 39))
.addGap(0, 435, Short.MAX_VALUE)
);
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
jButton1.setText("Save");
jButton1.addActionListener(new java.awt.event.ActionListener() {
jScrollPane1.setViewportView(guiPanel);
jSaveButton.setMnemonic('s');
jSaveButton.setText("Save");
jSaveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
jSaveButtonActionPerformed(evt);
}
});
jButton2.setText("Cancel");
jButton2.setMnemonic('c');
jButton2.setText("Close");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton1.setMnemonic('a');
jButton1.setText("Save as ...");
jRemoveButton.setMnemonic('r');
jRemoveButton.setText("Remove");
jRemoveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRemoveButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addContainerGap(275, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(guiPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.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))))
.addComponent(jRemoveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSaveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addGap(9, 9, 9))
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jScrollPane1)
.addGap(12, 12, 12)))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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, 459, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSaveButton)
.addComponent(jButton2)
.addComponent(jButton1)
.addComponent(jButton2))
.addComponent(jRemoveButton))
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jScrollPane1)
.addGap(41, 41, 41)))
);
pack();
}// </editor-fold>//GEN-END:initComponents
AutoTraderGui acgui;
AutoTraderConfig ac;
AutoTraderGui acgui;
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) {
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
JSONObject cfgs = new JSONObject(cfglist);
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
System.out.printf("The item selected: %s\n", item);
if (item == null) {
return;
}
String base = null;
JSONObject o = null;
try {
o = (JSONObject) cfgs.get(item);
System.out.printf("Have got a jason obj %s\n", o.toString(9));
System.out.print("--------------------------------------\n");
base = o.getString("base");
} catch (Exception e) {
System.out.printf("Exception return\n", "");
base = item;
}
System.out.printf("Base %s\n", base);
ac = Globals.tloader.getStrategy(base);
if (ac == null) {
System.out.print("BASE IST NULL\n");
System.exit(0);
return;
}
ac.putConfig(o);
acgui = ac.getGui();
guiPanel.removeAll();
if (acgui != null) {
// javax.swing.GroupLayout guil = (javax.swing.GroupLayout) this.guiPanel.getLayout();
guiPanel.add(acgui, java.awt.BorderLayout.CENTER);
// this.guiPanel;
acgui.setVisible(true);
} else {
@ -200,19 +287,76 @@ public class EditStrategies extends javax.swing.JDialog {
JSONObject jo = ac.getConfig();
if (jo != null) {
System.out.printf("%s\n", jo.toString(2));
jo = new JSONObject(jo.toString());
}
System.out.print("Crete auto trader afeter select\n");
AutoTrader at = ac.createTrader(Globals.se, jo, 100, 100);
this.repaint();
}//GEN-LAST:event_jComboBoxStrategySelectorActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
acgui.save();
}//GEN-LAST:event_jButton1ActionPerformed
private void jSaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSaveButtonActionPerformed
acgui.save();
JSONObject o = ac.getConfig();
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
o.put("base", ac.getName());
JSONObject o0 = strategies.get(item);
if (o0 == null) {
StrategySaveDialog d = new StrategySaveDialog((Frame) this.getParent(), true);
d.setLabelAndName(item, "");
d.setVisible(true);
if (d.getName().equals("")) {
return;
}
item = item + " - " + d.getName();
}
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
JSONObject cfgs = new JSONObject(cfglist);
cfgs.put(item, o);
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
//this.reloadStrategyConfigs();
this.initComboBox();
this.jComboBoxStrategySelector.setSelectedItem(item);
//this.jComboBoxStrategySelector.
System.out.printf("Saving item: %s\nJSON %s\n", item, o.toString(3));
}//GEN-LAST:event_jSaveButtonActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRemoveButtonActionPerformed
System.out.print("Hello - remove button\n");
String selected = (String) this.jComboBoxStrategySelector.getSelectedItem();
System.out.printf("Selected: %s\n", selected);
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
JSONObject cfgs = new JSONObject(cfglist);
//System.out.printf("CFG vorher: %s\n", cfgs.toString(3));
cfgs.remove(selected);
// System.out.printf("Neue nachher: %s\n", cfgs.toString(3));
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
this.initComboBox();
}//GEN-LAST:event_jRemoveButtonActionPerformed
/**
* @param args the command line arguments
@ -264,5 +408,8 @@ public class EditStrategies extends javax.swing.JDialog {
private javax.swing.JButton jButton2;
private javax.swing.JComboBox<String> jComboBoxStrategySelector;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton jRemoveButton;
private javax.swing.JButton jSaveButton;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}

View File

@ -199,8 +199,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="orderBookPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="550" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@ -291,8 +291,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
.addContainerGap()
.addComponent(orderBookPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 550, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jScrollPane1)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="strategyLabel" min="-2" pref="105" max="-2" attributes="0"/>
<EmptySpace pref="50" max="32767" attributes="0"/>
<Component id="displayNameField" min="-2" pref="286" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancleButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="displayNameField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="strategyLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="33" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancleButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="strategyLabel">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="displayNameField">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField1"/>
</Properties>
<Events>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="displayNameFieldKeyReleased"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancleButton">
<Properties>
<Property name="mnemonic" type="int" value="99"/>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancleButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="mnemonic" type="int" value="111"/>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,215 @@
/*
* 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.awt.event.KeyEvent;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class StrategySaveDialog extends javax.swing.JDialog {
/**
* Creates new form StrategySaveDialog
*
* @param parent
* @param modal
*/
public StrategySaveDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
this.setLocationRelativeTo(parent);
}
public void setLabelAndName(String l, String t) {
this.strategyLabel.setText(l);
this.displayNameField.setText(t);
}
public String getName() {
return this.displayNameField.getText();
}
/**
* 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() {
strategyLabel = new javax.swing.JLabel();
displayNameField = new javax.swing.JTextField();
cancleButton = new javax.swing.JButton();
okButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
strategyLabel.setText("jLabel1");
displayNameField.setText("jTextField1");
displayNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
displayNameFieldKeyReleased(evt);
}
});
cancleButton.setMnemonic('c');
cancleButton.setText("Cancel");
cancleButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancleButtonActionPerformed(evt);
}
});
okButton.setMnemonic('o');
okButton.setText("Ok");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(strategyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
.addComponent(displayNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancleButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(displayNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(strategyLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancleButton)
.addComponent(okButton))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
void myCancelButton(){
this.displayNameField.setText("");
this.dispose();
}
private void cancleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancleButtonActionPerformed
this.myCancelButton();
}//GEN-LAST:event_cancleButtonActionPerformed
void myOkButton() {
if (getName().equals("")) {
return;
}
this.dispose();
}
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
this.myOkButton();
}//GEN-LAST:event_okButtonActionPerformed
private void displayNameFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_displayNameFieldKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
this.myOkButton();
}
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
this.myCancelButton();
}
}//GEN-LAST:event_displayNameFieldKeyReleased
/**
* @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(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StrategySaveDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StrategySaveDialog.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() {
StrategySaveDialog dialog = new StrategySaveDialog(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.JButton cancleButton;
private javax.swing.JTextField displayNameField;
private javax.swing.JButton okButton;
private javax.swing.JLabel strategyLabel;
// End of variables declaration//GEN-END:variables
}

View File

@ -37,5 +37,6 @@ public abstract interface AutoTraderConfig {
public abstract String getName();
public abstract AutoTraderGui getGui();
public abstract JSONObject getConfig();
public abstract void putConfig(JSONObject cfg);
}

View File

@ -55,14 +55,11 @@ public class AutoTraderLoader {
Class<AutoTraderConfig> loadClass(String filename, String classname) {
String clnam = classname.substring(1, classname.length() - 6).replace('/', '.');
// System.out.printf("Load class name: %s\n", clnam);
// Class<?> cls = ClassLoader.loadClass(className);
File f = new File(filename);
URL url = null;
try {
url = f.toURL(); // file:/c:/myclasses/
url = f.toURL();
} catch (MalformedURLException ex) {
Logger.getLogger(AutoTraderLoader.class.getName()).log(Level.SEVERE, null, ex);
}
@ -74,45 +71,14 @@ public class AutoTraderLoader {
try {
Class<?> cls = cl.loadClass(clnam);
String kanone = cls.getCanonicalName();
// System.out.printf("%s --------------------------------------\n",kanone);
/* for (Class<?> i : cls.getClasses()){
String iname = i.getCanonicalName();
System.out.printf("Checking iname %s\n", iname);
if (i.equals(AutoTraderConfig.class)){
System.out.printf("Yea an autotrader found\n");
}
}
*/
for (Class<?> i : cls.getInterfaces()) {
if (i.equals(AutoTraderConfig.class)) {
System.out.printf("Loading class %s\n", clnam);
try {
String cname = i.getCanonicalName();
System.out.printf("CAnonical name: %s\n", cname);
} catch (Exception ex) {
System.out.printf("Ex: %s\n", ex.getClass().getName());
ex.printStackTrace();
}
return (Class<AutoTraderConfig>) cls;
//System.out.printf("Have found an Auto Trader %s\n", clnam);
//break;
}
}
} catch (ClassNotFoundException ex) {
System.out.printf("Cant load class %s\n", clnam);
//Logger.getLogger(AutoTraderLoader.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
@ -122,14 +88,6 @@ public class AutoTraderLoader {
int curlen = 0;
/* Consumer<? super Path> pf = (Object t) -> {
String fn = ((Path)t).toString();
System.out.printf("Have it %s %d %s\n", fn,curlen,fn.substring(curlen));
};
*/
ArrayList<Class<AutoTraderConfig>> traders;
traders = new ArrayList<>();
@ -155,7 +113,7 @@ public class AutoTraderLoader {
while ((entry = is.getNextJarEntry()) != null) {
if (entry.getName().endsWith(".class")) {
System.out.printf("Entry: %s\n", entry.getName());
// System.out.printf("Entry: %s\n", entry.getName());
}
}
@ -212,16 +170,14 @@ public class AutoTraderLoader {
for (int i = 0; i < traders.size(); i++) {
try {
AutoTraderConfig ac = traders.get(i).newInstance();
if (ac.getName().equals(name)) {
return ac;
}
} catch (Exception ex) {
}
}
return null;
}

View File

@ -25,6 +25,8 @@
*/
package traders;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import org.json.JSONArray;
import org.json.JSONObject;
@ -39,13 +41,13 @@ import sesim.Exchange;
*/
public class RandomTraderConfig implements AutoTraderConfig {
public Float[] sell_volume = {77f, 100f};
public Float[] sell_limit = {-5.3f, 5f};
public Float[] sell_volume = {100f, 100f};
public Float[] sell_limit = {-0.1f, 0.10101f};
public Integer[] sell_wait = {10000, 50000};
public Integer[] wait_after_sell = {10, 30};
public Integer[] wait_after_sell = {1000, 30000};
public Float[] buy_volume = {100f, 100f};
public Float[] buy_limit = {-5f, 5f};
public Float[] buy_limit = {-0.1f, 0.10101f};
public Integer[] buy_wait = {10000, 50000};
public Integer[] wait_after_buy = {10, 30};
@ -59,21 +61,23 @@ public class RandomTraderConfig implements AutoTraderConfig {
@Override
public String getName() {
return "RandomA";
return "Random A";
}
@Override
public AutoTraderGui getGui() {
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";
final String BUY_WAIT = "buy_wait";
final String WAIT_AFTER_SELL = "sell_wait_after";
final String WAIT_AFTER_BUY = "buy_wait_after";
@Override
public JSONObject getConfig() {
JSONObject jo = new JSONObject();
@ -83,16 +87,70 @@ public class RandomTraderConfig implements AutoTraderConfig {
jo.put(BUY_LIMIT, buy_limit);
jo.put(SELL_WAIT, sell_wait);
jo.put(BUY_WAIT, buy_wait);
jo.put(WAIT_AFTER_SELL, wait_after_sell);
jo.put(WAIT_AFTER_BUY, wait_after_buy);
return jo;
}
/* private <T extends Number> T to(Double o){
if (Float==T){
System.out.printf("Double ret %", o.floatValue());
return new T(3);
}
return null;
}
*/
private Float[] to_float(JSONArray a) {
Float[] ret = new Float[a.length()];
for (int i = 0; i < a.length(); i++) {
ret[i] = new Float(a.getDouble(i));
}
return ret;
}
private Integer[] to_integer(JSONArray a) {
Integer[] ret = new Integer[a.length()];
for (int i = 0; i < a.length(); i++) {
ret[i] = a.getInt(i);
}
return ret;
}
private Number[] to_arn(JSONArray a) {
Number[] ret = new Number[a.length()];
// Float x[] = new Float[2];
for (int i = 0; i < a.length(); i++) {
ret[i] = (Number) a.get(i);
}
return ret;
}
public void putConfig(JSONObject cfg) {
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);
if (cfg == null) {
return;
}
System.out.printf("Putconfig %s\n", cfg.toString(4));
String cname = cfg.get(SELL_VOLUME).getClass().getName();
// JSONArray a = cfg.getJSONArray(SELL_VOLUME);
System.out.printf("Array = %s \n", cname);
sell_volume = to_float(cfg.getJSONArray(SELL_VOLUME));
buy_volume = to_float(cfg.getJSONArray(BUY_VOLUME));
sell_limit = to_float(cfg.getJSONArray(SELL_LIMIT));
buy_limit = to_float(cfg.getJSONArray(BUY_LIMIT));
sell_wait = to_integer(cfg.getJSONArray(SELL_WAIT));
buy_wait = to_integer(cfg.getJSONArray(BUY_WAIT));
wait_after_sell = to_integer(cfg.getJSONArray(WAIT_AFTER_SELL));
wait_after_buy = to_integer(cfg.getJSONArray(WAIT_AFTER_BUY));
}
}

View File

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JTextField" name="jTextField1">
<Properties>
<Property name="text" type="java.lang.String" value="jTextField1"/>
</Properties>
</Component>
</NonVisualComponents>
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
@ -21,106 +28,438 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="1" 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 type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel24" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel22" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel23" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel21" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="waitAfterSellMin" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="waitAfterBuyMin" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel19" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel20" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="waitAfterSellMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="waitAfterBuyMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel9" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel12" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel10" pref="175" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel11" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel18" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel15" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<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 type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="sellVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="sellWaitMin" alignment="1" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel13" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyWaitMax" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyLimitMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="sellVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="0" min="-2" pref="98" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</Group>
<EmptySpace min="43" pref="43" max="-2" attributes="0"/>
</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="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="40" 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"/>
<Component id="buyVolMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="buyVolMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" 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="sellVolMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="sellVolMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="205" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buyLimitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="buyLimitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="sellLimitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="sellLimitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buyWaitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel16" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel15" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buyWaitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="sellWaitMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="sellWaitMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel17" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="waitAfterBuyMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="waitAfterBuyMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel19" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel23" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="waitAfterSellMin" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="waitAfterSellMax" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel24" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="37" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="buyWaitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellWaitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellWaitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyWaitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyLimitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyLimitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellLimitMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellLimitMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" minimum="-100.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterBuyMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterSellMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterSellMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="waitAfterBuyMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1000" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyVolMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="buyVolMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellVolMax">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="sellVolMin">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="100.0" minimum="0.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Volume to buy (in percent)"/>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Volume to sell (in percent):"/>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="max."/>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="max."/>
<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."/>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="min."/>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="buy_volume_min">
<Component class="javax.swing.JLabel" name="jLabel7">
<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=""/>
<Property name="text" type="java.lang.String" value="min:"/>
</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">
<Component class="javax.swing.JLabel" name="jLabel8">
<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=""/>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Volume to buy (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Volume to sell (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Buy limit (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Sel limit (in %):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel15">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Buy order wait (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel16">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel17">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel18">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Sell order wait (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel19">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
<Property name="verticalAlignment" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel20">
<Properties>
<Property name="text" type="java.lang.String" value="max:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel21">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel22">
<Properties>
<Property name="text" type="java.lang.String" value="min:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel23">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Wait after buy (in ms):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel24">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Wait after sell (in ms):"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buy_volume_maxActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -46,16 +46,54 @@ public class RandomTraderGui extends AutoTraderGui {
JDialog d;
this.buy_volume_min.setText(cfg.buy_volume[0].toString());
this.buy_volume_max.setText(cfg.buy_volume[1].toString());
this.buyVolMin.setValue(cfg.buy_volume[0]);
this.buyVolMax.setValue(cfg.buy_volume[1]);
this.sellVolMin.setValue(cfg.sell_volume[0]);
this.sellVolMax.setValue(cfg.sell_volume[1]);
this.buyLimitMin.setValue(cfg.buy_limit[0]);
this.buyLimitMax.setValue(cfg.buy_limit[1]);
this.sellLimitMin.setValue(cfg.sell_limit[0]);
this.sellLimitMax.setValue(cfg.sell_limit[1]);
this.buyWaitMin.setValue(cfg.buy_wait[0]);
this.buyWaitMax.setValue(cfg.buy_wait[1]);
this.sellWaitMin.setValue(cfg.sell_wait[0]);
this.sellWaitMax.setValue(cfg.sell_wait[1]);
this.waitAfterBuyMin.setValue(cfg.wait_after_buy[0]);
this.waitAfterBuyMax.setValue(cfg.wait_after_buy[1]);
this.waitAfterSellMin.setValue(cfg.wait_after_sell[0]);
this.waitAfterSellMax.setValue(cfg.wait_after_sell[1]);
// .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());
cfg.buy_volume[0] = (Float) this.buyVolMin.getValue();
cfg.buy_volume[1] = (Float) this.buyVolMax.getValue();
cfg.sell_volume[0] = (Float) this.sellVolMin.getValue();
cfg.sell_volume[1] = (Float) this.sellVolMax.getValue();
cfg.buy_limit[0] = (Float) this.buyLimitMin.getValue();
cfg.buy_limit[1] = (Float) this.buyLimitMax.getValue();
cfg.sell_limit[0] = (Float) this.sellLimitMin.getValue();
cfg.sell_limit[1] = (Float) this.sellLimitMax.getValue();
cfg.buy_wait[0] = (Integer) this.buyWaitMin.getValue();
cfg.buy_wait[1] = (Integer) this.buyWaitMax.getValue();
cfg.sell_wait[0] = (Integer) this.sellWaitMin.getValue();
cfg.sell_wait[1] = (Integer) this.sellWaitMax.getValue();
cfg.wait_after_buy[0] = (Integer) this.waitAfterBuyMin.getValue();
cfg.wait_after_buy[1] = (Integer) this.waitAfterBuyMax.getValue();
cfg.wait_after_sell[0] = (Integer) this.waitAfterSellMin.getValue();
cfg.wait_after_sell[1] = (Integer) this.waitAfterSellMax.getValue();
// cfg.buy_volume[0] = Float.parseFloat(this.buyVolMin.getText());
// cfg.buy_volume[1] = Float.parseFloat(this.buyVolMax.getText());
// cfg.sell_volume[0] = Float.parseFloat(this.sellVolMin.getText());
// cfg.sell_volume[1] = Float.parseFloat(this.sellVolMax.getText());
JSONObject j = cfg.getConfig();
System.out.printf("JSON: %s\n", j.toString(3));
}
@ -69,109 +107,340 @@ public class RandomTraderGui extends AutoTraderGui {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
buyWaitMin = new javax.swing.JSpinner();
sellWaitMin = new javax.swing.JSpinner();
sellWaitMax = new javax.swing.JSpinner();
buyWaitMax = new javax.swing.JSpinner();
buyLimitMin = new javax.swing.JSpinner();
buyLimitMax = new javax.swing.JSpinner();
sellLimitMax = new javax.swing.JSpinner();
sellLimitMin = new javax.swing.JSpinner();
waitAfterBuyMin = new javax.swing.JSpinner();
waitAfterSellMin = new javax.swing.JSpinner();
waitAfterSellMax = new javax.swing.JSpinner();
waitAfterBuyMax = new javax.swing.JSpinner();
buyVolMin = new javax.swing.JSpinner();
buyVolMax = new javax.swing.JSpinner();
sellVolMax = new javax.swing.JSpinner();
sellVolMin = new javax.swing.JSpinner();
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();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jTextField1.setText("jTextField1");
setBorder(null);
jLabel1.setText("Volume to buy (in percent)");
buyWaitMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
jLabel2.setText("Volume to sell (in percent):");
sellWaitMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
jLabel3.setText("max.");
sellWaitMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
jLabel4.setText("max.");
buyWaitMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
jLabel5.setText("min.");
buyLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
jLabel6.setText("min.");
buyLimitMax.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
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);
}
});
sellLimitMax.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
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);
}
});
sellLimitMin.setModel(new javax.swing.SpinnerNumberModel(0.0f, -100.0f, null, 1.0f));
waitAfterBuyMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
waitAfterSellMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
waitAfterSellMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
waitAfterBuyMax.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1000));
buyVolMin.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
buyVolMax.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
sellVolMax.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
sellVolMin.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), Float.valueOf(100.0f), Float.valueOf(1.0f)));
jLabel1.setText("min:");
jLabel2.setText("max:");
jLabel2.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel3.setText("min:");
jLabel4.setText("max:");
jLabel5.setText("max:");
jLabel5.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel6.setText("max:");
jLabel7.setText("min:");
jLabel8.setText("min:");
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Volume to buy (in %):");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Volume to sell (in %):");
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel11.setText("Buy limit (in %):");
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel12.setText("Sel limit (in %):");
jLabel13.setText("max:");
jLabel13.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel14.setText("max:");
jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel15.setText("Buy order wait (in ms):");
jLabel16.setText("min:");
jLabel17.setText("min:");
jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel18.setText("Sell order wait (in ms):");
jLabel19.setText("max:");
jLabel19.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
jLabel20.setText("max:");
jLabel21.setText("min:");
jLabel22.setText("min:");
jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel23.setText("Wait after buy (in ms):");
jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel24.setText("Wait after sell (in ms):");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, 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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel22))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel21)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(waitAfterSellMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterBuyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel19)
.addComponent(jLabel20))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(waitAfterSellMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterBuyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel8))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel3))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel17))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel16)))
.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))))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(sellVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel13)
.addComponent(jLabel14))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(sellVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGap(43, 43, 43))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGap(40, 40, 40)
.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))
.addComponent(buyVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel9))
.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(sellVolMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellVolMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel10))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buyLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buyLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(jLabel7)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sellLimitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellLimitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel4))
.addContainerGap(205, Short.MAX_VALUE))
.addComponent(jLabel8)
.addComponent(jLabel12))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buyWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(jLabel16)
.addComponent(jLabel15)
.addComponent(buyWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sellWaitMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sellWaitMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14)
.addComponent(jLabel17)
.addComponent(jLabel18))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(waitAfterBuyMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterBuyMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel19)
.addComponent(jLabel21)
.addComponent(jLabel23))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(waitAfterSellMin, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(waitAfterSellMax, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel20)
.addComponent(jLabel22)
.addComponent(jLabel24))
.addContainerGap(37, 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.JSpinner buyLimitMax;
private javax.swing.JSpinner buyLimitMin;
private javax.swing.JSpinner buyVolMax;
private javax.swing.JSpinner buyVolMin;
private javax.swing.JSpinner buyWaitMax;
private javax.swing.JSpinner buyWaitMin;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField1;
private javax.swing.JSpinner sellLimitMax;
private javax.swing.JSpinner sellLimitMin;
private javax.swing.JSpinner sellVolMax;
private javax.swing.JSpinner sellVolMin;
private javax.swing.JSpinner sellWaitMax;
private javax.swing.JSpinner sellWaitMin;
private javax.swing.JSpinner waitAfterBuyMax;
private javax.swing.JSpinner waitAfterBuyMin;
private javax.swing.JSpinner waitAfterSellMax;
private javax.swing.JSpinner waitAfterSellMin;
// End of variables declaration//GEN-END:variables
}

View File

@ -62,5 +62,10 @@ public class SuperTraderConfig implements AutoTraderConfig{
public JSONObject getConfig() {
return null;
}
@Override
public void putConfig(JSONObject cfg) {
}
}

View File

@ -68,17 +68,13 @@ public class Test {
+ "\n"
);
}
static public String getFullClassName(String classFileName) throws IOException {
static public String getFullClassName(String classFileName) throws IOException {
File file = new File(classFileName);
FileChannel roChannel = new RandomAccessFile(file, "r").getChannel();
ByteBuffer bb = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, (int)roChannel.size());
FileChannel roChannel = new RandomAccessFile(file, "r").getChannel();
ByteBuffer bb = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, (int) roChannel.size());
String x = new String();
//x.getClass().getClassLoader().loadClass(x);
@ -87,62 +83,36 @@ static public String getFullClassName(String classFileName) throws IOException {
return "";
}
/* static private <T extends Number> void to(T n, Double o) {
if (Float == T) {
System.out.printf("Double ret %", o.floatValue());
n = (T) (Number) o.floatValue();
}
}
*/
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException, MalformedURLException, InstantiationException, IllegalAccessException, IOException {
AutoTraderLoader tl = new AutoTraderLoader();
tl.getTraders();
Float x0;
x0 = 3.1f;
int x1; // = new Integer(0);
x1 = 4;
//x1 = (Integer)(Number)x0;
Double z = 0.99;
// to(x0,z);
System.out.printf("Erg: %f\n", x0);
System.out.printf("Hello world\n", "");
System.exit(0);
ArrayList<File> sl = tl.getTraders("./target/classes/traders");
File file = sl.get(0);
System.out.printf("Filename %s\n", file.getName());
try {
// Convert File to a URL
URL url = file.toURL(); // file:/c:/myclasses/
URL[] urls = new URL[]{url};
// Create a new class loader with the directory
ClassLoader cl = new URLClassLoader(urls);
Class cls = cl.loadClass("traders.RandomTraderConfig");
System.out.printf("Loaded Class: %s\n",cls.getClass().getName());
sesim.AutoTraderConfig at = (AutoTraderConfig )cls.newInstance();
String cp = System.getProperty("java.class.path");
System.out.printf("CP: %s\n", cp);
// Load in the class; MyClass.class should be located in
// the directory file:/c:/myclasses/com/mycompany
//Class cls = cl.loadClass("com.mycompany.MyClass");
} catch (ClassNotFoundException e) {
System.out.printf("hahahah %s\n", e.getClass().getName());
System.out.print("\nException was thrown\n");
System.out.print(e.getMessage());
System.out.print("\n;;;;a\n");
}
}