Moved ohls_data from Exchange to Stock class
This commit is contained in:
parent
6b2d382f8b
commit
11fec6e022
@ -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=
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -144,7 +144,7 @@ public class Exchange {
|
||||
public void orderUpdated(Order o);
|
||||
}
|
||||
|
||||
HashMap<Integer, OHLCData> ohlc_data = new HashMap<>();
|
||||
//HashMap<Integer, OHLCData> 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<OHLCData> it = ohlc_data.values().iterator();
|
||||
void updateOHLCData(Stock stock,Quote q) {
|
||||
Iterator<OHLCData> 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);
|
||||
}
|
||||
|
||||
|
@ -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<Quote> quoteHistory; // = new TreeSet<>();
|
||||
|
||||
HashMap<Integer, OHLCData> ohlc_data = new HashMap<>();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user