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() {
|
||||
initComponents();
|
||||
|
||||
/*
|
||||
String stockSymbol = "Schliemanz Koch AG";
|
||||
//String stockSymbol = "MSFT";
|
||||
|
||||
@ -102,7 +102,7 @@ public class Chart extends javax.swing.JPanel implements QuoteReceiver {
|
||||
}
|
||||
|
||||
MainWin.se.addQuoteReceiver(this);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,12 +94,25 @@
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="gui.Chart" name="zZChart1">
|
||||
<Container class="chart.Chart" name="chart1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</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>
|
||||
</Form>
|
@ -69,7 +69,7 @@ public class MainWin extends javax.swing.JFrame {
|
||||
jMenuItem1 = new javax.swing.JMenuItem();
|
||||
controlPanel2 = new gui.ControlPanel();
|
||||
orderBookPanel1 = new gui.OrderBookPanel();
|
||||
zZChart1 = new gui.Chart();
|
||||
chart1 = new chart.Chart();
|
||||
MainMenu = new javax.swing.JMenuBar();
|
||||
FileMenu = new javax.swing.JMenu();
|
||||
FileNew = new javax.swing.JMenuItem();
|
||||
@ -89,7 +89,19 @@ public class MainWin extends javax.swing.JFrame {
|
||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||
getContentPane().add(controlPanel2, java.awt.BorderLayout.LINE_END);
|
||||
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.setText("File");
|
||||
@ -214,11 +226,11 @@ public class MainWin extends javax.swing.JFrame {
|
||||
private javax.swing.JMenuItem FileNew;
|
||||
private javax.swing.JMenuItem FileRun;
|
||||
private javax.swing.JMenuBar MainMenu;
|
||||
private chart.Chart chart1;
|
||||
private gui.ControlPanel controlPanel2;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JMenu jMenu2;
|
||||
private javax.swing.JMenuItem jMenuItem1;
|
||||
private gui.OrderBookPanel orderBookPanel1;
|
||||
private gui.Chart zZChart1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -249,18 +249,18 @@ public class Exchange extends Thread {
|
||||
|
||||
long nextQuoteId = 0;
|
||||
|
||||
public void OrderMatching() {
|
||||
private void executeOrders() {
|
||||
|
||||
while (true) {
|
||||
|
||||
if (bid.isEmpty() || ask.isEmpty()) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
while (!bid.isEmpty() && !ask.isEmpty()) {
|
||||
|
||||
Order b = bid.first();
|
||||
Order a = ask.first();
|
||||
|
||||
if (b.limit < a.limit) {
|
||||
// no match, nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.volume == 0) {
|
||||
// This order is fully executed, remove
|
||||
a.account.orderpending = false;
|
||||
@ -283,14 +283,11 @@ public class Exchange extends Thread {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (b.limit < a.limit) {
|
||||
// no match, nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
if (b.limit >= a.limit) {
|
||||
double price;
|
||||
|
||||
price = b.id<a.id ? b.limit : a.limit;
|
||||
|
||||
if (b.id < a.id) {
|
||||
price = b.limit;
|
||||
} else {
|
||||
@ -389,7 +386,7 @@ public class Exchange extends Thread {
|
||||
o.id = orderid++;
|
||||
addOrder(o);
|
||||
o.account.pending.add(o);
|
||||
OrderMatching();
|
||||
executeOrders();
|
||||
tradelock.unlock();
|
||||
|
||||
return o;
|
||||
@ -405,7 +402,7 @@ public class Exchange extends Thread {
|
||||
|
||||
Unlock();
|
||||
Lock();
|
||||
// OrderMatching();
|
||||
// executeOrders();
|
||||
Unlock();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user