From e87f8a4a00a1cf56c79a067b8f115988a911bae1 Mon Sep 17 00:00:00 2001 From: David Pang Date: Mon, 23 Sep 2024 13:00:42 -0400 Subject: [PATCH] updated all dependency versions and relevant api usage. bumped java to 21 --- pom.xml | 417 +++++++++--------- ta4j-core/pom.xml | 10 +- ta4j-examples/pom.xml | 8 +- .../analysis/BuyAndSellSignalsToChart.java | 6 +- .../analysis/CashFlowToChart.java | 11 +- .../indicators/CandlestickChart.java | 6 +- .../CandlestickChartWithChopIndicator.java | 6 +- .../indicators/IndicatorsToChart.java | 8 +- .../ta4jexamples/loaders/CsvBarsLoader.java | 35 +- .../ta4jexamples/loaders/CsvTradesLoader.java | 25 +- 10 files changed, 268 insertions(+), 264 deletions(-) diff --git a/pom.xml b/pom.xml index f408a9a0..13f2635c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,210 +1,213 @@ - 4.0.0 - org.ta4j - ta4j-parent - 0.16-CF - pom - - Ta4j Parent - ta4j is a Java library providing a simple API for technical analysis. - http://github.com/ta4j/ta4j - 2014 - - - - Marc de Verdelhan - - - Simon-Justus Wimmer - - - - - - MIT License - All source code is under the MIT license. - - - - - GitHub - http://github.com/ta4j/ta4j/issues - - - - - sonatype-nexus-snapshots - Sonatype Nexus snapshot repository - https://oss.sonatype.org/content/repositories/snapshots - - - sonatype-nexus-staging - Sonatype Nexus release repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - http://travis-ci.org/ta4j/ta4j - - - - scm:git:git://github.com/ta4j/ta4j.git - scm:git:git@github.com:ta4j/ta4j.git - http://github.com/ta4j/ta4j - 0.14 - - - - ta4j-core - ta4j-examples - - - - - UTF-8 - UTF-8 - - - - - - ch.qos.logback - logback-classic - 1.2.3 - - - - - - - - - sonatype-oss-release - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - true - - - https://oss.sonatype.org/ - - sonatype-nexus-staging - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - none - - - - attach-javadocs - - jar - - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - 17 - 17 - true - true - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - - - com.mycila - license-maven-plugin - 3.0 - -
LICENSE
- - **/*.java - -
-
- - - - net.revelc.code.formatter - formatter-maven-plugin - 2.10.0 - - ${project.basedir}/code-formatter.xml - - - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.1 - - @{project.version} - - - - org.apache.maven.shared - maven-invoker - 2.2 - - - - -
-
+ 4.0.0 + org.ta4j + ta4j-parent + 0.16-CF + pom + + Ta4j Parent + ta4j is a Java library providing a simple API for technical analysis. + http://github.com/ta4j/ta4j + 2014 + + + + mdeverdelhan + Marc de Verdelhan + + + team172011 + Simon-Justus Wimmer + + + + + + MIT License + All source code is under the MIT license. + + + + + GitHub + http://github.com/TheCookieLab/ta4j/issues + + + + + sonatype-nexus-snapshots + Sonatype Nexus snapshot repository + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + Sonatype Nexus release repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + http://travis-ci.org/TheCookieLab/ta4j + + + + scm:git:git://github.com/TheCookieLab/ta4j.git + scm:git:git@github.com:TheCookieLab/ta4j.git + http://github.com/TheCookieLab/ta4j + 0.16-CF + + + + ta4j-core + ta4j-examples + + + + + UTF-8 + UTF-8 + + + + + + ch.qos.logback + logback-classic + 1.5.6 + + + + + + + + + sonatype-oss-release + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.7.0 + true + + + https://oss.sonatype.org/ + + sonatype-nexus-staging + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.8.0 + + none + + + + attach-javadocs + + jar + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.6 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + 21 + 21 + true + true + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + + + com.mycila + license-maven-plugin + 4.5 + +
LICENSE
+ + **/*.java + +
+
+ + + + net.revelc.code.formatter + formatter-maven-plugin + 2.10.0 + + ${project.basedir}/code-formatter.xml + + + + + + org.apache.maven.plugins + maven-release-plugin + 3.1.1 + + @{project.version} + + + + org.apache.maven.shared + maven-invoker + 3.3.0 + + + + +
+
diff --git a/ta4j-core/pom.xml b/ta4j-core/pom.xml index 4132618c..5f163ffb 100644 --- a/ta4j-core/pom.xml +++ b/ta4j-core/pom.xml @@ -16,14 +16,14 @@ org.slf4j slf4j-api - 1.7.25 + 2.0.13 junit junit - 4.13.1 + 4.13.2 test @@ -35,7 +35,7 @@ org.apache.poi poi - 5.2.2 + 5.3.0 test @@ -49,7 +49,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.1.0 + 3.4.1 ${project.build.outputDirectory}/META-INF/MANIFEST.MF @@ -59,7 +59,7 @@ biz.aQute.bnd bnd-maven-plugin - 3.3.0 + 6.4.0 default-bnd-process diff --git a/ta4j-examples/pom.xml b/ta4j-examples/pom.xml index 2b31d00a..9e7539f3 100644 --- a/ta4j-examples/pom.xml +++ b/ta4j-examples/pom.xml @@ -16,7 +16,7 @@ junit junit - 4.13.1 + 4.13.2 test @@ -29,13 +29,13 @@ com.opencsv opencsv - 3.9 + 5.9 org.jfree jfreechart - 1.0.17 + 1.5.5 @@ -46,7 +46,7 @@ com.google.code.gson gson - 2.8.6 + 2.10.1 diff --git a/ta4j-examples/src/main/java/ta4jexamples/analysis/BuyAndSellSignalsToChart.java b/ta4j-examples/src/main/java/ta4jexamples/analysis/BuyAndSellSignalsToChart.java index 09139f18..eb20bc08 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/analysis/BuyAndSellSignalsToChart.java +++ b/ta4j-examples/src/main/java/ta4jexamples/analysis/BuyAndSellSignalsToChart.java @@ -36,10 +36,10 @@ import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.ui.ApplicationFrame; +import org.jfree.chart.ui.UIUtils; import org.jfree.data.time.Minute; import org.jfree.data.time.TimeSeriesCollection; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; import org.ta4j.core.Bar; import org.ta4j.core.BarSeries; import org.ta4j.core.BarSeriesManager; @@ -125,7 +125,7 @@ private static void displayChart(JFreeChart chart) { ApplicationFrame frame = new ApplicationFrame("Ta4j example - Buy and sell signals to chart"); frame.setContentPane(panel); frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); + UIUtils.centerFrameOnScreen(frame); frame.setVisible(true); } diff --git a/ta4j-examples/src/main/java/ta4jexamples/analysis/CashFlowToChart.java b/ta4j-examples/src/main/java/ta4jexamples/analysis/CashFlowToChart.java index fdb0c769..95eca5de 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/analysis/CashFlowToChart.java +++ b/ta4j-examples/src/main/java/ta4jexamples/analysis/CashFlowToChart.java @@ -35,10 +35,11 @@ import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; +import org.jfree.chart.ui.ApplicationFrame; +import org.jfree.chart.ui.UIUtils; import org.jfree.data.time.Minute; import org.jfree.data.time.TimeSeriesCollection; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; + import org.ta4j.core.Bar; import org.ta4j.core.BarSeries; import org.ta4j.core.BarSeriesManager; @@ -62,7 +63,7 @@ public class CashFlowToChart { * * @param barSeries the ta4j bar series * @param indicator the indicator - * @param name the name of the chart time series + * @param name the name of the chart time series * @return the JFreeChart time series */ private static org.jfree.data.time.TimeSeries buildChartBarSeries(BarSeries barSeries, Indicator indicator, @@ -79,7 +80,7 @@ private static org.jfree.data.time.TimeSeries buildChartBarSeries(BarSeries barS /** * Adds the cash flow axis to the plot. * - * @param plot the plot + * @param plot the plot * @param dataset the cash flow dataset */ private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) { @@ -108,7 +109,7 @@ private static void displayChart(JFreeChart chart) { ApplicationFrame frame = new ApplicationFrame("Ta4j example - Cash flow to chart"); frame.setContentPane(panel); frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); + UIUtils.centerFrameOnScreen(frame); frame.setVisible(true); } diff --git a/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChart.java b/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChart.java index 2b5cd2bc..dce83736 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChart.java +++ b/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChart.java @@ -34,12 +34,12 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.CandlestickRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.ui.ApplicationFrame; +import org.jfree.chart.ui.UIUtils; import org.jfree.data.time.Second; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.DefaultHighLowDataset; import org.jfree.data.xy.OHLCDataset; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; import org.ta4j.core.Bar; import org.ta4j.core.BarSeries; import org.ta4j.core.indicators.helpers.ClosePriceIndicator; @@ -114,7 +114,7 @@ private static void displayChart(JFreeChart chart) { ApplicationFrame frame = new ApplicationFrame("Ta4j example - Candlestick chart"); frame.setContentPane(panel); frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); + UIUtils.centerFrameOnScreen(frame); frame.setVisible(true); } diff --git a/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChartWithChopIndicator.java b/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChartWithChopIndicator.java index b050b82c..c4ba2d52 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChartWithChopIndicator.java +++ b/ta4j-examples/src/main/java/ta4jexamples/indicators/CandlestickChartWithChopIndicator.java @@ -40,13 +40,13 @@ import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.CandlestickRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.ui.ApplicationFrame; +import org.jfree.chart.ui.UIUtils; import org.jfree.data.time.Second; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.DefaultHighLowDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; import org.ta4j.core.Bar; import org.ta4j.core.BarSeries; import org.ta4j.core.indicators.ChopIndicator; @@ -201,7 +201,7 @@ private static void displayChart(XYDataset ohlcDataset, XYDataset xyDataset, XYD ApplicationFrame frame = new ApplicationFrame("Ta4j example - Candlestick chart"); frame.setContentPane(combinedChartPanel); frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); + UIUtils.centerFrameOnScreen(frame); frame.setVisible(true); // CHOP oscillator upper/lower threshold guidelines diff --git a/ta4j-examples/src/main/java/ta4jexamples/indicators/IndicatorsToChart.java b/ta4j-examples/src/main/java/ta4jexamples/indicators/IndicatorsToChart.java index b2093cac..42d757d0 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/indicators/IndicatorsToChart.java +++ b/ta4j-examples/src/main/java/ta4jexamples/indicators/IndicatorsToChart.java @@ -31,10 +31,10 @@ import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.ui.ApplicationFrame; +import org.jfree.chart.ui.UIUtils; import org.jfree.data.time.Day; import org.jfree.data.time.TimeSeriesCollection; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; import org.ta4j.core.Bar; import org.ta4j.core.BarSeries; import org.ta4j.core.Indicator; @@ -58,7 +58,7 @@ public class IndicatorsToChart { * * @param barSeries the ta4j bar series * @param indicator the indicator - * @param name the name of the chart time series + * @param name the name of the chart time series * @return the JFreeChart time series */ private static org.jfree.data.time.TimeSeries buildChartBarSeries(BarSeries barSeries, Indicator indicator, @@ -86,7 +86,7 @@ private static void displayChart(JFreeChart chart) { ApplicationFrame frame = new ApplicationFrame("Ta4j example - Indicators to chart"); frame.setContentPane(panel); frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); + UIUtils.centerFrameOnScreen(frame); frame.setVisible(true); } diff --git a/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvBarsLoader.java b/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvBarsLoader.java index e4e218e2..cba1853f 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvBarsLoader.java +++ b/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvBarsLoader.java @@ -23,10 +23,10 @@ */ package ta4jexamples.loaders; +import com.opencsv.CSVParserBuilder; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.Charset; import java.time.LocalDate; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -38,6 +38,9 @@ import org.ta4j.core.BaseBarSeries; import com.opencsv.CSVReader; +import com.opencsv.CSVReaderBuilder; +import com.opencsv.exceptions.CsvValidationException; +import java.nio.charset.StandardCharsets; /** * This class build a Ta4j bar series from a CSV file containing bars. @@ -59,18 +62,26 @@ public static BarSeries loadCsvSeries(String filename) { BarSeries series = new BaseBarSeries("apple_bars"); - try (CSVReader csvReader = new CSVReader(new InputStreamReader(stream, Charset.forName("UTF-8")), ',', '"', - 1)) { - String[] line; - while ((line = csvReader.readNext()) != null) { - ZonedDateTime date = LocalDate.parse(line[0], DATE_FORMAT).atStartOfDay(ZoneId.systemDefault()); - double open = Double.parseDouble(line[1]); - double high = Double.parseDouble(line[2]); - double low = Double.parseDouble(line[3]); - double close = Double.parseDouble(line[4]); - double volume = Double.parseDouble(line[5]); + try { + assert stream != null; + try (CSVReader csvReader = new CSVReaderBuilder(new InputStreamReader(stream, StandardCharsets.UTF_8)) + .withCSVParser(new CSVParserBuilder().withSeparator(',').build()) + .withSkipLines(1) + .build()) { + String[] line; + while ((line = csvReader.readNext()) != null) { + ZonedDateTime date = LocalDate.parse(line[0], DATE_FORMAT).atStartOfDay(ZoneId.systemDefault()); + double open = Double.parseDouble(line[1]); + double high = Double.parseDouble(line[2]); + double low = Double.parseDouble(line[3]); + double close = Double.parseDouble(line[4]); + double volume = Double.parseDouble(line[5]); - series.addBar(date, open, high, low, close, volume); + series.addBar(date, open, high, low, close, volume); + } + } catch (CsvValidationException e) { + Logger.getLogger(CsvBarsLoader.class.getName()) + .log(Level.SEVERE, "Unable to load bars from CSV. File is not valid csv.", e); } } catch (IOException ioe) { Logger.getLogger(CsvBarsLoader.class.getName()).log(Level.SEVERE, "Unable to load bars from CSV", ioe); diff --git a/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvTradesLoader.java b/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvTradesLoader.java index 2553f94a..9ee649f0 100644 --- a/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvTradesLoader.java +++ b/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvTradesLoader.java @@ -23,10 +23,8 @@ */ package ta4jexamples.loaders; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.Charset; import java.time.Duration; import java.time.Instant; import java.time.ZoneId; @@ -56,22 +54,13 @@ public static BarSeries loadBitstampSeries() { // Reading all lines of the CSV file InputStream stream = CsvTradesLoader.class.getClassLoader() .getResourceAsStream("bitstamp_trades_from_20131125_usd.csv"); - CSVReader csvReader = null; List lines = null; - try { - csvReader = new CSVReader(new InputStreamReader(stream, Charset.forName("UTF-8")), ','); + assert stream != null; + try (CSVReader csvReader = new com.opencsv.CSVReader(new InputStreamReader(stream))) { lines = csvReader.readAll(); lines.remove(0); // Removing header line - } catch (IOException ioe) { + } catch (Exception ioe) { Logger.getLogger(CsvTradesLoader.class.getName()).log(Level.SEVERE, "Unable to load trades from CSV", ioe); - } finally { - if (csvReader != null) { - try { - csvReader.close(); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } } BarSeries series = new BaseBarSeries(); @@ -104,9 +93,9 @@ public static BarSeries loadBitstampSeries() { * Builds a list of populated bars from csv data. * * @param beginTime the begin time of the whole period - * @param endTime the end time of the whole period - * @param duration the bar duration (in seconds) - * @param lines the csv data returned by CSVReader.readAll() + * @param endTime the end time of the whole period + * @param duration the bar duration (in seconds) + * @param lines the csv data returned by CSVReader.readAll() */ @SuppressWarnings("deprecation") private static void buildSeries(BarSeries series, ZonedDateTime beginTime, ZonedDateTime endTime, int duration, @@ -155,4 +144,4 @@ public static void main(String[] args) { System.out.println("First bar: \n" + "\tVolume: " + series.getBar(0).getVolume() + "\n" + "\tNumber of trades: " + series.getBar(0).getTrades() + "\n" + "\tClose price: " + series.getBar(0).getClosePrice()); } -} \ No newline at end of file +}