Better schedulet
This commit is contained in:
parent
df6c10ed59
commit
3039cee680
5
pom.xml
5
pom.xml
@ -23,6 +23,11 @@
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.linoleum</groupId>
|
||||
<artifactId>jlfgr</artifactId>
|
||||
<version>1_0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -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(16000);
|
||||
OHLCData data = new OHLCData(60000*15);
|
||||
|
||||
OHLCDataItem current = null;
|
||||
|
||||
|
@ -27,6 +27,7 @@ package gui;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import sesim.Exchange.Statistics;
|
||||
import sesim.Scheduler;
|
||||
|
||||
/**
|
||||
@ -35,7 +36,7 @@ import sesim.Scheduler;
|
||||
*/
|
||||
public class Clock extends javax.swing.JPanel {
|
||||
|
||||
private final Timer timer;
|
||||
protected final Timer timer;
|
||||
TimerTask clockUpdater;
|
||||
/**
|
||||
* Creates new form Clock
|
||||
@ -50,6 +51,8 @@ public class Clock extends javax.swing.JPanel {
|
||||
long t = Globals.se.timer.currentTimeMillis();
|
||||
|
||||
System.out.printf("The Clock: %d\n",t);
|
||||
Statistics s = Globals.se.getStatistics();
|
||||
System.out.printf("Num trades: %d, %d\n",s.trades,s.orders);
|
||||
jLabel1.setText(Scheduler.formatTimeMillis(t));
|
||||
|
||||
}
|
||||
@ -57,9 +60,13 @@ public class Clock extends javax.swing.JPanel {
|
||||
|
||||
timer.schedule(clockUpdater, 0, 1000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b){
|
||||
System.out.printf("Visible: %s\n",Boolean.toString(b));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,7 @@
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="Clock"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
@ -49,6 +50,9 @@
|
||||
<Properties>
|
||||
<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="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -37,6 +37,7 @@ public class ClockDialog extends javax.swing.JDialog {
|
||||
public ClockDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,8 +53,14 @@ public class ClockDialog extends javax.swing.JDialog {
|
||||
jButton1 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Clock");
|
||||
|
||||
jButton1.setText("Ok");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
@ -77,6 +84,10 @@ public class ClockDialog extends javax.swing.JDialog {
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
@ -122,6 +133,7 @@ public class ClockDialog extends javax.swing.JDialog {
|
||||
@Override
|
||||
public void dispose(){
|
||||
super.dispose();
|
||||
this.clock1.timer.cancel();
|
||||
System.out.print("Disposed\n");
|
||||
}
|
||||
|
||||
|
@ -196,15 +196,15 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="orderBookPanel1" min="-2" pref="233" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jToolBar1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -213,11 +213,12 @@
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jToolBar1" min="-2" pref="60" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="orderBookPanel1" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
<Component id="orderBookPanel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -225,16 +226,85 @@
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JToolBar" name="jToolBar1">
|
||||
<Properties>
|
||||
<Property name="floatable" type="boolean" value="false"/>
|
||||
<Property name="rollover" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Component class="gui.OrderBookPanel" name="orderBookPanel1">
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="chart.Chart" name="chart1">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jRunButton" min="-2" pref="86" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" pref="67" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" pref="63" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="clock1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
|
||||
<Component id="jSpinner2" min="-2" pref="90" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jRunButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="jButton2" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="jButton1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="jSpinner2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="clock1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="9" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/toolbarButtonGraphics/general/Stop24.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Stop"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jRunButton">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||
<FontInfo relative="true">
|
||||
<Font component="jRunButton" property="font" relativeSize="true" size="0"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/icons/run.gif"/>
|
||||
</Property>
|
||||
@ -262,29 +332,18 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="gui.OrderBookPanel" name="orderBookPanel1">
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="chart.Chart" name="chart1">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Component class="javax.swing.JSpinner" name="jSpinner2">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.0" maximum="1000.0" minimum="0.0" numberType="java.lang.Double" stepSize="0.1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jSpinner2StateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="gui.Clock" name="clock1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
|
@ -137,12 +137,15 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
jTextArea1 = new javax.swing.JTextArea();
|
||||
jToolBar1 = new javax.swing.JToolBar();
|
||||
jRunButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
orderBookPanel1 = new gui.OrderBookPanel();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
chart1 = new chart.Chart();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jRunButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jSpinner2 = new javax.swing.JSpinner();
|
||||
clock1 = new gui.Clock();
|
||||
menuBar = new javax.swing.JMenuBar();
|
||||
fileMenu = new javax.swing.JMenu();
|
||||
openMenuItem = new javax.swing.JMenuItem();
|
||||
@ -173,34 +176,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||
setPreferredSize(new java.awt.Dimension(800, 561));
|
||||
|
||||
jToolBar1.setFloatable(false);
|
||||
jToolBar1.setRollover(true);
|
||||
|
||||
jRunButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/run.gif"))); // NOI18N
|
||||
jRunButton.setText("Run sim!");
|
||||
jRunButton.setToolTipText("Run the simmulation");
|
||||
jRunButton.setFocusable(false);
|
||||
jRunButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jRunButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
jRunButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jRunButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jToolBar1.add(jRunButton);
|
||||
|
||||
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pause.gif"))); // NOI18N
|
||||
jButton2.setText("Pause");
|
||||
jButton2.setFocusable(false);
|
||||
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jToolBar1.add(jButton2);
|
||||
|
||||
javax.swing.GroupLayout chart1Layout = new javax.swing.GroupLayout(chart1);
|
||||
chart1.setLayout(chart1Layout);
|
||||
chart1Layout.setHorizontalGroup(
|
||||
@ -214,6 +189,74 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
jScrollPane1.setViewportView(chart1);
|
||||
|
||||
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Stop24.gif"))); // NOI18N
|
||||
jButton1.setText("Stop");
|
||||
jButton1.setFocusable(false);
|
||||
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
|
||||
jRunButton.setFont(jRunButton.getFont());
|
||||
jRunButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/run.gif"))); // NOI18N
|
||||
jRunButton.setText("Run sim!");
|
||||
jRunButton.setToolTipText("Run the simmulation");
|
||||
jRunButton.setFocusable(false);
|
||||
jRunButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jRunButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
jRunButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jRunButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pause.gif"))); // NOI18N
|
||||
jButton2.setText("Pause");
|
||||
jButton2.setFocusable(false);
|
||||
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jSpinner2.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 1000.0d, 0.1d));
|
||||
jSpinner2.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
jSpinner2StateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||
jPanel2.setLayout(jPanel2Layout);
|
||||
jPanel2Layout.setHorizontalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jRunButton, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(clock1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(17, 17, 17)
|
||||
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jRunButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(clock1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(9, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
fileMenu.setMnemonic('f');
|
||||
fileMenu.setText("File");
|
||||
|
||||
@ -347,23 +390,24 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(orderBookPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1))
|
||||
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap()
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(orderBookPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1))
|
||||
.addComponent(jScrollPane1)
|
||||
.addComponent(orderBookPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -478,6 +522,11 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
}//GEN-LAST:event_viewClockActionPerformed
|
||||
|
||||
private void jSpinner2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner2StateChanged
|
||||
Double val = (Double)this.jSpinner2.getValue();
|
||||
Globals.se.timer.setMultiply(val);
|
||||
}//GEN-LAST:event_jSpinner2StateChanged
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
* @throws java.lang.IllegalAccessException
|
||||
@ -535,6 +584,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem aboutMenuItem;
|
||||
private chart.Chart chart1;
|
||||
private gui.Clock clock1;
|
||||
private javax.swing.JMenuItem contentMenuItem;
|
||||
private javax.swing.JMenuItem deleteMenuItem;
|
||||
private javax.swing.JMenuItem editExchangeMenuItem;
|
||||
@ -543,16 +593,18 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
private javax.swing.JMenuItem exitMenuItem;
|
||||
private javax.swing.JMenu fileMenu;
|
||||
private javax.swing.JMenu helpMenu;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JMenuItem jMenuItem2;
|
||||
private javax.swing.JMenuItem jMenuItem3;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JButton jRunButton;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator1;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator2;
|
||||
private javax.swing.JSpinner jSpinner2;
|
||||
private javax.swing.JTextArea jTextArea1;
|
||||
private javax.swing.JToolBar jToolBar1;
|
||||
private javax.swing.JMenuBar menuBar;
|
||||
private javax.swing.JMenuItem openMenuItem;
|
||||
private gui.OrderBookPanel orderBookPanel1;
|
||||
|
60
src/main/java/gui/StatisticsDialog.form
Normal file
60
src/main/java/gui/StatisticsDialog.form
Normal file
@ -0,0 +1,60 @@
|
||||
<?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="-2" attributes="0"/>
|
||||
<Component id="statisticsPanel1" 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="statisticsPanel1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="gui.StatisticsPanel" name="statisticsPanel1">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="388" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="288" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
131
src/main/java/gui/StatisticsDialog.java
Normal file
131
src/main/java/gui/StatisticsDialog.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 StatisticsDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form StatisticsDialog
|
||||
*/
|
||||
public StatisticsDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
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() {
|
||||
|
||||
statisticsPanel1 = new gui.StatisticsPanel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
javax.swing.GroupLayout statisticsPanel1Layout = new javax.swing.GroupLayout(statisticsPanel1);
|
||||
statisticsPanel1.setLayout(statisticsPanel1Layout);
|
||||
statisticsPanel1Layout.setHorizontalGroup(
|
||||
statisticsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 388, Short.MAX_VALUE)
|
||||
);
|
||||
statisticsPanel1Layout.setVerticalGroup(
|
||||
statisticsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 288, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
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()
|
||||
.addComponent(statisticsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(statisticsPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(StatisticsDialog.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() {
|
||||
StatisticsDialog dialog = new StatisticsDialog(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.StatisticsPanel statisticsPanel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
40
src/main/java/gui/StatisticsPanel.form
Normal file
40
src/main/java/gui/StatisticsPanel.form
Normal file
@ -0,0 +1,40 @@
|
||||
<?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="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" pref="216" 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" min="-2" pref="60" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
93
src/main/java/gui/StatisticsPanel.java
Normal file
93
src/main/java/gui/StatisticsPanel.java
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package gui;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import sesim.Scheduler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class StatisticsPanel extends javax.swing.JPanel {
|
||||
|
||||
Timer timer;
|
||||
TimerTask clockUpdater;
|
||||
/**
|
||||
* Creates new form StatisticsPanel
|
||||
*/
|
||||
public StatisticsPanel() {
|
||||
initComponents();
|
||||
this.timer = new Timer();
|
||||
clockUpdater = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
long t = Globals.se.timer.currentTimeMillis();
|
||||
|
||||
System.out.printf("The Clock: %d\n", t);
|
||||
jLabel1.setText(Scheduler.formatTimeMillis(t));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
timer.schedule(clockUpdater, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -171,7 +171,7 @@ public class Exchange { //extends Thread {
|
||||
this.limit = roundMoney(limit);
|
||||
this.volume = roundShares(volume);
|
||||
this.initial_volume = this.volume;
|
||||
this.created = System.currentTimeMillis();
|
||||
this.created = timer.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getID() {
|
||||
@ -219,6 +219,24 @@ public class Exchange { //extends Thread {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class Statistics{
|
||||
public long trades;
|
||||
public long orders;
|
||||
}
|
||||
|
||||
long num_trades = 0;
|
||||
long num_orders=0;
|
||||
|
||||
public Statistics getStatistics(){
|
||||
Statistics s = new Statistics();
|
||||
s.trades=num_trades;
|
||||
s.orders=num_orders;
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*public interface TimerEvent {
|
||||
|
||||
@ -239,15 +257,7 @@ public class Exchange { //extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long getCurrentTimeSeconds() {
|
||||
long ct = System.currentTimeMillis();
|
||||
return ct / 1000;
|
||||
}
|
||||
|
||||
|
||||
public SortedSet<Quote> getQuoteHistory(long start) {
|
||||
|
||||
Quote s = new Quote();
|
||||
@ -500,6 +510,8 @@ public class Exchange { //extends Thread {
|
||||
volume_total += volume;
|
||||
money_total += price * volume;
|
||||
|
||||
num_trades++;
|
||||
|
||||
removeOrderIfExecuted(a);
|
||||
removeOrderIfExecuted(b);
|
||||
|
||||
@ -511,7 +523,7 @@ public class Exchange { //extends Thread {
|
||||
Quote q = new Quote();
|
||||
q.price = money_total / volume_total;
|
||||
q.volume = volume_total;
|
||||
q.time = System.currentTimeMillis();
|
||||
q.time = timer.currentTimeMillis();
|
||||
|
||||
// System.out.print("There was a trade:"+q.price+"\n");
|
||||
this.quoteHistory.add(q);
|
||||
@ -546,7 +558,8 @@ public class Exchange { //extends Thread {
|
||||
return -1;
|
||||
}
|
||||
tradelock.lock();
|
||||
|
||||
num_orders++;
|
||||
|
||||
addOrderToBook(o);
|
||||
a.orders.put(o.id, o);
|
||||
|
||||
|
@ -42,7 +42,15 @@ import java.util.TreeSet;
|
||||
*/
|
||||
public class Scheduler extends Thread {
|
||||
|
||||
long multiply = 1;
|
||||
private double multiplier = 0.0;
|
||||
|
||||
public void setMultiply(double val){
|
||||
this.multiplier=val;
|
||||
}
|
||||
|
||||
public double getMultiply(){
|
||||
return this.multiplier;
|
||||
}
|
||||
|
||||
private final SortedMap<Long, SortedSet<TimerTask>> event_queue = new TreeMap<>();
|
||||
private boolean halt = false;
|
||||
@ -82,9 +90,10 @@ public class Scheduler extends Thread {
|
||||
* @return
|
||||
*/
|
||||
public long currentTimeMillis() {
|
||||
|
||||
long diff = System.currentTimeMillis() - last_time_millis;
|
||||
last_time_millis += diff;
|
||||
this.current_time_millis += diff * 1;
|
||||
this.current_time_millis += diff * this.multiplier;
|
||||
|
||||
return (long) this.current_time_millis;
|
||||
|
||||
@ -95,7 +104,10 @@ public class Scheduler extends Thread {
|
||||
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
String dateFormatted = formatter.format(date);
|
||||
|
||||
return dateFormatted;
|
||||
long seconds = (t/1000) % 60;
|
||||
long minutes = (t/1000/60) % 60;
|
||||
long hours = (t/1000)/(60*60);
|
||||
return String.format("%02d:%02d:%02d",hours,minutes, seconds);
|
||||
|
||||
}
|
||||
|
||||
@ -107,7 +119,7 @@ public class Scheduler extends Thread {
|
||||
public void startTimerEvent(TimerTask e, long time) {
|
||||
long evtime = time + currentTimeMillis();
|
||||
synchronized (event_queue) {
|
||||
this.addEvent(e, time);
|
||||
this.addEvent(e, evtime);
|
||||
}
|
||||
synchronized (this) {
|
||||
notify();
|
||||
@ -128,9 +140,9 @@ public class Scheduler extends Thread {
|
||||
return e.timerTask();
|
||||
}
|
||||
|
||||
private boolean addEvent(TimerTask e, long time) {
|
||||
private boolean addEvent(TimerTask e, long evtime) {
|
||||
|
||||
long evtime = time + currentTimeMillis();
|
||||
// long evtime = time + currentTimeMillis();
|
||||
|
||||
SortedSet<TimerTask> s = event_queue.get(evtime);
|
||||
if (s == null) {
|
||||
@ -147,19 +159,25 @@ public class Scheduler extends Thread {
|
||||
}
|
||||
|
||||
long t = event_queue.firstKey();
|
||||
if (t <= currentTimeMillis()) {
|
||||
long ct = currentTimeMillis();
|
||||
|
||||
//System.out.printf("Current CMP %d %d\n", ct, t);
|
||||
|
||||
if (t <= ct) {
|
||||
this.current_time_millis=t;
|
||||
SortedSet s = event_queue.get(t);
|
||||
event_queue.remove(t);
|
||||
Iterator<TimerTask> it = s.iterator();
|
||||
while (it.hasNext()) {
|
||||
TimerTask e = it.next();
|
||||
long next_t = this.fireEvent(e);
|
||||
this.addEvent(e, next_t);
|
||||
|
||||
this.addEvent(e, next_t+ct);
|
||||
}
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
return t - currentTimeMillis();
|
||||
return (t - currentTimeMillis())/(long)this.multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +196,7 @@ public class Scheduler extends Thread {
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
|
||||
|
||||
if (wtime != -1 && !pause) {
|
||||
wait(wtime);
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ public class RandomTrader extends AutoTrader {
|
||||
|
||||
sesim.Exchange.Account a = se.getAccount(account_id);
|
||||
long rc = this.doTrade();
|
||||
return rc ;
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
@ -67,7 +67,8 @@ public class RandomTrader extends AutoTrader {
|
||||
public long timerTask() {
|
||||
sesim.Exchange.Account a = se.getAccount(account_id);
|
||||
long rc = this.doTrade();
|
||||
return rc / 1;
|
||||
System.out.printf("TT RC: %d\n",rc);
|
||||
return rc;
|
||||
|
||||
// return this.event();
|
||||
}
|
||||
@ -85,9 +86,9 @@ public class RandomTrader extends AutoTrader {
|
||||
|
||||
}
|
||||
|
||||
double getStart (){
|
||||
double getStart() {
|
||||
return Globals.se.fairValue;
|
||||
|
||||
|
||||
}
|
||||
//Timer timer = new Timer();
|
||||
|
||||
@ -104,7 +105,6 @@ public class RandomTrader extends AutoTrader {
|
||||
//final private RandomTraderConfig_old myconfig;
|
||||
// object to generate random numbers
|
||||
//final private Random rand = new Random();
|
||||
|
||||
/**
|
||||
* Get a (long) random number between min an max
|
||||
*
|
||||
@ -114,7 +114,7 @@ public class RandomTrader extends AutoTrader {
|
||||
*/
|
||||
protected double getRandom(double min, double max) {
|
||||
double r = se.randNextDouble();
|
||||
|
||||
|
||||
return (max - min) * r + min;
|
||||
}
|
||||
|
||||
@ -122,7 +122,6 @@ public class RandomTrader extends AutoTrader {
|
||||
return (int) Math.round(getRandom(minmax[0], minmax[1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param val
|
||||
@ -130,7 +129,7 @@ public class RandomTrader extends AutoTrader {
|
||||
* @return
|
||||
*/
|
||||
protected double getRandomAmmount(double val, Float[] minmax) {
|
||||
|
||||
|
||||
//System.out.printf("RandomAmmount: %f (%f,%f)\n",val, minmax[0], minmax[1]);
|
||||
double min = val * minmax[0] / 100.0;
|
||||
double max = val * minmax[1] / 100.0;
|
||||
@ -175,20 +174,18 @@ public class RandomTrader extends AutoTrader {
|
||||
|
||||
double limit;
|
||||
limit = lp + getRandomAmmount(lp, myconfig.buy_limit);
|
||||
|
||||
// System.out.printf("MyLimit: %f\n",limit);
|
||||
|
||||
|
||||
// System.out.printf("MyLimit: %f\n",limit);
|
||||
long volume = (long) (money / (limit * 1));
|
||||
if (volume <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// double volume = (money / (limit * 1));
|
||||
if (volume <= 0) {
|
||||
if (volume <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
se.createOrder(account_id, type, volume, limit);
|
||||
|
||||
return getRandom(myconfig.buy_wait);
|
||||
@ -202,7 +199,7 @@ public class RandomTrader extends AutoTrader {
|
||||
OrderType type = OrderType.ASK;
|
||||
|
||||
// how much money we ant to envest?
|
||||
double volume = (long)getRandomAmmount(ad.shares, myconfig.sell_volume);
|
||||
double volume = (long) getRandomAmmount(ad.shares, myconfig.sell_volume);
|
||||
|
||||
// double lp = 100.0; //se.getBestLimit(type);
|
||||
Quote q = se.getCurrentPrice();
|
||||
|
BIN
src/main/resources/icons/stop.gif
Normal file
BIN
src/main/resources/icons/stop.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 777 B |
Loading…
Reference in New Issue
Block a user