real time update mechanism for the chart #647
Replies: 6 comments 8 replies
-
By the way, to accomplish #641, I was able to conduct substantial modification on several classes relevant to which seems enough to resolve issue (1) and hopefully can resolve (2) as well in the near future. Understand real-time update mechanism seems one of the very few (two~three) bottlenecks remaining to fully finish #641 |
Beta Was this translation helpful? Give feedback.
-
Class new SimpleOhlcvDailyParser().getContinuousOHLCV(data);
// look to this method
convertTsRowStream()
// and
DefaultOHLCV Next important classes for you for realtime processing of ohlcv data. SimpleOhlcvReplayDataSet
SCIDByNio.createTickDataReplayStream()
// creates ohlcv tick data processing provider
TickOhlcvDataProvider
de.gsi.financial.samples.service.SimpleOhlcvReplayDataSet#fillTestData
de.gsi.financial.samples.service.SimpleOhlcvReplayDataSet#tick About timeframe consolidation, you can look here OhlcvTimeframeConsolidation
// there are next examples of consolidations
RangeBarsIncrementalOhlcvConsolidation
VolumeIncrementalOhlcvConsolidation Could you provide a hand-drawn example of the chart you're aiming for? I'm having trouble grasping the specifics of your goal from the description. Thanks. |
Beta Was this translation helpful? Give feedback.
-
how to put code to get chart updated while
|
Beta Was this translation helpful? Give feedback.
-
@yezhengli-Mr9 Can you provide more information about your application and what you are trying to achieve? That will make it easier to recommend something.
You should also learn about the JavaFX threading model. Architecture.md has a small summary about the individual phases. In general you can only update the chart from the JavaFX thread. Datasets have some built-in support for concurrent updates, but for low-latency applications with small updates it may make sense to do something more custom. |
Beta Was this translation helpful? Give feedback.
-
Try to combine @raven2cz 's hints on
replayDataSet.addOhlcvChangeListener(ohlcvItem -> FXUtils.runFX(() -> {
Interval<Calendar> timeRangeInt =null,ttInt=null;
Calendar replayFromCal=null;
try{
timeRangeInt = CalendarUtils.createByDateTimeInterval(timeRange);
ttInt = CalendarUtils.createByTimeInterval(tt);
replayFromCal = CalendarUtils.createByDateTime(replayFrom);
}catch(ParseException pe){
pe.printStackTrace();
}
replayDataSet.fillTestData(period,
timeRangeInt,
ttInt, replayFromCal, consolidationAddons);
closeIndicator.setMarkerValue(ohlcvItem.getClose());
})); instead of 2. try {
getStreamChartDataSetUpdate(symbolSignal, 1, null, 1, "Minute", true,
ohlcvDataSet,indiSet,
title, chart);
}catch(IOException | ParseException e){
e.printStackTrace();
} where within BufferedReader responseReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((line = responseReader.readLine()) != null) {
if (TokenResponse.aboutToExpire(tokenResponse, lagSeconds)) {
tokenResponse = Credential.getAccessToken();
continue;
}
if (!line.isEmpty()) {
// Assuming you have a JSONObject class for parsing JSON
Bar b = Bar.readBarFromJsonString(line, symbol);
System.out.println("[getStreamBarchartQuotes]" + b);
if (b == null) {
System.out.println("barList.size()\t" + barList.size() + ":\n" + barList.get(barList.size() - 1));
continue;
}
if (barList.size() == 0) {
barList.add(b);
// update the chart
} else {
long diff = Util.calculateTimeDiffSecUTC(b.getTimeStamp(), barList.get(barList.size() - 1).getTimeStamp());
if (diff > 30) {
barList.add(b);
/*
* here is part to ohlcvDataSet.setData(...) new data
*/
Thread.sleep(20000); // try to sleep 20 seconds to provide chart enough time to update/refresh
// update the chart
} else {
barList.set(barList.size() - 1, b);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(connection.getResponseCode());
System.out.println(connection.getErrorStream());
System.out.println(connection.getInputStream());
} Will try more later today, tomorrow or later this week.
|
Beta Was this translation helpful? Give feedback.
-
Resolved. |
Beta Was this translation helpful? Give feedback.
-
For #641, try to figure out real time update mechanism for the chart suitable for
chart-fx/chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/financial/CandleStickRenderer.java
Line 105 in ed86318
for example,
(1a) incremental update?
(1b) need to integrate with real-time streaming data.
(2) Do not feel these financial examples are (updated) real time since they do not update the similar to
chart-fx/chartfx-samples/src/main/java/io/fair_acc/sample/chart/Histogram2DimSample.java
Lines 138 to 144 in ed86318
likely because these "real-time" financial examples are not handling streaming(-like) data but calling
loadTestData(...)
insteadchart-fx/chartfx-samples/src/main/java/io/fair_acc/sample/financial/AbstractBasicFinancialApplication.java
Lines 207 to 215 in ed86318
Need real-time update of daily minute-level financial charts.
Beta Was this translation helpful? Give feedback.
All reactions