Added some stuff.
This commit is contained in:
parent
3c56ef2d0e
commit
22ac291e84
@ -55,7 +55,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
|
|||||||
// int item_width = 10;
|
// int item_width = 10;
|
||||||
//int items = 350;
|
//int items = 350;
|
||||||
//long ntime = 0;
|
//long ntime = 0;
|
||||||
OHLCData data = new OHLCData(6000);
|
OHLCData data = new OHLCData(60000);
|
||||||
|
|
||||||
OHLCDataItem current = null;
|
OHLCDataItem current = null;
|
||||||
|
|
||||||
|
79
src/main/java/gui/EditAutoTraderList.form
Normal file
79
src/main/java/gui/EditAutoTraderList.form
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jScrollPane1" pref="388" 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="jScrollPane1" pref="288" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JTable" name="list">
|
||||||
|
<Properties>
|
||||||
|
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||||
|
<Table columnCount="6" rowCount="2">
|
||||||
|
<Column editable="true" title="Name" type="java.lang.String">
|
||||||
|
<Data value="Alice"/>
|
||||||
|
<Data value="Bob"/>
|
||||||
|
</Column>
|
||||||
|
<Column editable="true" title="Count" type="java.lang.Integer">
|
||||||
|
<Data value="1"/>
|
||||||
|
<Data value="1"/>
|
||||||
|
</Column>
|
||||||
|
<Column editable="true" title="Strategy" type="java.lang.String">
|
||||||
|
<Data value="Random"/>
|
||||||
|
<Data value="Random"/>
|
||||||
|
</Column>
|
||||||
|
<Column editable="true" title="Money" type="java.lang.Double">
|
||||||
|
<Data value="10000.0"/>
|
||||||
|
<Data value="1000.0"/>
|
||||||
|
</Column>
|
||||||
|
<Column editable="true" title="Shares" type="java.lang.Double">
|
||||||
|
<Data value="100.0"/>
|
||||||
|
<Data value="100.0"/>
|
||||||
|
</Column>
|
||||||
|
<Column editable="true" title="Enabled" type="java.lang.Boolean">
|
||||||
|
<Data value="true"/>
|
||||||
|
<Data value="true"/>
|
||||||
|
</Column>
|
||||||
|
</Table>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
130
src/main/java/gui/EditAutoTraderList.java
Normal file
130
src/main/java/gui/EditAutoTraderList.java
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* 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 javax.swing.table.AbstractTableModel;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import javax.swing.table.JTableHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class EditAutoTraderList extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
void save() {
|
||||||
|
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||||
|
JTableHeader th = list.getTableHeader();
|
||||||
|
|
||||||
|
for (int i = 0; i < model.getColumnCount(); i++) {
|
||||||
|
String hw = (String) th.getColumnModel().getColumn(0).getHeaderValue();
|
||||||
|
System.out.printf("%s\t", hw);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
for (int i = 0; i < model.getRowCount(); i++) {
|
||||||
|
for (int x = 0; x < model.getColumnCount(); x++) {
|
||||||
|
Object cw = model.getValueAt(i, x);
|
||||||
|
if (cw != null) {
|
||||||
|
System.out.printf("%s\t", cw.toString());
|
||||||
|
//model.getValueAt(i, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form NewJPanel
|
||||||
|
*/
|
||||||
|
public EditAutoTraderList() {
|
||||||
|
initComponents();
|
||||||
|
|
||||||
|
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||||
|
model.setRowCount(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() {
|
||||||
|
|
||||||
|
jScrollPane1 = new javax.swing.JScrollPane();
|
||||||
|
list = new javax.swing.JTable();
|
||||||
|
|
||||||
|
list.setModel(new javax.swing.table.DefaultTableModel(
|
||||||
|
new Object [][] {
|
||||||
|
{"Alice", new Integer(1), "Random", new Double(10000.0), new Double(100.0), new Boolean(true)},
|
||||||
|
{"Bob", new Integer(1), "Random", new Double(1000.0), new Double(100.0), new Boolean(true)}
|
||||||
|
},
|
||||||
|
new String [] {
|
||||||
|
"Name", "Count", "Strategy", "Money", "Shares", "Enabled"
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Class[] types = new Class [] {
|
||||||
|
java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Boolean.class
|
||||||
|
};
|
||||||
|
|
||||||
|
public Class getColumnClass(int columnIndex) {
|
||||||
|
return types [columnIndex];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jScrollPane1.setViewportView(list);
|
||||||
|
|
||||||
|
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()
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
private javax.swing.JTable list;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
70
src/main/java/gui/EditAutoTraderListDialog.form
Normal file
70
src/main/java/gui/EditAutoTraderListDialog.form
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
|
<Component id="jButton2" 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"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="editAutoTraderList1" alignment="1" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<Component id="editAutoTraderList1" pref="267" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace 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"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="gui.EditAutoTraderList" name="editAutoTraderList1">
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="mnemonic" type="int" value="99"/>
|
||||||
|
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButton2">
|
||||||
|
<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="jButton2ActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
149
src/main/java/gui/EditAutoTraderListDialog.java
Normal file
149
src/main/java/gui/EditAutoTraderListDialog.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package gui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form EditAutoTraderListDialog
|
||||||
|
*/
|
||||||
|
public EditAutoTraderListDialog(java.awt.Frame parent, boolean modal) {
|
||||||
|
super(parent, modal);
|
||||||
|
initComponents();
|
||||||
|
this.setTitle("Edit Auto Traders");
|
||||||
|
//this.setLocationRelativeTo(MainWin.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
||||||
|
|
||||||
|
editAutoTraderList1 = new gui.EditAutoTraderList();
|
||||||
|
jButton1 = new javax.swing.JButton();
|
||||||
|
jButton2 = new javax.swing.JButton();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
jButton1.setMnemonic('c');
|
||||||
|
jButton1.setText("Cancel");
|
||||||
|
jButton1.setToolTipText("");
|
||||||
|
|
||||||
|
jButton2.setMnemonic('o');
|
||||||
|
jButton2.setText("Ok");
|
||||||
|
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
jButton2ActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(jButton2)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButton1)
|
||||||
|
.addContainerGap())
|
||||||
|
.addComponent(editAutoTraderList1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addComponent(editAutoTraderList1, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(jButton1)
|
||||||
|
.addComponent(jButton2))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||||
|
// TODO add your handling code here:
|
||||||
|
this.editAutoTraderList1.save();
|
||||||
|
}//GEN-LAST:event_jButton2ActionPerformed
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (InstantiationException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||||
|
java.util.logging.Logger.getLogger(EditAutoTraderListDialog.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() {
|
||||||
|
EditAutoTraderListDialog dialog = new EditAutoTraderListDialog(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 gui.EditAutoTraderList editAutoTraderList1;
|
||||||
|
private javax.swing.JButton jButton1;
|
||||||
|
private javax.swing.JButton jButton2;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -27,6 +27,7 @@ package gui;
|
|||||||
|
|
||||||
import java.awt.Dialog;
|
import java.awt.Dialog;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
@ -58,8 +59,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
AutoTraderConfig cfg2 = new RandomTraderConfig();
|
AutoTraderConfig cfg2 = new RandomTraderConfig();
|
||||||
|
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 700; i++) {
|
||||||
AutoTrader randt = cfg2.createTrader(Globals.se, 1000, 1000);
|
AutoTrader randt = cfg2.createTrader(Globals.se, 10000, 10000);
|
||||||
|
|
||||||
Globals.se.traders.add(randt);
|
Globals.se.traders.add(randt);
|
||||||
randt.setName("Bob");
|
randt.setName("Bob");
|
||||||
@ -310,32 +311,35 @@ 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
|
||||||
JFileChooser fc = new JFileChooser();
|
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this,true);
|
||||||
int f = fc.showOpenDialog(chart1);
|
ed.setVisible(rootPaneCheckingEnabled);
|
||||||
File file = fc.getSelectedFile();
|
|
||||||
String s = file.getName();
|
|
||||||
System.out.printf("Select filename: %s\n",s);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}//GEN-LAST:event_deleteMenuItemActionPerformed
|
}//GEN-LAST:event_deleteMenuItemActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args the command line arguments
|
* @param args the command line arguments
|
||||||
|
* @throws java.lang.IllegalAccessException
|
||||||
|
* @throws java.lang.InstantiationException
|
||||||
*/
|
*/
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
|
||||||
Globals.se = new Exchange();
|
Globals.se = new Exchange();
|
||||||
|
ArrayList<Class<AutoTraderConfig>> traders;
|
||||||
|
traders = null;
|
||||||
|
|
||||||
sesim.TraderLoader tl = new sesim.TraderLoader();
|
sesim.TraderLoader tl = new sesim.TraderLoader();
|
||||||
try{
|
try {
|
||||||
tl.get();
|
traders = tl.get();
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
System.out.print("Execptiojn\n");
|
System.out.print("Execption\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Class<AutoTraderConfig> at_class : traders) {
|
||||||
|
AutoTraderConfig cfg = at_class.newInstance();
|
||||||
|
System.out.printf("Have a Trader with name: %s\n", cfg.getName());
|
||||||
|
}
|
||||||
|
|
||||||
//System.exit(0);
|
//System.exit(0);
|
||||||
|
|
||||||
|
|
||||||
/* Create and display the form */
|
/* Create and display the form */
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -29,6 +29,8 @@ package sesim;
|
|||||||
*
|
*
|
||||||
* @author 7u83
|
* @author 7u83
|
||||||
*/
|
*/
|
||||||
public interface AutoTraderConfig {
|
public abstract interface AutoTraderConfig {
|
||||||
public abstract AutoTrader createTrader(Exchange se, double money, double shares);
|
public abstract AutoTrader createTrader(Exchange se, double money, double shares);
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
39
src/main/java/sesim/AutoTraderRunConfig.java
Normal file
39
src/main/java/sesim/AutoTraderRunConfig.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 7u83 <7u83@mail.ru>
|
||||||
|
*/
|
||||||
|
public class AutoTraderRunConfig {
|
||||||
|
AutoTraderConfig config;
|
||||||
|
int num_traders;
|
||||||
|
String trader_name;
|
||||||
|
double initial_money;
|
||||||
|
double initial_shares;
|
||||||
|
|
||||||
|
}
|
@ -52,10 +52,10 @@ public class TraderLoader {
|
|||||||
System.out.printf("File\n", file);
|
System.out.printf("File\n", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadClass(String filename, String classname) throws MalformedURLException {
|
Class <AutoTraderConfig> loadClass(String filename, String classname) throws MalformedURLException {
|
||||||
|
|
||||||
String clnam = classname.substring(1, classname.length() - 6).replace('/', '.');
|
String clnam = classname.substring(1, classname.length() - 6).replace('/', '.');
|
||||||
System.out.printf("Load class name: %s\n", clnam);
|
// System.out.printf("Load class name: %s\n", clnam);
|
||||||
|
|
||||||
// Class<?> cls = ClassLoader.loadClass(className);
|
// Class<?> cls = ClassLoader.loadClass(className);
|
||||||
File f = new File(filename);
|
File f = new File(filename);
|
||||||
@ -70,12 +70,45 @@ public class TraderLoader {
|
|||||||
try {
|
try {
|
||||||
Class<?> cls = cl.loadClass(clnam);
|
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()) {
|
for(Class<?> i : cls.getInterfaces()) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(i.equals(AutoTraderConfig.class)) {
|
if(i.equals(AutoTraderConfig.class)) {
|
||||||
System.out.printf("Have found an Auto Trader %s\n", clnam);
|
System.out.printf("Loading class %s\n", clnam);
|
||||||
break;
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,12 +116,14 @@ public class TraderLoader {
|
|||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
System.out.printf("Cant load class %s\n", clnam);
|
System.out.printf("Cant load class %s\n", clnam);
|
||||||
|
|
||||||
|
|
||||||
//Logger.getLogger(TraderLoader.class.getName()).log(Level.SEVERE, null, ex);
|
//Logger.getLogger(TraderLoader.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void get() throws IOException {
|
public ArrayList <Class <AutoTraderConfig>> get() throws IOException {
|
||||||
|
|
||||||
int curlen = 0;
|
int curlen = 0;
|
||||||
|
|
||||||
@ -100,8 +135,14 @@ public class TraderLoader {
|
|||||||
System.out.printf("Have it %s %d %s\n", fn,curlen,fn.substring(curlen));
|
System.out.printf("Have it %s %d %s\n", fn,curlen,fn.substring(curlen));
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ArrayList <Class <AutoTraderConfig>> traders;
|
||||||
|
traders = new ArrayList <> ();
|
||||||
|
|
||||||
for (String classpathEntry : System.getProperty("java.class.path").split(System.getProperty("path.separator"))) {
|
for (String classpathEntry : System.getProperty("java.class.path").split(System.getProperty("path.separator"))) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Consumer<? super Path> pf = new Consumer() {
|
Consumer<? super Path> pf = new Consumer() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(Object t) {
|
public void accept(Object t) {
|
||||||
@ -109,7 +150,11 @@ public class TraderLoader {
|
|||||||
if (fn.toLowerCase().endsWith(".class")) {
|
if (fn.toLowerCase().endsWith(".class")) {
|
||||||
try {
|
try {
|
||||||
//System.out.printf("Halloe: %s %s\n", fn, fn.substring(classpathEntry.length()));
|
//System.out.printf("Halloe: %s %s\n", fn, fn.substring(classpathEntry.length()));
|
||||||
loadClass(fn, fn.substring(classpathEntry.length()));
|
Class <AutoTraderConfig> cls = loadClass(fn, fn.substring(classpathEntry.length()));
|
||||||
|
if (cls==null)
|
||||||
|
return;
|
||||||
|
traders.add(cls);
|
||||||
|
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
Logger.getLogger(TraderLoader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(TraderLoader.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@ -146,34 +191,10 @@ public class TraderLoader {
|
|||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
.forEach(pf);
|
.forEach(pf);
|
||||||
|
|
||||||
// Files.walk(Paths.get(classpathEntry));
|
|
||||||
/*
|
|
||||||
System.out.printf("CP ENtry %s\n", classpathEntry);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (classpathEntry.endsWith(".jar")) {
|
|
||||||
File jar = new File(classpathEntry);
|
|
||||||
|
|
||||||
JarInputStream is = new JarInputStream(new FileInputStream(jar));
|
|
||||||
|
|
||||||
JarEntry entry;
|
|
||||||
while ((entry = is.getNextJarEntry()) != null) {
|
|
||||||
if (entry.getName().endsWith(".class")) {
|
|
||||||
|
|
||||||
|
|
||||||
System.out.printf("Entry: %s\n", entry.getName());
|
|
||||||
|
|
||||||
// Class.forName(entry.getName()) and check
|
|
||||||
// for implementation of the interface
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// File[] jarFiles = new File("./plugins").listFiles((File f)
|
return traders;
|
||||||
// -> f.getName().toLowerCase().endsWith(".jar"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList getTraders(String dir) {
|
public ArrayList getTraders(String dir) {
|
||||||
|
@ -49,4 +49,9 @@ public class RandomTraderConfig implements AutoTraderConfig {
|
|||||||
public AutoTrader createTrader(Exchange se, double money, double shares) {
|
public AutoTrader createTrader(Exchange se, double money, double shares) {
|
||||||
return new traders.RandomTrader(se, money, shares, this);
|
return new traders.RandomTrader(se, money, shares, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "RandomA";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
53
src/main/java/traders/SuperTraderConfig.java
Normal file
53
src/main/java/traders/SuperTraderConfig.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, tobias
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package traders;
|
||||||
|
|
||||||
|
import sesim.AutoTrader;
|
||||||
|
import sesim.AutoTraderConfig;
|
||||||
|
import sesim.Exchange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author tobias
|
||||||
|
*/
|
||||||
|
public class SuperTraderConfig implements AutoTraderConfig{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AutoTrader createTrader(Exchange se, double money, double shares) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "SuperTrader";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SuperTraderConfig(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -54,4 +54,9 @@ public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTra
|
|||||||
buy_order_wait = new int[]{1, 5};
|
buy_order_wait = new int[]{1, 5};
|
||||||
wait_after_buy = new int[]{1, 5};
|
wait_after_buy = new int[]{1, 5};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(){
|
||||||
|
return "SwitchingTrader";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user