From 22ac291e842b7dd2a154b173d355f15e82564050 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@mail.ru> Date: Wed, 25 Jan 2017 00:24:53 +0100 Subject: [PATCH] Added some stuff. --- src/main/java/chart/Chart.java | 2 +- src/main/java/gui/EditAutoTraderList.form | 79 ++++++++++ src/main/java/gui/EditAutoTraderList.java | 130 +++++++++++++++ .../java/gui/EditAutoTraderListDialog.form | 70 ++++++++ .../java/gui/EditAutoTraderListDialog.java | 149 ++++++++++++++++++ src/main/java/gui/NewMDIApplication.java | 44 +++--- src/main/java/sesim/AutoTraderConfig.java | 4 +- src/main/java/sesim/AutoTraderRunConfig.java | 39 +++++ src/main/java/sesim/TraderLoader.java | 87 ++++++---- src/main/java/traders/RandomTraderConfig.java | 5 + src/main/java/traders/SuperTraderConfig.java | 53 +++++++ .../java/traders/SwitchingTraderConfig.java | 5 + 12 files changed, 612 insertions(+), 55 deletions(-) create mode 100644 src/main/java/gui/EditAutoTraderList.form create mode 100644 src/main/java/gui/EditAutoTraderList.java create mode 100644 src/main/java/gui/EditAutoTraderListDialog.form create mode 100644 src/main/java/gui/EditAutoTraderListDialog.java create mode 100644 src/main/java/sesim/AutoTraderRunConfig.java create mode 100644 src/main/java/traders/SuperTraderConfig.java diff --git a/src/main/java/chart/Chart.java b/src/main/java/chart/Chart.java index 6be0bdc..408e072 100644 --- a/src/main/java/chart/Chart.java +++ b/src/main/java/chart/Chart.java @@ -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(60000); OHLCDataItem current = null; diff --git a/src/main/java/gui/EditAutoTraderList.form b/src/main/java/gui/EditAutoTraderList.form new file mode 100644 index 0000000..9b91a3e --- /dev/null +++ b/src/main/java/gui/EditAutoTraderList.form @@ -0,0 +1,79 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
diff --git a/src/main/java/gui/EditAutoTraderList.java b/src/main/java/gui/EditAutoTraderList.java new file mode 100644 index 0000000..e977b56 --- /dev/null +++ b/src/main/java/gui/EditAutoTraderList.java @@ -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") + // //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()) + ); + }// //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 +} diff --git a/src/main/java/gui/EditAutoTraderListDialog.form b/src/main/java/gui/EditAutoTraderListDialog.form new file mode 100644 index 0000000..e81f7ce --- /dev/null +++ b/src/main/java/gui/EditAutoTraderListDialog.form @@ -0,0 +1,70 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/gui/EditAutoTraderListDialog.java b/src/main/java/gui/EditAutoTraderListDialog.java new file mode 100644 index 0000000..17c08a9 --- /dev/null +++ b/src/main/java/gui/EditAutoTraderListDialog.java @@ -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") + // //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(); + }// //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 */ + // + /* 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); + } + // + + /* 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 +} diff --git a/src/main/java/gui/NewMDIApplication.java b/src/main/java/gui/NewMDIApplication.java index a0ae02f..e6ebd63 100644 --- a/src/main/java/gui/NewMDIApplication.java +++ b/src/main/java/gui/NewMDIApplication.java @@ -27,6 +27,7 @@ package gui; import java.awt.Dialog; import java.io.File; +import java.util.ArrayList; import javax.swing.JFileChooser; import sesim.AutoTrader; import sesim.AutoTraderConfig; @@ -58,8 +59,8 @@ public class NewMDIApplication extends javax.swing.JFrame { AutoTraderConfig cfg2 = new RandomTraderConfig(); - for (int i = 0; i < 30; i++) { - AutoTrader randt = cfg2.createTrader(Globals.se, 1000, 1000); + for (int i = 0; i < 700; i++) { + AutoTrader randt = cfg2.createTrader(Globals.se, 10000, 10000); Globals.se.traders.add(randt); randt.setName("Bob"); @@ -310,32 +311,35 @@ public class NewMDIApplication extends javax.swing.JFrame { }//GEN-LAST:event_jButton2ActionPerformed private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed - JFileChooser fc = new JFileChooser(); - int f = fc.showOpenDialog(chart1); - File file = fc.getSelectedFile(); - String s = file.getName(); - System.out.printf("Select filename: %s\n",s); - - - - + EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this,true); + ed.setVisible(rootPaneCheckingEnabled); + + }//GEN-LAST:event_deleteMenuItemActionPerformed /** * @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(); - + ArrayList> traders; + traders = null; + sesim.TraderLoader tl = new sesim.TraderLoader(); - try{ - tl.get(); - }catch(Exception e){ - System.out.print("Execptiojn\n"); + try { + traders = tl.get(); + } catch (Exception e) { + System.out.print("Execption\n"); } - //System.exit(0); - - + + for (Class at_class : traders) { + AutoTraderConfig cfg = at_class.newInstance(); + System.out.printf("Have a Trader with name: %s\n", cfg.getName()); + } + + //System.exit(0); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { diff --git a/src/main/java/sesim/AutoTraderConfig.java b/src/main/java/sesim/AutoTraderConfig.java index 7bf5284..e5e5b7e 100644 --- a/src/main/java/sesim/AutoTraderConfig.java +++ b/src/main/java/sesim/AutoTraderConfig.java @@ -29,6 +29,8 @@ package sesim; * * @author 7u83 */ -public interface AutoTraderConfig { +public abstract interface AutoTraderConfig { public abstract AutoTrader createTrader(Exchange se, double money, double shares); + public abstract String getName(); + } diff --git a/src/main/java/sesim/AutoTraderRunConfig.java b/src/main/java/sesim/AutoTraderRunConfig.java new file mode 100644 index 0000000..2c1eafd --- /dev/null +++ b/src/main/java/sesim/AutoTraderRunConfig.java @@ -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; + +} diff --git a/src/main/java/sesim/TraderLoader.java b/src/main/java/sesim/TraderLoader.java index a330dff..b960519 100644 --- a/src/main/java/sesim/TraderLoader.java +++ b/src/main/java/sesim/TraderLoader.java @@ -52,10 +52,10 @@ public class TraderLoader { System.out.printf("File\n", file); } - void loadClass(String filename, String classname) throws MalformedURLException { + Class loadClass(String filename, String classname) throws MalformedURLException { 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); File f = new File(filename); @@ -70,12 +70,45 @@ public class TraderLoader { 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("Have found an Auto Trader %s\n", clnam); - break; + 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 )cls; + //System.out.printf("Have found an Auto Trader %s\n", clnam); + //break; } } @@ -83,12 +116,14 @@ public class TraderLoader { } catch (ClassNotFoundException ex) { System.out.printf("Cant load class %s\n", clnam); + //Logger.getLogger(TraderLoader.class.getName()).log(Level.SEVERE, null, ex); } + return null; } - public void get() throws IOException { + public ArrayList > get() throws IOException { int curlen = 0; @@ -100,8 +135,14 @@ public class TraderLoader { System.out.printf("Have it %s %d %s\n", fn,curlen,fn.substring(curlen)); }; */ + + ArrayList > traders; + traders = new ArrayList <> (); + for (String classpathEntry : System.getProperty("java.class.path").split(System.getProperty("path.separator"))) { + + Consumer pf = new Consumer() { @Override public void accept(Object t) { @@ -109,7 +150,11 @@ public class TraderLoader { if (fn.toLowerCase().endsWith(".class")) { try { //System.out.printf("Halloe: %s %s\n", fn, fn.substring(classpathEntry.length())); - loadClass(fn, fn.substring(classpathEntry.length())); + Class cls = loadClass(fn, fn.substring(classpathEntry.length())); + if (cls==null) + return; + traders.add(cls); + } catch (MalformedURLException ex) { Logger.getLogger(TraderLoader.class.getName()).log(Level.SEVERE, null, ex); } @@ -145,35 +190,11 @@ public class TraderLoader { Files.walk(Paths.get(classpathEntry)) .filter(Files::isRegularFile) .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) - // -> f.getName().toLowerCase().endsWith(".jar")); + return traders; + } public ArrayList getTraders(String dir) { diff --git a/src/main/java/traders/RandomTraderConfig.java b/src/main/java/traders/RandomTraderConfig.java index 543ce7f..a68dd8e 100644 --- a/src/main/java/traders/RandomTraderConfig.java +++ b/src/main/java/traders/RandomTraderConfig.java @@ -49,4 +49,9 @@ public class RandomTraderConfig implements AutoTraderConfig { public AutoTrader createTrader(Exchange se, double money, double shares) { return new traders.RandomTrader(se, money, shares, this); } + + @Override + public String getName() { + return "RandomA"; + } } diff --git a/src/main/java/traders/SuperTraderConfig.java b/src/main/java/traders/SuperTraderConfig.java new file mode 100644 index 0000000..d5813b9 --- /dev/null +++ b/src/main/java/traders/SuperTraderConfig.java @@ -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(){ + + } + +} diff --git a/src/main/java/traders/SwitchingTraderConfig.java b/src/main/java/traders/SwitchingTraderConfig.java index d902834..29fee13 100644 --- a/src/main/java/traders/SwitchingTraderConfig.java +++ b/src/main/java/traders/SwitchingTraderConfig.java @@ -54,4 +54,9 @@ public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTra buy_order_wait = new int[]{1, 5}; wait_after_buy = new int[]{1, 5}; } + + @Override + public String getName(){ + return "SwitchingTrader"; + } }