Moved order books out of exchange to Stock class.

using getDefaultStock to be compatible
This commit is contained in:
7u83 2017-12-10 09:33:25 +01:00
parent 1efc9ab4c6
commit fd90846f04
11 changed files with 578 additions and 45 deletions

View File

@ -1,4 +1,4 @@
#Thu, 07 Dec 2017 16:22:48 +0100
#Sun, 10 Dec 2017 09:32:20 +0100
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=

55
src/chart/MChart.form Normal file
View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.PanelFormInfo">
<Properties>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Crosshair Cursor"/>
</Property>
</Properties>
<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"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,115,0,0,2,127"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="149" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="390" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="97" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="174" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder/>
</Border>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
</SubComponents>
</Form>

123
src/chart/MChart.java Normal file
View File

@ -0,0 +1,123 @@
/*
* 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 chart;
import javax.swing.JPanel;
import javax.swing.border.Border;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class MChart extends java.awt.Panel {
private javax.swing.JButton jButton1;
private javax.swing.JToggleButton jToggleButton1;
/**
* Creates new form MChart
*/
public MChart() {
initComponents();
/* java.awt.GridBagConstraints gridBagConstraints;
jButton1 = new javax.swing.JButton();
jToggleButton1 = new javax.swing.JToggleButton();
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
layout.columnWidths = new int[]{0, 5, 0, 5, 0};
layout.rowHeights = new int[]{0};
setLayout(layout);
*/
this.setupLeyout();
}
void setupLeyout() {
Border border = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0));
jButton1 = new javax.swing.JButton();
jToggleButton1 = new javax.swing.JToggleButton();
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
setLayout(layout);
java.awt.GridBagConstraints gridBagConstraints;
jButton1.setText("jButton1");
JPanel p = new JPanel();
//Border border;
//border = javax.swing.border.LineBorder;
p.setBorder(border);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 1;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.7;
add(p, gridBagConstraints);
}
/**
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(149, 149, 149)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(390, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(97, 97, 97)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(174, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables
}

19
src/chart/MMChart.form Normal file
View File

@ -0,0 +1,19 @@
<?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 class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
</Form>

113
src/chart/MMChart.java Normal file
View File

@ -0,0 +1,113 @@
/*
* 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 chart;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class MMChart extends javax.swing.JPanel {
/**
* Creates new form MMChart
*/
public MMChart() {
initComponents();
setupLayout();
}
void setupLayout() {
Border redborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0));
Border blueborder = javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 255));
// jButton1 = new javax.swing.JButton();
// jToggleButton1 = new javax.swing.JToggleButton();
java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
setLayout(layout);
java.awt.GridBagConstraints gridBagConstraints;
// jButton1.setText("jButton1");
JButton but = new JButton();
but.setText("Hello world");
JPanel p;
p = new JPanel();
p.setBorder(redborder);
p.setBackground(Color.blue);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 1;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.7;
add(p, gridBagConstraints);
p = new JPanel();
p.setBorder(redborder);
p.setBackground(Color.white);
p.setPreferredSize(new Dimension(100,100));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 1;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.0;
gridBagConstraints.weighty = 0.7;
add(p, gridBagConstraints);
p.setLayout(layout);
}
/**
* 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() {
setLayout(null);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

56
src/chart/NewPanel.form Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.PanelFormInfo">
<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"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="jButton1"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 0]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="80" gridHeight="-1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="50.0" weightY="0.7"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="jButton2"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 0]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="1" gridWidth="80" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.5" weightY="0.3"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="jButton3">
<Properties>
<Property name="text" type="java.lang.String" value="jButton3"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="80" gridY="0" gridWidth="20" gridHeight="-1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.7"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Form>

96
src/chart/NewPanel.java Normal file
View File

@ -0,0 +1,96 @@
/*
* 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 chart;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class NewPanel extends java.awt.Panel {
/**
* Creates new form NewPanel
*/
public NewPanel() {
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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setLayout(new java.awt.GridBagLayout());
jButton1.setText("jButton1");
jButton1.setPreferredSize(new java.awt.Dimension(0, 0));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 80;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 50.0;
gridBagConstraints.weighty = 0.7;
add(jButton1, gridBagConstraints);
jButton2.setText("jButton2");
jButton2.setPreferredSize(new java.awt.Dimension(0, 0));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 80;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.5;
gridBagConstraints.weighty = 0.3;
add(jButton2, gridBagConstraints);
jButton3.setText("jButton3");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 80;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 20;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weighty = 0.7;
add(jButton3, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
// End of variables declaration//GEN-END:variables
}

View File

@ -469,6 +469,13 @@
</Constraint>
</Constraints>
</Component>
<Component class="chart.MMChart" name="mMChart2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@ -187,6 +187,7 @@ public class SeSimApplication extends javax.swing.JFrame {
quoteVertical1 = new gui.orderbook.QuoteVertical();
jSplitPane5 = new javax.swing.JSplitPane();
statistics1 = new gui.Statistics();
mMChart2 = new chart.MMChart();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
openMenuItem = new javax.swing.JMenuItem();
@ -325,6 +326,7 @@ public class SeSimApplication extends javax.swing.JFrame {
jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane5.setTopComponent(statistics1);
jSplitPane5.setRightComponent(mMChart2);
jSplitPane3.setLeftComponent(jSplitPane5);
@ -861,7 +863,7 @@ public class SeSimApplication extends javax.swing.JFrame {
//hs.setVisible(true);
SeSimHelp h = new SeSimHelp();
h.setVisible(true);
}//GEN-LAST:event_jMenuItem1ActionPerformed
@ -943,6 +945,7 @@ public class SeSimApplication extends javax.swing.JFrame {
private javax.swing.JSplitPane jSplitPane4;
private javax.swing.JSplitPane jSplitPane5;
private javax.swing.JTextArea jTextArea1;
private chart.MMChart mMChart2;
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenuItem openMenuItem;
private gui.orderbook.OrderBook orderBookNew1;

View File

@ -43,12 +43,20 @@ import sesim.Order.OrderType;
* @author 7u83
*/
public class Exchange {
//private HashMap<Order.OrderType, SortedSet<Order>> order_books;
HashMap<String, Stock> stocks;
Stock getStock(String symbol) {
final String DEFAULT_STOCK="def";
public Stock getStock(String symbol) {
return stocks.get(symbol);
}
public Stock getDefaultStock(){
return getStock(DEFAULT_STOCK);
}
ConcurrentLinkedQueue<Order> order_queue = new ConcurrentLinkedQueue();
@ -240,7 +248,7 @@ public class Exchange {
return a.id;
}
class OrderComparator implements Comparator<Order> {
static class OrderComparator implements Comparator<Order> {
OrderType type;
@ -288,7 +296,6 @@ public class Exchange {
}
HashMap<OrderType, SortedSet<Order>> order_books;
IDGenerator order_id_generator = new IDGenerator();
@ -315,11 +322,15 @@ public class Exchange {
this.ohlc_data = new HashMap();
// Create order books
order_books = new HashMap();
/* order_books = new HashMap();
for (OrderType type : OrderType.values()) {
order_books.put(type, new TreeSet(new OrderComparator(type)));
}
*/
Stock defstock = new Stock(DEFAULT_STOCK);
stocks = new HashMap();
stocks.put(defstock.getSymbol(), defstock);
}
/**
@ -383,7 +394,7 @@ public class Exchange {
Account a = o.account;
a.orders.put(o.id, o);
a.update(o);
executeOrders();
executeOrders(getDefaultStock());
}
updateBookReceivers(OrderType.SELLLIMIT);
@ -428,7 +439,7 @@ public class Exchange {
}
}
*/
public SortedSet<Quote> getQuoteHistory(long start) {
/* public SortedSet<Quote> getQuoteHistory(long start) {
Quote s = new Quote();
s.time = start * 1000;
@ -440,7 +451,8 @@ public class Exchange {
return result;
}
*/
public final String CFG_MONEY_DECIMALS = "money_decimals";
public final String CFG_SHARES_DECIMALS = "shares_decimals";
@ -454,10 +466,10 @@ public class Exchange {
}
public Double getBestPrice() {
System.out.printf("Get BP\n");
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
public Double getBestPrice(Stock stock) {
SortedSet<Order> bid = stock.order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = stock.order_books.get(OrderType.SELLLIMIT);
Quote lq = this.getLastQuoete();
Order b = null, a = null;
@ -533,11 +545,11 @@ public class Exchange {
return lq.price;
}
public Quote getBestPrice_0() {
public Quote getBestPrice_0(Stock stock) {
synchronized (executor) {
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
SortedSet<Order> bid = stock.order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = stock.order_books.get(OrderType.SELLLIMIT);
Quote lq = this.getLastQuoete();
Order b = null, a = null;
@ -607,6 +619,10 @@ public class Exchange {
}
}
public Quote getBestPrice_0(){
return getBestPrice_0(getDefaultStock());
}
// Class to describe an executed order
// QuoteReceiver has to be implemented by objects that wants
// to receive quote updates
@ -688,9 +704,9 @@ public class Exchange {
//double lastprice = 100.0;
// long lastsvolume;
// private final Locker tradelock = new Locker();
public ArrayList<Order> getOrderBook(OrderType type, int depth) {
public ArrayList<Order> getOrderBook(Stock stock, OrderType type, int depth) {
SortedSet<Order> book = order_books.get(type);
SortedSet<Order> book = stock.order_books.get(type);
if (book == null) {
return null;
}
@ -715,6 +731,11 @@ public class Exchange {
return ret;
}
public ArrayList<Order> getOrderBook(OrderType type, int depth){
return getOrderBook(getDefaultStock(),type,depth);
}
public Quote getLastQuoete() {
if (this.quoteHistory.isEmpty()) {
return null;
@ -737,7 +758,7 @@ public class Exchange {
}
public boolean cancelOrder(double account_id, long order_id) {
public boolean cancelOrder(Stock stock,double account_id, long order_id) {
Account a = accounts.get(account_id);
if (a == null) {
return false;
@ -754,7 +775,7 @@ public class Exchange {
// System.out.print("The Order:"+o.limit+"\n");
if (o != null) {
SortedSet ob = order_books.get(o.type);
SortedSet ob = stock.order_books.get(o.type);
boolean rc = ob.remove(o);
@ -770,6 +791,10 @@ public class Exchange {
// System.out.printf("Levave executor %d\n", Thread.currentThread().getId());
return ret;
}
public boolean cancelOrder(double account_id, long order_id){
return cancelOrder(getDefaultStock(),account_id,order_id);
}
Random random;
@ -797,7 +822,7 @@ public class Exchange {
public double fairValue = 0;
private void removeOrderIfExecuted(Order o) {
private void removeOrderIfExecuted(Stock stock,Order o) {
if (o.getAccount().getOwner().getName().equals("Tobias0")) {
// System.out.printf("Tobias 0 test\n");
}
@ -819,7 +844,7 @@ public class Exchange {
o.account.orders.remove(o.id);
SortedSet book = order_books.get(o.type);
SortedSet book = stock.order_books.get(o.type);
book.remove(book.first());
@ -827,10 +852,14 @@ public class Exchange {
o.account.update(o);
}
private void removeOrderIfExecuted(Order o){
removeOrderIfExecuted(getDefaultStock(),o);
}
void checkSLOrders(double price) {
SortedSet<Order> sl = order_books.get(OrderType.STOPLOSS);
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
void checkSLOrders(Stock stock, double price) {
SortedSet<Order> sl = stock.order_books.get(OrderType.STOPLOSS);
SortedSet<Order> ask = stock.order_books.get(OrderType.SELLLIMIT);
if (sl.isEmpty()) {
return;
@ -846,6 +875,11 @@ public class Exchange {
// System.out.printf("Stoploss hit %f %f\n", s.volume, s.limit);
}
}
void checkSLOrders(double price){
checkSLOrders(getDefaultStock(),price);
}
public void executeUnlimitedOrders() {
@ -886,14 +920,14 @@ public class Exchange {
/**
*
*/
public void executeOrders() {
public void executeOrders(Stock stock) {
// System.out.printf("Exec Orders\n");
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
SortedSet<Order> bid = stock.order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = stock.order_books.get(OrderType.SELLLIMIT);
SortedSet<Order> ul_buy = order_books.get(OrderType.BUY);
SortedSet<Order> ul_sell = order_books.get(OrderType.SELL);
SortedSet<Order> ul_buy = stock.order_books.get(OrderType.BUY);
SortedSet<Order> ul_sell = stock.order_books.get(OrderType.SELL);
double volume_total = 0;
double money_total = 0;
@ -905,7 +939,7 @@ public class Exchange {
Order a = ul_sell.first();
Order b = ul_buy.first();
Double price = getBestPrice();
Double price = getBestPrice(stock);
if (price == null) {
break;
}
@ -989,8 +1023,8 @@ public class Exchange {
long buy_orders = 0;
long sell_orders = 0;
private void addOrderToBook(Order o) {
order_books.get(o.type).add(o);
private void addOrderToBook(Stock stock, Order o) {
stock.order_books.get(o.type).add(o);
switch (o.type) {
case BUY:
case BUYLIMIT:
@ -1004,6 +1038,10 @@ public class Exchange {
}
// System.out.printf("B/S %d/%d Failed B/S: %d/%d\n", buy_orders, sell_orders,buy_failed,sell_failed);
}
private void addOrderToBook(Order o){
addOrderToBook(getDefaultStock(),o);
}
long buy_failed = 0;
long sell_failed = 0;
@ -1054,7 +1092,7 @@ public class Exchange {
a.orders.put(o.id, o);
a.update(o);
executeOrders();
executeOrders(getDefaultStock());
updateBookReceivers(OrderType.SELLLIMIT);
updateBookReceivers(OrderType.BUYLIMIT);
@ -1066,13 +1104,17 @@ public class Exchange {
return o.getID();
}
public double getBestLimit(OrderType type) {
Order o = order_books.get(type).first();
public double getBestLimit(Stock stock,OrderType type) {
Order o = stock.order_books.get(type).first();
if (o == null) {
return -1;
}
return o.limit;
}
public double getBestLimit(OrderType type){
return getBestLimit(getDefaultStock(),type);
}
public int getNumberOfOpenOrders(double account_id) {
Account a = accounts.get(account_id);

View File

@ -25,21 +25,40 @@
*/
package sesim;
import java.util.HashMap;
import java.util.SortedSet;
import java.util.TreeSet;
import sesim.Exchange.OrderComparator;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
public class Stock {
private String symbol;
private final String symbol;
private String name;
String getSymbol(){
Stock(String symbol) {
this.symbol=symbol;
order_books = new HashMap();
// Create an order book for each order type
for (Order.OrderType type : Order.OrderType.values()) {
this.order_books.put(type, new TreeSet(new Exchange.OrderComparator(type)));
}
}
String getSymbol() {
return symbol;
}
String getName(){
String getName() {
return name;
}
public final HashMap<Order.OrderType, SortedSet<Order>> order_books;
}