diff --git a/nbproject/project.properties b/nbproject/project.properties index 54118b8..923f673 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Sun, 10 Dec 2017 18:25:56 +0100 +#Sun, 10 Dec 2017 18:46:05 +0100 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/chart/MasterChart.java b/src/chart/MasterChart.java index 64d46f7..3cc6ca1 100644 --- a/src/chart/MasterChart.java +++ b/src/chart/MasterChart.java @@ -150,7 +150,7 @@ public class MasterChart extends javax.swing.JPanel implements QuoteReceiver { this.yLegend.setChartDef(chartDef); ChartPainter p; - mydata = Globals.se.getOHLCdata(60000 * 20); + mydata = Globals.se.getOHLCdata(Globals.se.getDefaultStock(),60000 * 20); this.xScrollBar.setMaximum(0); diff --git a/src/gui/MainChart.java b/src/gui/MainChart.java index f54ddb4..ea5a173 100644 --- a/src/gui/MainChart.java +++ b/src/gui/MainChart.java @@ -122,7 +122,7 @@ setCursor(new MyCursor(Cursor.CROSSHAIR_CURSOR)); protected final void setCompression0(int timeFrame) { javax.swing.SwingUtilities.invokeLater(() -> { - data = Globals.se.getOHLCdata(timeFrame); + data = Globals.se.getOHLCdata(Globals.se.getDefaultStock(),timeFrame); invalidate(); repaint(); }); diff --git a/src/sesim/Exchange.java b/src/sesim/Exchange.java index b813a6a..8f3661f 100644 --- a/src/sesim/Exchange.java +++ b/src/sesim/Exchange.java @@ -144,7 +144,7 @@ public class Exchange { public void orderUpdated(Order o); } - HashMap ohlc_data = new HashMap<>(); + //HashMap ohlc_data = new HashMap<>(); public OHLCData buildOHLCData(int timeFrame) { Stock stock = getDefaultStock(); @@ -193,21 +193,21 @@ public class Exchange { } - public OHLCData getOHLCdata(Integer timeFrame) { + public OHLCData getOHLCdata(Stock stock,Integer timeFrame) { OHLCData data; - data = ohlc_data.get(timeFrame); + data = stock.ohlc_data.get(timeFrame); if (data == null) { synchronized (executor) { data = this.buildOHLCData(timeFrame); - ohlc_data.put(timeFrame, data); + stock.ohlc_data.put(timeFrame, data); } } return data; } - void updateOHLCData(Quote q) { - Iterator it = ohlc_data.values().iterator(); + void updateOHLCData(Stock stock,Quote q) { + Iterator it = stock.ohlc_data.values().iterator(); while (it.hasNext()) { OHLCData data = it.next(); data.realTimeAdd(q.time, (float) q.price, (float) q.volume); @@ -319,7 +319,7 @@ public class Exchange { statistics = new Statistics(); //num_trades = 0; - this.ohlc_data = new HashMap(); + // getDefaultStock().ohlc_data = new HashMap(); // Create order books @@ -917,7 +917,7 @@ public class Exchange { Stock stock = getDefaultStock(); stock.quoteHistory.add(q); - updateOHLCData(q); + updateOHLCData(stock,q); updateQuoteReceivers(q); } diff --git a/src/sesim/Stock.java b/src/sesim/Stock.java index 10ffb16..ed38b1e 100644 --- a/src/sesim/Stock.java +++ b/src/sesim/Stock.java @@ -57,6 +57,7 @@ public class Stock { } quoteHistory = new TreeSet(); + ohlc_data = new HashMap(); } String getSymbol() { @@ -75,4 +76,6 @@ public class Stock { */ public TreeSet quoteHistory; // = new TreeSet<>(); + HashMap ohlc_data = new HashMap<>(); + }