work on graphics
This commit is contained in:
parent
74dc584984
commit
36c1826778
@ -68,7 +68,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
|||||||
*/
|
*/
|
||||||
public Chart() {
|
public Chart() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
/*
|
||||||
String stockSymbol = "Schliemanz Koch AG";
|
String stockSymbol = "Schliemanz Koch AG";
|
||||||
//String stockSymbol = "MSFT";
|
//String stockSymbol = "MSFT";
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainWin.se.addQuoteReceiver(this);
|
MainWin.se.addQuoteReceiver(this);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,12 +94,25 @@
|
|||||||
</Constraint>
|
</Constraint>
|
||||||
</Constraints>
|
</Constraints>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="gui.Chart" name="zZChart1">
|
<Container class="chart.Chart" name="chart1">
|
||||||
<Constraints>
|
<Constraints>
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||||
<BorderConstraints direction="Center"/>
|
<BorderConstraints direction="Center"/>
|
||||||
</Constraint>
|
</Constraint>
|
||||||
</Constraints>
|
</Constraints>
|
||||||
</Component>
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<EmptySpace min="0" pref="241" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<EmptySpace min="0" pref="582" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
@ -69,7 +69,7 @@ public class MainWin extends javax.swing.JFrame {
|
|||||||
jMenuItem1 = new javax.swing.JMenuItem();
|
jMenuItem1 = new javax.swing.JMenuItem();
|
||||||
controlPanel2 = new gui.ControlPanel();
|
controlPanel2 = new gui.ControlPanel();
|
||||||
orderBookPanel1 = new gui.OrderBookPanel();
|
orderBookPanel1 = new gui.OrderBookPanel();
|
||||||
zZChart1 = new gui.Chart();
|
chart1 = new chart.Chart();
|
||||||
MainMenu = new javax.swing.JMenuBar();
|
MainMenu = new javax.swing.JMenuBar();
|
||||||
FileMenu = new javax.swing.JMenu();
|
FileMenu = new javax.swing.JMenu();
|
||||||
FileNew = new javax.swing.JMenuItem();
|
FileNew = new javax.swing.JMenuItem();
|
||||||
@ -89,7 +89,19 @@ public class MainWin extends javax.swing.JFrame {
|
|||||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||||
getContentPane().add(controlPanel2, java.awt.BorderLayout.LINE_END);
|
getContentPane().add(controlPanel2, java.awt.BorderLayout.LINE_END);
|
||||||
getContentPane().add(orderBookPanel1, java.awt.BorderLayout.LINE_START);
|
getContentPane().add(orderBookPanel1, java.awt.BorderLayout.LINE_START);
|
||||||
getContentPane().add(zZChart1, java.awt.BorderLayout.CENTER);
|
|
||||||
|
javax.swing.GroupLayout chart1Layout = new javax.swing.GroupLayout(chart1);
|
||||||
|
chart1.setLayout(chart1Layout);
|
||||||
|
chart1Layout.setHorizontalGroup(
|
||||||
|
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 241, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
chart1Layout.setVerticalGroup(
|
||||||
|
chart1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 582, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
|
||||||
|
getContentPane().add(chart1, java.awt.BorderLayout.CENTER);
|
||||||
|
|
||||||
FileMenu.setBackground(new java.awt.Color(254, 203, 1));
|
FileMenu.setBackground(new java.awt.Color(254, 203, 1));
|
||||||
FileMenu.setText("File");
|
FileMenu.setText("File");
|
||||||
@ -214,11 +226,11 @@ public class MainWin extends javax.swing.JFrame {
|
|||||||
private javax.swing.JMenuItem FileNew;
|
private javax.swing.JMenuItem FileNew;
|
||||||
private javax.swing.JMenuItem FileRun;
|
private javax.swing.JMenuItem FileRun;
|
||||||
private javax.swing.JMenuBar MainMenu;
|
private javax.swing.JMenuBar MainMenu;
|
||||||
|
private chart.Chart chart1;
|
||||||
private gui.ControlPanel controlPanel2;
|
private gui.ControlPanel controlPanel2;
|
||||||
private javax.swing.JButton jButton1;
|
private javax.swing.JButton jButton1;
|
||||||
private javax.swing.JMenu jMenu2;
|
private javax.swing.JMenu jMenu2;
|
||||||
private javax.swing.JMenuItem jMenuItem1;
|
private javax.swing.JMenuItem jMenuItem1;
|
||||||
private gui.OrderBookPanel orderBookPanel1;
|
private gui.OrderBookPanel orderBookPanel1;
|
||||||
private gui.Chart zZChart1;
|
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
@ -249,18 +249,18 @@ public class Exchange extends Thread {
|
|||||||
|
|
||||||
long nextQuoteId = 0;
|
long nextQuoteId = 0;
|
||||||
|
|
||||||
public void OrderMatching() {
|
private void executeOrders() {
|
||||||
|
|
||||||
while (true) {
|
while (!bid.isEmpty() && !ask.isEmpty()) {
|
||||||
|
|
||||||
if (bid.isEmpty() || ask.isEmpty()) {
|
|
||||||
// nothing to do
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Order b = bid.first();
|
Order b = bid.first();
|
||||||
Order a = ask.first();
|
Order a = ask.first();
|
||||||
|
|
||||||
|
if (b.limit < a.limit) {
|
||||||
|
// no match, nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (a.volume == 0) {
|
if (a.volume == 0) {
|
||||||
// This order is fully executed, remove
|
// This order is fully executed, remove
|
||||||
a.account.orderpending = false;
|
a.account.orderpending = false;
|
||||||
@ -283,14 +283,11 @@ public class Exchange extends Thread {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.limit < a.limit) {
|
|
||||||
// no match, nothing to do
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.limit >= a.limit) {
|
if (b.limit >= a.limit) {
|
||||||
double price;
|
double price;
|
||||||
|
|
||||||
|
price = b.id<a.id ? b.limit : a.limit;
|
||||||
|
|
||||||
if (b.id < a.id) {
|
if (b.id < a.id) {
|
||||||
price = b.limit;
|
price = b.limit;
|
||||||
} else {
|
} else {
|
||||||
@ -389,7 +386,7 @@ public class Exchange extends Thread {
|
|||||||
o.id = orderid++;
|
o.id = orderid++;
|
||||||
addOrder(o);
|
addOrder(o);
|
||||||
o.account.pending.add(o);
|
o.account.pending.add(o);
|
||||||
OrderMatching();
|
executeOrders();
|
||||||
tradelock.unlock();
|
tradelock.unlock();
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
@ -405,7 +402,7 @@ public class Exchange extends Thread {
|
|||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
Lock();
|
Lock();
|
||||||
// OrderMatching();
|
// executeOrders();
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user