diff --git a/src/main/java/chart/Chart.java b/src/main/java/chart/Chart.java
index b1ab11e..bafa321 100644
--- a/src/main/java/chart/Chart.java
+++ b/src/main/java/chart/Chart.java
@@ -99,7 +99,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver, Scrollab
}
String getAt(int unit) {
- Date date = new Date(sesim.Scheduler.timeStart + unit * 5000);
+ Date date = new Date(/*sesim.Scheduler.timeStart*/ 0 + unit * 5000);
// DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
String dateFormatted = formatter.format(date);
diff --git a/src/main/java/chart/FullChart.java b/src/main/java/chart/FullChart.java
index 4f7abf5..c4b512b 100644
--- a/src/main/java/chart/FullChart.java
+++ b/src/main/java/chart/FullChart.java
@@ -119,7 +119,7 @@ public class FullChart extends javax.swing.JPanel {
}
String getAt(int unit) {
- Date date = new Date(sesim.Scheduler.timeStart + unit * 5000);
+ Date date = new Date(0 + unit * 5000);
// DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
String dateFormatted = formatter.format(date);
diff --git a/src/main/java/gui/AboutDialog.form b/src/main/java/gui/AboutDialog.form
index 57b6897..48a2d59 100644
--- a/src/main/java/gui/AboutDialog.form
+++ b/src/main/java/gui/AboutDialog.form
@@ -1,6 +1,6 @@
-
diff --git a/src/main/java/gui/Clock.java b/src/main/java/gui/Clock.java
index f986f64..7b3111a 100644
--- a/src/main/java/gui/Clock.java
+++ b/src/main/java/gui/Clock.java
@@ -25,19 +25,43 @@
*/
package gui;
+import java.util.Timer;
+import java.util.TimerTask;
+import sesim.Scheduler;
+
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Clock extends javax.swing.JPanel {
+ private final Timer timer;
+ TimerTask clockUpdater;
/**
* Creates new form Clock
*/
public Clock() {
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
@@ -47,19 +71,32 @@ public class Clock extends javax.swing.JPanel {
// //GEN-BEGIN:initComponents
private void initComponents() {
+ jLabel1 = new javax.swing.JLabel();
+
+ jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()+6));
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel1.setText("00:00:00");
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 400, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
+ .addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 300, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
diff --git a/src/main/java/gui/ClockDialog.form b/src/main/java/gui/ClockDialog.form
new file mode 100644
index 0000000..3c797f4
--- /dev/null
+++ b/src/main/java/gui/ClockDialog.form
@@ -0,0 +1,54 @@
+
+
+
diff --git a/src/main/java/gui/ClockDialog.java b/src/main/java/gui/ClockDialog.java
new file mode 100644
index 0000000..76ce0ed
--- /dev/null
+++ b/src/main/java/gui/ClockDialog.java
@@ -0,0 +1,132 @@
+/*
+ * 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 gui;
+
+/**
+ *
+ * @author tobias
+ */
+public class ClockDialog extends javax.swing.JDialog {
+
+ /**
+ * Creates new form ClockDialog
+ */
+ public ClockDialog(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")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ clock1 = new gui.Clock();
+ jButton1 = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ jButton1.setText("Ok");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(clock1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(jButton1)
+ .addGap(59, 59, 59))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(clock1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton1)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ /**
+ * @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(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(ClockDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //
+
+ /* Create and display the dialog */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ ClockDialog dialog = new ClockDialog(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);
+ }
+ });
+ }
+
+ @Override
+ public void dispose(){
+ super.dispose();
+ System.out.print("Disposed\n");
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private gui.Clock clock1;
+ private javax.swing.JButton jButton1;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/src/main/java/gui/EditAutoTraderList.java b/src/main/java/gui/EditAutoTraderList.java
index 0394314..f876ff7 100644
--- a/src/main/java/gui/EditAutoTraderList.java
+++ b/src/main/java/gui/EditAutoTraderList.java
@@ -32,6 +32,9 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
@@ -146,6 +149,24 @@ public class EditAutoTraderList extends javax.swing.JPanel {
// model.setRowCount(3);
list.setRowHeight(30);
+
+ list.getModel().addTableModelListener((TableModelEvent e) -> {
+ System.out.printf("Table has changed\n", "");
+// if (summary==null)
+ // return;
+
+ Double money=0.0;
+ Double shares=0.0;
+
+ for (int r = 0; r < model.getRowCount(); r++) {
+ money+=(Double)list.getValueAt( r, list.getColumn("Money").getModelIndex());
+ shares+=(Double)list.getValueAt( r, list.getColumn("Shares").getModelIndex());
+ System.out.printf("Row: %d %f %f\n",r,money,shares);
+ }
+
+ this.summary.setText(String.format("Fair Value: %.5f", money/shares));
+ });
+
}
@@ -154,6 +175,8 @@ public class EditAutoTraderList extends javax.swing.JPanel {
DefaultTableModel model = (DefaultTableModel) list.getModel();
model.setRowCount(model.getRowCount()+1);
}
+
+ JLabel summary=null;
/**
* This method is called from within the constructor to initialize the form.
diff --git a/src/main/java/gui/EditAutoTraderListDialog.form b/src/main/java/gui/EditAutoTraderListDialog.form
index 1f601db..1343718 100644
--- a/src/main/java/gui/EditAutoTraderListDialog.form
+++ b/src/main/java/gui/EditAutoTraderListDialog.form
@@ -24,7 +24,9 @@
-
+
+
+
@@ -44,6 +46,7 @@
+
@@ -80,5 +83,7 @@
+
+
diff --git a/src/main/java/gui/EditAutoTraderListDialog.java b/src/main/java/gui/EditAutoTraderListDialog.java
index acf6e46..9ef1a15 100644
--- a/src/main/java/gui/EditAutoTraderListDialog.java
+++ b/src/main/java/gui/EditAutoTraderListDialog.java
@@ -39,6 +39,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
initComponents();
this.setTitle("Edit Auto Traders");
this.setLocationRelativeTo(this.getParent());
+ this.editAutoTraderList1.summary=this.jLabelSummary;
//this.setLocationRelativeTo(MainWin.instance);
}
@@ -55,6 +56,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
jButton1 = new javax.swing.JButton();
jOkButton = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
+ jLabelSummary = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@@ -87,7 +89,9 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
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)
+ .addContainerGap()
+ .addComponent(jLabelSummary, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jOkButton)
@@ -104,7 +108,8 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jOkButton)
- .addComponent(jButton2))
+ .addComponent(jButton2)
+ .addComponent(jLabelSummary))
.addContainerGap())
);
@@ -171,6 +176,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
private gui.EditAutoTraderList editAutoTraderList1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
+ private javax.swing.JLabel jLabelSummary;
private javax.swing.JButton jOkButton;
// End of variables declaration//GEN-END:variables
}
diff --git a/src/main/java/gui/EditPreferencesDialog.form b/src/main/java/gui/EditPreferencesDialog.form
index b2882de..68f394e 100644
--- a/src/main/java/gui/EditPreferencesDialog.form
+++ b/src/main/java/gui/EditPreferencesDialog.form
@@ -39,11 +39,8 @@
-
-
-
-
-
+
+
@@ -59,11 +56,9 @@
-
-
-
-
-
+
+
+
@@ -122,18 +117,12 @@
-
+
-
+
-
-
-
-
-
-
-
+
diff --git a/src/main/java/gui/EditPreferencesDialog.java b/src/main/java/gui/EditPreferencesDialog.java
index 209e18f..1d531e9 100644
--- a/src/main/java/gui/EditPreferencesDialog.java
+++ b/src/main/java/gui/EditPreferencesDialog.java
@@ -62,6 +62,10 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
lafComboBox.addItem(lafInfo1.getName());
}
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
+
+ String selstr = Globals.prefs.get(Globals.DEVELSTATUS,"false");
+
+ this.jDevleopmentFeaturesCheckBox.setSelected(selstr.equals("true"));
}
/**
@@ -78,8 +82,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
applyButton = new javax.swing.JButton();
okButton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
- jCheckBox2 = new javax.swing.JCheckBox();
- jLabel2 = new javax.swing.JLabel();
+ jDevleopmentFeaturesCheckBox = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@@ -114,12 +117,9 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
}
});
- jLabel1.setText("jLabel1");
+ jLabel1.setText("Look and Feel:");
- jCheckBox2.setText("jCheckBox2");
- jCheckBox2.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
-
- jLabel2.setText("jLabel2");
+ jDevleopmentFeaturesCheckBox.setText("Develeopment");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@@ -140,9 +140,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))
.addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(jCheckBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(jDevleopmentFeaturesCheckBox)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
@@ -153,11 +151,9 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jCheckBox2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 191, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 178, Short.MAX_VALUE)
+ .addComponent(jDevleopmentFeaturesCheckBox)
+ .addGap(40, 40, 40)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(applyButton)
@@ -207,6 +203,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
this.applyButtonActionPerformed(evt);
String selected = (String) this.lafComboBox.getSelectedItem();
Globals.prefs.put("laf", selected);
+ String sel = this.jDevleopmentFeaturesCheckBox.isSelected() == true ? "true" : "false";
+ Globals.prefs.put(Globals.DEVELSTATUS,sel);
this.dispose();
}//GEN-LAST:event_okButtonActionPerformed
@@ -255,9 +253,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton applyButton;
private javax.swing.JButton cancelButton;
- private javax.swing.JCheckBox jCheckBox2;
+ private javax.swing.JCheckBox jDevleopmentFeaturesCheckBox;
private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
private javax.swing.JComboBox lafComboBox;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables
diff --git a/src/main/java/gui/Globals.java b/src/main/java/gui/Globals.java
index e763de2..a064a74 100644
--- a/src/main/java/gui/Globals.java
+++ b/src/main/java/gui/Globals.java
@@ -47,6 +47,8 @@ public class Globals {
static final String STRATEGYPREFS = "Strategies";
static final String TRADERPREFS = "Traders";
+
+ static final String DEVELSTATUS = "devel_status";
static public sesim.Exchange se;
diff --git a/src/main/java/gui/NewMDIApplication.form b/src/main/java/gui/NewMDIApplication.form
index 6472f5d..7ed2347 100644
--- a/src/main/java/gui/NewMDIApplication.form
+++ b/src/main/java/gui/NewMDIApplication.form
@@ -110,7 +110,7 @@
-