Code cleaning
This commit is contained in:
parent
cee076162c
commit
8b8c052c97
@ -37,6 +37,7 @@ public class AboutDialog extends javax.swing.JDialog {
|
||||
public AboutDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,8 +41,8 @@ import traders.*;
|
||||
public class MainWin extends javax.swing.JFrame {
|
||||
|
||||
static public sesim.Exchange se;
|
||||
static sesim.Account_old myAccount;
|
||||
static traders.ManTrader myTrader;
|
||||
//static sesim.Account_old myAccount;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form MainWin
|
||||
@ -50,6 +50,7 @@ public class MainWin extends javax.swing.JFrame {
|
||||
public MainWin() {
|
||||
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this);
|
||||
|
||||
|
||||
double aid1 = se.createAccount(100, 100);
|
||||
@ -204,7 +205,7 @@ public class MainWin extends javax.swing.JFrame {
|
||||
//rt.start();
|
||||
|
||||
// SwitchingTraderConfig rcfg1 = new SwitchingTraderConfig();
|
||||
RandomTraderConfig rcfg1 = new RandomTraderConfig();
|
||||
SwitchingTraderConfig rcfg1 = new SwitchingTraderConfig();
|
||||
AutoTrader rt1 = rcfg1.createTrader(se, 0, 1000000);
|
||||
|
||||
rt1.setName("Bob");
|
||||
@ -213,49 +214,17 @@ public class MainWin extends javax.swing.JFrame {
|
||||
//rt2.start();
|
||||
|
||||
|
||||
RandomTraderConfig cfg = new RandomTraderConfig();
|
||||
/* cfg.sell_limit[0]=0.5f;
|
||||
cfg.sell_limit[1]=1.0f;
|
||||
|
||||
cfg.buy_limit[0]=-0.5f;
|
||||
cfg.buy_limit[1]=-1.0f;
|
||||
*/
|
||||
|
||||
// cfg.buy_order_wait[0]=20;
|
||||
// cfg.buy_order_wait[1]=30;
|
||||
|
||||
// cfg.sell_order_wait[0]=20;
|
||||
// cfg.sell_order_wait[1]=30;
|
||||
|
||||
|
||||
SwitchingTraderConfig cfg = new SwitchingTraderConfig();
|
||||
|
||||
for (int i=0; i<1000; i++){
|
||||
AutoTrader randt = cfg.createTrader(se, 1000000, 0);
|
||||
AutoTrader randt = cfg.createTrader(se, 100000, 0);
|
||||
|
||||
randt.setName("Alice");
|
||||
randt.start();
|
||||
}
|
||||
|
||||
|
||||
//RandomTrader rt = new RandomTrader();
|
||||
//rt.start();
|
||||
|
||||
// myAccount = new Account_old(se,1000,100000000.0);
|
||||
// myTrader = new traders.ManTrader(myAccount,null);
|
||||
|
||||
/* Account_old otherAccount = new Account_old(se,1000,1000);
|
||||
Traders.ManTrader otherTrader = new Traders.ManTrader(otherAccount);
|
||||
otherTrader.sell(80, 22.70);
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Account_old traccount = new Account_old(se,5500,1000000.0);
|
||||
RandomTrader rt = new RandomTrader(traccount,null);
|
||||
TraderRunner tr = new TraderRunner(rt);
|
||||
tr.start();
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
136
src/main/java/gui/NewMDIApplication.form
Normal file
136
src/main/java/gui/NewMDIApplication.form
Normal file
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Container class="javax.swing.JDesktopPane" name="desktopPane">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Menu class="javax.swing.JMenuBar" name="menuBar">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="fileMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="102"/>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="openMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Open"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="Save As ..."/>
|
||||
<Property name="displayedMnemonicIndex" type="int" value="5"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="120"/>
|
||||
<Property name="text" type="java.lang.String" value="Exit"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="editMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="101"/>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="cutMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="116"/>
|
||||
<Property name="text" type="java.lang.String" value="Cut"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="copyMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="121"/>
|
||||
<Property name="text" type="java.lang.String" value="Copy"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="pasteMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="112"/>
|
||||
<Property name="text" type="java.lang.String" value="Paste"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="deleteMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="100"/>
|
||||
<Property name="text" type="java.lang.String" value="Delete"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="helpMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="104"/>
|
||||
<Property name="text" type="java.lang.String" value="Help"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="contentMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Contents"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="aboutMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="About"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="menuBar"/>
|
||||
<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">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="279" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
202
src/main/java/gui/NewMDIApplication.java
Normal file
202
src/main/java/gui/NewMDIApplication.java
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* 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 NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* Creates new form NewMDIApplication
|
||||
*/
|
||||
public NewMDIApplication() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
desktopPane = new javax.swing.JDesktopPane();
|
||||
menuBar = new javax.swing.JMenuBar();
|
||||
fileMenu = new javax.swing.JMenu();
|
||||
openMenuItem = new javax.swing.JMenuItem();
|
||||
saveMenuItem = new javax.swing.JMenuItem();
|
||||
saveAsMenuItem = new javax.swing.JMenuItem();
|
||||
exitMenuItem = new javax.swing.JMenuItem();
|
||||
editMenu = new javax.swing.JMenu();
|
||||
cutMenuItem = new javax.swing.JMenuItem();
|
||||
copyMenuItem = new javax.swing.JMenuItem();
|
||||
pasteMenuItem = new javax.swing.JMenuItem();
|
||||
deleteMenuItem = new javax.swing.JMenuItem();
|
||||
helpMenu = new javax.swing.JMenu();
|
||||
contentMenuItem = new javax.swing.JMenuItem();
|
||||
aboutMenuItem = new javax.swing.JMenuItem();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
fileMenu.setMnemonic('f');
|
||||
fileMenu.setText("File");
|
||||
|
||||
openMenuItem.setMnemonic('o');
|
||||
openMenuItem.setText("Open");
|
||||
fileMenu.add(openMenuItem);
|
||||
|
||||
saveMenuItem.setMnemonic('s');
|
||||
saveMenuItem.setText("Save");
|
||||
fileMenu.add(saveMenuItem);
|
||||
|
||||
saveAsMenuItem.setMnemonic('a');
|
||||
saveAsMenuItem.setText("Save As ...");
|
||||
saveAsMenuItem.setDisplayedMnemonicIndex(5);
|
||||
fileMenu.add(saveAsMenuItem);
|
||||
|
||||
exitMenuItem.setMnemonic('x');
|
||||
exitMenuItem.setText("Exit");
|
||||
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
exitMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(exitMenuItem);
|
||||
|
||||
menuBar.add(fileMenu);
|
||||
|
||||
editMenu.setMnemonic('e');
|
||||
editMenu.setText("Edit");
|
||||
|
||||
cutMenuItem.setMnemonic('t');
|
||||
cutMenuItem.setText("Cut");
|
||||
editMenu.add(cutMenuItem);
|
||||
|
||||
copyMenuItem.setMnemonic('y');
|
||||
copyMenuItem.setText("Copy");
|
||||
editMenu.add(copyMenuItem);
|
||||
|
||||
pasteMenuItem.setMnemonic('p');
|
||||
pasteMenuItem.setText("Paste");
|
||||
editMenu.add(pasteMenuItem);
|
||||
|
||||
deleteMenuItem.setMnemonic('d');
|
||||
deleteMenuItem.setText("Delete");
|
||||
editMenu.add(deleteMenuItem);
|
||||
|
||||
menuBar.add(editMenu);
|
||||
|
||||
helpMenu.setMnemonic('h');
|
||||
helpMenu.setText("Help");
|
||||
|
||||
contentMenuItem.setMnemonic('c');
|
||||
contentMenuItem.setText("Contents");
|
||||
helpMenu.add(contentMenuItem);
|
||||
|
||||
aboutMenuItem.setMnemonic('a');
|
||||
aboutMenuItem.setText("About");
|
||||
helpMenu.add(aboutMenuItem);
|
||||
|
||||
menuBar.add(helpMenu);
|
||||
|
||||
setJMenuBar(menuBar);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
|
||||
System.exit(0);
|
||||
}//GEN-LAST:event_exitMenuItemActionPerformed
|
||||
|
||||
/**
|
||||
* @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(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new NewMDIApplication().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem aboutMenuItem;
|
||||
private javax.swing.JMenuItem contentMenuItem;
|
||||
private javax.swing.JMenuItem copyMenuItem;
|
||||
private javax.swing.JMenuItem cutMenuItem;
|
||||
private javax.swing.JMenuItem deleteMenuItem;
|
||||
private javax.swing.JDesktopPane desktopPane;
|
||||
private javax.swing.JMenu editMenu;
|
||||
private javax.swing.JMenuItem exitMenuItem;
|
||||
private javax.swing.JMenu fileMenu;
|
||||
private javax.swing.JMenu helpMenu;
|
||||
private javax.swing.JMenuBar menuBar;
|
||||
private javax.swing.JMenuItem openMenuItem;
|
||||
private javax.swing.JMenuItem pasteMenuItem;
|
||||
private javax.swing.JMenuItem saveAsMenuItem;
|
||||
private javax.swing.JMenuItem saveMenuItem;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
@ -31,14 +31,5 @@ package sesim;
|
||||
*/
|
||||
public class AutoTraderLIst {
|
||||
|
||||
public void add(int n, TraderConfig_old config, Exchange se, long shares, double money) {
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
AutoTrader_old trader = config.createTrader(se, shares, money);
|
||||
// TraderRunner tr = new TraderRunner(trader);
|
||||
|
||||
trader.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package sesim;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public abstract class AutoTrader_old extends Trader_old implements Runnable {
|
||||
|
||||
public AutoTrader_old(Account_old account, TraderConfig_old config) {
|
||||
super(account, config);
|
||||
}
|
||||
|
||||
protected void doSleep(int seconds) {
|
||||
try {
|
||||
sleep(seconds * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
System.out.print("Starting AutoTrader\n");
|
||||
class Runner extends Thread {
|
||||
|
||||
AutoTrader_old trader;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
trader.run();
|
||||
}
|
||||
}
|
||||
Runner r = new Runner();
|
||||
r.trader = this;
|
||||
r.start();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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 abstract class TraderConfig_old{
|
||||
String name;
|
||||
|
||||
public abstract AutoTrader_old createTrader(Exchange se, long shares, double money);
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
public abstract class Trader_old {
|
||||
|
||||
public String name = null;
|
||||
|
||||
|
||||
public Account_old account;
|
||||
public TraderConfig_old config;
|
||||
|
||||
/* public void sell(long shares, double limit){
|
||||
account.sell(shares, limit);
|
||||
}
|
||||
|
||||
public void buy(long shares, double limit){
|
||||
account.buy(shares, limit);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Construct a Trader object
|
||||
* @param account Account_old for this trader
|
||||
* @param config Configration for this trader
|
||||
*/
|
||||
public Trader_old(Account_old account, TraderConfig_old config){
|
||||
this.account=account;
|
||||
this.config=config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Trader object w/o config
|
||||
* The Trader object shoul initialize a default config
|
||||
* @param account
|
||||
*/
|
||||
public Trader_old(Account_old account){
|
||||
this(account,null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package traders;
|
||||
|
||||
import sesim.Account_old;
|
||||
import sesim.Trader_old;
|
||||
import sesim.TraderConfig_old;
|
||||
import sesim.BuyOrder;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ManTrader extends Trader_old{
|
||||
|
||||
public ManTrader(Account_old account,TraderConfig_old config) {
|
||||
super(account,config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void trade(){
|
||||
|
||||
BuyOrder o = new BuyOrder();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@ package traders;
|
||||
import java.util.*;
|
||||
import java.util.Random;
|
||||
import java.util.TimerTask;
|
||||
import sesim.AccountData;
|
||||
/*import sesim.AccountData;*/
|
||||
|
||||
import sesim.AutoTrader;
|
||||
import sesim.Exchange;
|
||||
@ -166,6 +166,7 @@ public class RandomTrader extends AutoTrader {
|
||||
|
||||
if (ad==null || myconfig==null) {
|
||||
System.out.print(ad+"\n");
|
||||
return 0;
|
||||
|
||||
}
|
||||
// how much money we ant to envest?
|
||||
@ -219,6 +220,7 @@ if (ad==null || myconfig==null) {
|
||||
|
||||
// long volume = (long) (money / (limit * 1));
|
||||
if (volume <= 0) {
|
||||
System.out.print("SellVolume 0\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,7 @@
|
||||
package traders;
|
||||
|
||||
import sesim.AccountData;
|
||||
import sesim.Account_old;
|
||||
import sesim.Exchange;
|
||||
import sesim.TraderConfig_old;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -46,8 +44,15 @@ public class SwitchingTrader extends RandomTrader {
|
||||
|
||||
@Override
|
||||
protected Action getAction() {
|
||||
|
||||
|
||||
|
||||
if (action == Action.RANDOM) {
|
||||
action = super.getAction();
|
||||
if ("Bob".equals(name)){
|
||||
System.out.print("Bobs Action\n"+action);
|
||||
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,7 @@
|
||||
*/
|
||||
package traders;
|
||||
|
||||
import sesim.Account_old;
|
||||
import sesim.AutoTrader;
|
||||
import sesim.AutoTrader_old;
|
||||
import sesim.Exchange;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user