├── .classpath ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── LICENSE ├── MANIFEST.MF ├── README.md ├── build.xml ├── docs ├── _config.yml └── index.md ├── js ├── ariva.js ├── finanzennet.js ├── overview.html └── portfolioreport.js ├── lib ├── apache-commons-csv │ ├── LICENSE-header.txt │ ├── LICENSE.txt │ ├── NOTICE.txt │ └── commons-csv-1.0-SNAPSHOT.jar ├── htmlunit-2.45 │ ├── commons-codec-1.11.jar │ ├── commons-io-2.8.0.jar │ ├── commons-lang3-3.11.jar │ ├── commons-logging-1.2.jar │ ├── commons-net-3.7.2.jar │ ├── commons-text-1.9.jar │ ├── dec-0.1.2.jar │ ├── httpclient-4.5.13.jar │ ├── httpcore-4.4.13.jar │ ├── httpmime-4.5.13.jar │ ├── jetty-client-9.4.34.v20201102.jar │ ├── jetty-http-9.4.34.v20201102.jar │ ├── jetty-io-9.4.34.v20201102.jar │ ├── jetty-util-9.4.34.v20201102.jar │ ├── salvation2-3.0.0.jar │ ├── serializer-2.7.2.jar │ ├── websocket-api-9.4.34.v20201102.jar │ ├── websocket-client-9.4.34.v20201102.jar │ ├── websocket-common-9.4.34.v20201102.jar │ ├── xalan-2.7.2.jar │ ├── xercesImpl-2.12.0.jar │ └── xml-apis-1.4.01.jar ├── org.htmlunit │ ├── htmlunit-3.2.0.jar │ ├── htmlunit-core-js-3.2.0.jar │ ├── htmlunit-cssparser-3.2.0.jar │ ├── htmlunit-xpath-3.2.0.jar │ └── neko-htmlunit-3.2.0.jar └── rhino │ └── rhino-1.7.14.jar ├── src ├── jsq │ ├── config │ │ ├── Config.java │ │ └── ConfigTuple.java │ ├── datastructes │ │ ├── Const.java │ │ └── Datacontainer.java │ ├── fetch │ │ └── factory │ │ │ └── Factory.java │ ├── fetcher │ │ └── history │ │ │ ├── BaseFetcher.java │ │ │ ├── GenericJSFetcher.java │ │ │ └── Yahoo.java │ └── tools │ │ ├── CsvTools.java │ │ ├── CurrencyTools.java │ │ ├── HtmlUnitTools.java │ │ └── VarTools.java └── label.txt └── tests ├── AllJSTests.java ├── TestJS.java └── TestYahoo.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | /bin 14 | /build 15 | 16 | # Visual Studio 17 | /.vs 18 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaStockQuotes 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.validation.validationbuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.wst.jsdt.core.jsNature 22 | 23 | 24 | 25 | 1631144860308 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.release=disabled 8 | org.eclipse.jdt.core.compiler.source=1.8 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License, Version 2.0 2 | http://opensource.org/licenses/Apache-2.0 -------------------------------------------------------------------------------- /MANIFEST.MF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/MANIFEST.MF -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JavaStockQuotes 2 | =============== 3 | 4 | Java libary for fetching historical stock quotes. 5 | 6 | It supports JavaScript Plugins to add more sources. 7 | 8 | The information are returned as a List of Datacontainer (HashMap) 9 | 10 | Used Labels for Quotes: 11 | 12 | |Name | Description | Java Class | Format | 13 | | --- | --- | --- | --- | 14 | | date|Date |Date 15 | | first|First Price |BigDecimal 16 | | last| Last Price |BigDecimal 17 | | low | Lowest trade| BigDecimal 18 | | high | Highest trade |BigDecimal 19 | | currency | Currency | String | three letter code, see ISO 4217 20 | 21 | Used Labels for Events: 22 | 23 | |Name | Description | Java Class | Format | 24 | | --- | --- | --- | --- | 25 | | date|Date |Date | 26 | | ratio| Split Ratio | String | x:y (e.g. "8:7") 27 | | value| | BigDecimal 28 | | currency | Currency |String|three letter code, see ISO 4217 29 | | action | | String | See jsq.datastructes.Const for Strings 30 | 31 | 32 | # Referenzen 33 | Diese Bibliothek wird verwendet vom [Hibiscus Depot Viewer](https://github.com/littleyoda/hibiscus.depotviewer). -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Demonstrate the use of the Ant build tool with a simple Java project. 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Application: ${app.name} ${app.version} 49 | Build File : ${ant.file} 50 | Run Date : ${build.time} 51 | Run by : ${user.name} 52 | Build Dir : ${build} 53 | Base Dir : ${basedir} 54 | Java Home : ${java.home} 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | Classpath: ${toString:compile.classpath} 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 118 | 119 | 120 |
${app.name} ${app.version}]]>
121 |
122 |
123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 150 | Finished creating all build artifacts. 151 | 152 | 153 |
-------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Verfügbare Plugins / Available plugins 2 | 3 | ## Ariva.de 4 | 5 | - Unter https://ariva.de einen neuen Benutzer-Account registrieren. Kurse sind nicht mehr ohne Registrierung abrufbar. 6 | 7 | - [ariva.js](https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/master/js/ariva.js) (zuletzt geändert 19.12.2024) 8 | herunterladen und unter Windows speichern unter 9 | `C:\Users\{USERNAME}\.jameica\hibiscus.depotviewer\js` 10 | Unter Linux das entsprechende Benutzer-Verzeichnis wählen. 11 | 12 | - Die heruntergeladene Datei `ariva.js` in einem Texteditor öffnen. Die folgenden beiden Zeilen suchen und jeweils 13 | `MeinUserName` und `MeinPasswort` durch die eigenen Werte ersetzen und speichern. 14 | ```js 15 | var ArivaUserName = "MeinUserName"; // Hier Username eintragen 16 | var ArivaUserPasswort = "MeinPasswort"; // Hier Passwort eintragen 17 | ``` 18 | - Jameica neu starten 19 | 20 | ## Finanzen.net 21 | 22 | - [finanzennet.js](https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/master/js/finanzennet.js) (zuletzt geändert 18.01.2025) 23 | herunterladen und unter Windows speichern unter 24 | `C:\Users\{USERNAME}\.jameica\hibiscus.depotviewer\js` 25 | Unter Linux das entsprechende Benutzer-Verzeichnis wählen. 26 | 27 | - Jameica neu starten 28 | 29 | ## PortfolioReport 30 | 31 | - [portfolioreport.js](https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/master/js/portfolioreport.js) (zuletzt geändert 18.01.2025) 32 | herunterladen und unter Windows speichern unter 33 | `C:\Users\{USERNAME}\.jameica\hibiscus.depotviewer\js` 34 | Unter Linux das entsprechende Benutzer-Verzeichnis wählen. 35 | 36 | - Jameica neu starten 37 | 38 | Danke an [b3nn0](https://github.com/b3nn0) für den PortfolioReport code. 39 | -------------------------------------------------------------------------------- /js/ariva.js: -------------------------------------------------------------------------------- 1 | // Script for Hibiscus Depot Viewer 2 | // Updated 05.10.2022 by @faiteanu 3 | // Original version by @mikekorb 4 | // Hotfix 21.03.2023 Karl Heesch 5 | // Hotfix 07.03.2024 @gnampf1 6 | // Hotfix 19.12.2024 by @faiteanu 7 | 8 | var ArivaUserName = "MeinUserName"; // Hier Username eintragen 9 | var ArivaUserPasswort = "MeinPasswort"; // Hier Passwort eintragen 10 | 11 | var Logger = Packages.de.willuhn.logging.Logger; 12 | var ArrayList = java.util.ArrayList; 13 | 14 | var fetcher; 15 | var webClient; 16 | var url; 17 | var kursUrl; 18 | var secu; // KH: zugefügt 19 | 20 | var y1,m1,d1,y2,m2,d2; 21 | 22 | function getAPIVersion() { 23 | return "1"; 24 | }; 25 | 26 | function getVersion() { 27 | return "2024-04-04"; 28 | }; 29 | 30 | function getName() { 31 | return "Ariva"; 32 | }; 33 | 34 | function getURL() { 35 | return "http://www.ariva.de"; 36 | }; 37 | 38 | function prepare(fetch, search, startyear, startmon, startday, stopyear, stopmon, stopday) { 39 | fetcher = fetch; 40 | y1 = startyear; m1 = startmon; d1 = startday; 41 | y2 = stopyear; m2 = stopmon; d2 = stopday; 42 | 43 | webClient = fetcher.getWebClient(false); 44 | url = getURL(); 45 | 46 | try { 47 | page = webClient.getPage(url + "/user/login/?ref=Lw=="); 48 | form = page.getHtmlElementById("kc-form-login"); 49 | form.getInputByName("username").type(ArivaUserName); 50 | form.getInputByName("password").type(ArivaUserPasswort); 51 | page = page.getHtmlElementById("submit").click(); 52 | } catch (error) { 53 | Logger.info("Error on Login: " + error); 54 | Logger.info("Page war " + page.asXml()); 55 | } 56 | 57 | var cfgliste = new ArrayList(); 58 | 59 | 60 | page = webClient.getPage(url + "/search/livesearch.m?searchname=" + search); 61 | 62 | secu = page.getContent().match(/ 0) { 81 | var cfg = new Packages.jsq.config.Config("Handelsplatz"); 82 | for (i = 0; i < options.size(); i++) { 83 | cfg.addAuswahl(options.get(i), new String("handelsplatz")); 84 | } 85 | cfgliste.add(cfg); 86 | } 87 | 88 | // Währung 89 | options = getLinksForSelection("waehrung", page); 90 | if (options.size() > 0) { 91 | var cfg = new Packages.jsq.config.Config("Währung"); 92 | for (i = 0; i < options.size(); i++) { 93 | if (options.get(i).includes("wählen")) { 94 | continue; 95 | } 96 | cfg.addAuswahl(options.get(i), new String("waehrung")); 97 | } 98 | cfgliste.add(cfg); 99 | } 100 | 101 | } 102 | return cfgliste; 103 | }; 104 | 105 | function process(config) { 106 | print("Processing"); 107 | var defaultcur = "EUR"; 108 | var handelsplatz = ""; 109 | var boerse_id=""; 110 | var currency_id=""; 111 | //var secu = ""; 112 | 113 | for (i = 0; i < config.size(); i++) { 114 | var cfg = config.get(i); 115 | for (j = 0; j < cfg.getSelected().size(); j++) { 116 | var o = cfg.getSelected().get(j); 117 | if (o.getObj().toString().equals("waehrung")) { 118 | defaultcur = o.toString(); 119 | var found = 0; 120 | 121 | select = getSelect(o.getObj(), page); 122 | optionslist = select.getOptions(); 123 | for (var k = 0; k < optionslist.size(); k++) { 124 | var option = optionslist.get(k); 125 | if (option.getText().trim().equals(o.toString())) { 126 | print("Selecting " + option.getText()); 127 | currency_id = option.getValueAttribute(); 128 | option.setSelected(true); 129 | found = 1; 130 | } 131 | } 132 | if (found == 0) { 133 | print("Warnung: Link für " + o.getObj() + " nicht gefunden!"); 134 | } 135 | } else if (o.getObj().toString().equals("handelsplatz")) { 136 | handelsplatz = o.toString(); 137 | var found = 0; 138 | 139 | select = getSelect(o.getObj(), page); 140 | optionslist = select.getOptions(); 141 | for (var k = 0; k < optionslist.size(); k++) { 142 | var option = optionslist.get(k); 143 | if (option.getText().trim().equals(o.toString())) { 144 | print("Selecting " + option.getText()); 145 | boerse_id= option.getValueAttribute(); 146 | option.setSelected(true); 147 | found = 1; 148 | } 149 | } 150 | if (found == 0) { 151 | print("Warnung: Link für " + o.getObj() + " nicht gefunden!"); 152 | } 153 | } 154 | } 155 | } 156 | if (boerse_id){ 157 | //var histUrl= getURL() + "/quote/historic/historic.csv?secu=" + Packages.jsq.tools.HtmlUnitTools.getFirstElementByXpath(page, "//input[@name='secu']").getValueAttribute() 158 | var histUrl= getURL() + "/quote/historic/historic.csv?secu=" + secu // KH: Zeile geändert 159 | + "&boerse_id=" + boerse_id + "&clean_split=0&clean_payout=0&clean_bezug=0¤cy=" + currency_id + "&min_time=" + d1 + "." + m1 + "." + y1 160 | +"&max_time=" + d2 + "." + m2 + "." + y2 + "&trenner=%3B&go=Download"; 161 | print(histUrl); 162 | text = webClient.getPage(histUrl); 163 | defaultcur = Packages.jsq.tools.CurrencyTools.correctCurrency(defaultcur); 164 | evalCSV(text.getContent(), defaultcur); 165 | } 166 | extractEvents(page, handelsplatz); 167 | 168 | }; 169 | 170 | 171 | function extractEvents(page, handelsplatz) { 172 | 173 | var dict = {}; 174 | dict["Gratisaktien"] = Packages.jsq.datastructes.Const.STOCKDIVIDEND; 175 | dict["Dividende"] = Packages.jsq.datastructes.Const.CASHDIVIDEND; 176 | dict["Ausschüttung"] = Packages.jsq.datastructes.Const.CASHDIVIDEND; 177 | dict["Split"] = Packages.jsq.datastructes.Const.STOCKSPLIT; 178 | dict["Allg. Korrektur"] = Packages.jsq.datastructes.Const.STOCKSPLIT; 179 | dict["Reverse Split"] = Packages.jsq.datastructes.Const.STOCKREVERSESPLIT; 180 | dict["Bezugsrecht"] = Packages.jsq.datastructes.Const.SUBSCRIPTIONRIGHTS; 181 | 182 | if(kursUrl.indexOf("secu=") > 0){ 183 | // fonds use a different URL from shares 184 | eventUrl = getURL() + "/quote/kapitalmassnahmen.m?clean_split=0&" + kursUrl.substring(kursUrl.indexOf("secu=")); 185 | }else{ 186 | eventUrl = url + "/dividende-split/?clean_split=0"; 187 | } 188 | 189 | print(eventUrl); 190 | page = webClient.getPage(eventUrl); 191 | tab = Packages.jsq.tools.HtmlUnitTools.getElementByPartContent(page, "Datum", "table"); 192 | list = Packages.jsq.tools.HtmlUnitTools.analyse(tab); 193 | 194 | var res = new ArrayList(); 195 | for (i = 0; i < list.size(); i++) { 196 | hashmap = list.get(i); 197 | if (hashmap.get("Ereignis") == "Euro-Umstellung") { 198 | continue; 199 | } 200 | 201 | // filter date range 202 | d = Packages.jsq.tools.VarTools.parseDate(hashmap.get("Datum"), "dd.MM.yy"); 203 | if (!fetcher.within(d)) { 204 | continue; 205 | } 206 | 207 | // filter events with neither ratio nor amount 208 | if ((hashmap.get("Verhältnis") == null || hashmap.get("Verhältnis").trim() == "") && (hashmap.get("Betrag") == null || hashmap.get("Betrag") == "")) { 209 | continue; 210 | } 211 | 212 | var dc = new Packages.jsq.datastructes.Datacontainer(); 213 | // Teilweise unterscheiden sich die Termine nach Handelsplätzen 214 | if (hashmap.get("Handelsplätze") != null && hashmap.get("Handelsplätze") != "") { 215 | hp = java.util.Arrays.asList(hashmap.get("Handelsplätze").split(", ")) 216 | if (!hp.contains(handelsplatz)) { 217 | // Nicht unser Handelsplatz 218 | continue; 219 | } 220 | } 221 | dc.put("date", d); 222 | var ratio = hashmap.get("Verhältnis"); 223 | if(ratio !== undefined && ratio.trim() !== "" && ratio.indexOf(":") < 0){ 224 | // convert float to ratio with colon 225 | ratio = Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(ratio).toString() + ":1"; 226 | } 227 | dc.put("ratio", ratio); 228 | action = dict[hashmap.get("Ereignis")]; 229 | if (typeof action === "undefined") { 230 | print("Undef für " + hashmap); 231 | } 232 | dc.put("action", action); 233 | cur = null; 234 | amount = null; 235 | if (hashmap.get("Betrag") != null && hashmap.get("Betrag") != "") { 236 | betrag = hashmap.get("Betrag").split(" "); 237 | amount = Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(betrag[0]); 238 | cur = betrag[1]; 239 | } 240 | dc.put("value", amount); 241 | dc.put("currency", cur); 242 | res.add(dc); 243 | } 244 | fetcher.setHistEvents(res); 245 | 246 | } 247 | 248 | 249 | 250 | function evalCSV(content, defaultcur) { 251 | var records = Packages.jsq.tools.CsvTools.getRecordsFromCsv(";", content); 252 | var res = new ArrayList(); 253 | for (i = 0; i < records.size(); i++) { 254 | var record = records.get(i); 255 | var dc = new Packages.jsq.datastructes.Datacontainer(); 256 | dc.put("date", Packages.jsq.tools.VarTools.parseDate(record.get("Datum"), "yyyy-MM-dd")); 257 | dc.put("first", Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(record.get("Erster"))); 258 | dc.put("last", Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(record.get("Schlusskurs"))); 259 | dc.put("low", Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(record.get("Tief"))); 260 | dc.put("high", Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(record.get("Hoch"))); 261 | dc.put("currency", defaultcur); 262 | res.add(dc); 263 | } 264 | print(records.size() + " Kurse geladen"); 265 | fetcher.setHistQuotes(res); 266 | } 267 | 268 | function getSelect(search, page) { 269 | return page.getFirstByXPath("//select[contains(@class, '" + search + "')]"); 270 | } 271 | 272 | function getLinksForSelection(search, page) { 273 | var ret = new ArrayList(); 274 | select = getSelect(search, page); 275 | if (select) { 276 | optionslist = select.getOptions(); 277 | for (var i = 0; i < optionslist.size(); i++) { 278 | var div = optionslist.get(i); 279 | content = div.getText().trim(); 280 | ret.add(content); 281 | } 282 | } 283 | return ret; 284 | } 285 | 286 | function extractBasisdata(page) { 287 | var dc = new Packages.jsq.datastructes.Datacontainer(); 288 | 289 | wkn = Packages.jsq.tools.HtmlUnitTools.getElementByPartContent(page, "WKN:", "div"); 290 | wkn && dc.put("wkn", wkn.getTextContent().trim().split(" ")[1]); 291 | 292 | isin = Packages.jsq.tools.HtmlUnitTools.getElementByPartContent(page, "ISIN:", "div"); 293 | isin && dc.put("isin", isin.getTextContent().split(" ")[1]); 294 | 295 | name = Packages.jsq.tools.HtmlUnitTools.getFirstElementByXpath(page, "//h1"); 296 | name && dc.put("name", name.getTextContent().trim()); 297 | fetcher.setStockDetails(dc); 298 | } 299 | 300 | -------------------------------------------------------------------------------- /js/finanzennet.js: -------------------------------------------------------------------------------- 1 | // Script for Hibiscus Depot Viewer 2 | // Updated 03.01.2025 by @dirkhe 3 | // Updated 18.01.2025 by @dirkhe - Logging added 4 | 5 | var ArrayList = java.util.ArrayList; 6 | 7 | var fetcher; 8 | var wc; 9 | var boerseSelect; 10 | var searchButton; 11 | //var tablePath; 12 | 13 | function getAPIVersion() { 14 | return "1"; 15 | } 16 | 17 | function getVersion() { 18 | return "2025-01-18"; 19 | } 20 | 21 | function getDate(year, month, day) { 22 | return new java.util.Date(year - 1900, month - 1, day); 23 | } 24 | 25 | function getURL() { 26 | return "http://www.finanzen.net"; 27 | } 28 | 29 | function getName() { 30 | return "Finanzen.net"; 31 | } 32 | 33 | function prepare( 34 | fetch, 35 | search, 36 | startyear, 37 | startmon, 38 | startday, 39 | stopyear, 40 | stopmon, 41 | stopday 42 | ) { 43 | fetcher = fetch; 44 | 45 | wc = fetcher.getWebClient(true); 46 | wc.getOptions().setThrowExceptionOnFailingStatusCode(false); 47 | Packages.de.willuhn.logging.Logger.debug("load http://www.finanzen.net/suchergebnis.asp?frmAktiensucheTextfeld=" + search); 48 | page = wc.getPage( 49 | "http://www.finanzen.net/suchergebnis.asp?frmAktiensucheTextfeld=" + search 50 | ); 51 | 52 | try { 53 | Packages.de.willuhn.logging.Logger.debug("suche Link Kurse"); 54 | links = page.getAnchorByText("Kurse"); 55 | page = links.click(); 56 | Packages.de.willuhn.logging.Logger.debug("suche Select historic-prices-stock-market"); 57 | boerseSelect = page.getElementById("historic-prices-stock-market"); 58 | Packages.de.willuhn.logging.Logger.debug("suche Button request-historic-price"); 59 | searchButton = page.getElementById("request-historic-price"); 60 | 61 | input = page.getElementById("fromDate"); 62 | input.setValue(input.getMin()); 63 | 64 | input = page.getElementById("toDate"); 65 | input.setValue(input.getMax()); 66 | } catch (e) { 67 | try { 68 | Packages.de.willuhn.logging.Logger.debug("suche Link historische Kurse"); 69 | links = page.getAnchorByText("Historische Kurse"); 70 | page = links.click(); 71 | } catch (error) { 72 | Packages.de.willuhn.logging.Logger.debug("suche Link Kurse & Realtime"); 73 | links = page.getAnchorByText("Kurse & Realtime"); 74 | page = links.click(); 75 | Packages.de.willuhn.logging.Logger.debug("suche Link historische Kurse"); 76 | links = page.getAnchorByText("Historische Kurse"); 77 | page = links.click(); 78 | } 79 | Packages.de.willuhn.logging.Logger.debug("suche Select strBoerse"); 80 | boerseSelect = page.getElementByName("strBoerse"); 81 | Packages.de.willuhn.logging.Logger.debug("suche search-Button"); 82 | searchButton = boerseSelect.getFirstByXPath("../../div/button"); 83 | 84 | input = page.getElementByName("dtDate1"); 85 | input.setValue(input.getMin()); 86 | 87 | input = page.getElementByName("dtDate2"); 88 | input.setValue(input.getMax()); 89 | } 90 | 91 | var liste = new ArrayList(); 92 | if (!page) { 93 | Packages.de.willuhn.logging.Logger.error("Konnte Kurse Link nicht finden"); 94 | } else { 95 | // Handelsplätze extrahieren 96 | 97 | var cfg = new Packages.jsq.config.Config("Handelsplatz"); 98 | var listeHandelsplaetze = boerseSelect.getOptions(); // List of HtmlOption 99 | for (var i = 0; i < listeHandelsplaetze.size(); i++) { 100 | var platz = listeHandelsplaetze.get(i); 101 | cfg.addAuswahl(platz.getText(), platz.getValueAttribute()); 102 | } 103 | liste.add(cfg); 104 | } 105 | 106 | 107 | return liste; 108 | } 109 | 110 | function process(config) { 111 | var res = new ArrayList(); 112 | var currency = "EUR"; 113 | var boerse = ""; 114 | for (i = 0; i < config.size(); i++) { 115 | var cfg = config.get(i); 116 | for (j = 0; j < cfg.getSelected().size(); j++) { 117 | var o = cfg.getSelected().get(j); 118 | if (cfg.getBeschreibung().equals("Handelsplatz")) { 119 | boerse = o.getObj().toString(); 120 | } /* else if (cfg.getBeschreibung().equals("waehrung")) { 121 | currency = o.getObj().toString(); 122 | }*/ 123 | } 124 | } 125 | 126 | if (!boerseSelect) { 127 | Packages.de.willuhn.logging.Logger.error("Börsenauswahl nicht gefunden"); 128 | } else { 129 | option = boerseSelect.getOptionByValue(boerse); 130 | boerseSelect.setSelectedAttribute(option, true); 131 | } 132 | 133 | page = searchButton.click(); 134 | wc.waitForBackgroundJavaScript(10000); 135 | tab = Packages.jsq.tools.HtmlUnitTools.getTableByPartContent(page, "Datum"); 136 | if (!tab) { 137 | Packages.de.willuhn.logging.Logger.error("Börsenauswahl nicht gefunden"); 138 | } else { 139 | list = Packages.jsq.tools.HtmlUnitTools.analyse(tab); 140 | Packages.de.willuhn.logging.Logger.info(list.size() + " Kurse gefunden"); 141 | 142 | 143 | for (i = 0; i < list.size(); i++) { 144 | try { 145 | hashmap = list.get(i); 146 | last = hashmap.get("Schluss"); 147 | if (!last || last.equals("-")) { 148 | // happens for the current day 149 | continue; 150 | } 151 | var dc = new Packages.jsq.datastructes.Datacontainer(); 152 | dc.put( 153 | "date", 154 | Packages.jsq.tools.VarTools.parseDate( 155 | hashmap.get("Datum"), 156 | "dd.MM.yyyy" 157 | ) 158 | ); 159 | dc.put( 160 | "first", 161 | Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat( 162 | hashmap.get("Eröffnung") || "" 163 | ) 164 | ); 165 | dc.put( 166 | "last", 167 | Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat(last) 168 | ); 169 | dc.put( 170 | "low", 171 | Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat( 172 | hashmap.get("Tagestief") || "" 173 | ) 174 | ); 175 | dc.put( 176 | "high", 177 | Packages.jsq.tools.VarTools.stringToBigDecimalGermanFormat( 178 | hashmap.get("Tageshoch") || "" 179 | ) 180 | ); 181 | dc.put("currency", currency); 182 | res.add(dc); 183 | } catch (error) { 184 | Packages.de.willuhn.logging.Logger.error("Fehler beim Kurse auslesen: " + error + "\n" + hashmap); 185 | } 186 | } 187 | } 188 | fetcher.setHistQuotes(res); 189 | } 190 | 191 | function search(fetch, search) { 192 | fetcher = fetch; 193 | 194 | wc = fetcher.getWebClient(true); 195 | page = wc.getPage( 196 | "http://www.finanzen.net/suchergebnis.asp?frmAktiensucheTextfeld=" + search 197 | ); 198 | } -------------------------------------------------------------------------------- /js/overview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Verfügbare Plugins / Available plugins

4 | For website ariva.de: Download (updated 21.03.2023)
5 | 6 |

Installation to Hibiscus Depot-Viewer

7 |

Save file ariva.js in folder C:\Users\<username>\.jameica\hibiscus.depotviewer\js and restart Jameica.

8 | 9 | 10 | -------------------------------------------------------------------------------- /js/portfolioreport.js: -------------------------------------------------------------------------------- 1 | // Script for Hibiscus Depot Viewer 2 | // Original version by b3nn0 3 | // Updated 17.12.2024 by dirkhe and faiteanu 4 | // Updated 18.01.2025 by dirkhe 5 | 6 | var ArrayList = java.util.ArrayList; 7 | var Logger = Packages.de.willuhn.logging.Logger; 8 | 9 | var fetcher; 10 | var webClient; 11 | 12 | 13 | var s,y1,m1,d1,y2,m2,d2; 14 | 15 | function getAPIVersion() { 16 | return "1"; 17 | }; 18 | 19 | function getVersion() { 20 | return "2025-01-18"; 21 | }; 22 | 23 | function getName() { 24 | return "PortfolioReport"; 25 | }; 26 | 27 | function getURL() { 28 | return "https://www.portfolio-report.net/"; 29 | }; 30 | 31 | 32 | 33 | function prepare(fetch, search, startyear, startmon, startday, stopyear, stopmon, stopday) { 34 | Logger.info("prepare..."); 35 | fetcher = fetch; 36 | s = search; 37 | y1 = startyear; m1 = startmon; d1 = startday; 38 | y2 = stopyear; m2 = stopmon; d2 = stopday; 39 | 40 | var cfgliste = new ArrayList(); 41 | 42 | // Währung 43 | var currencies = new Packages.jsq.config.Config("Waehrung"); 44 | currencies.addAuswahl("EUR", new String("waehrung")); 45 | currencies.addAuswahl("USD", new String("waehrung")); 46 | 47 | cfgliste.add(currencies); 48 | 49 | return cfgliste; 50 | } 51 | 52 | function process(config) { 53 | Logger.info("process..."); 54 | var currency = "EUR"; 55 | for (i = 0; i < config.size(); i++) { 56 | var cfg = config.get(i); 57 | for (j = 0; j < cfg.getSelected().size(); j++) { 58 | var o = cfg.getSelected().get(j); 59 | if (cfg.getBeschreibung().equals("waehrung")) { 60 | currency = o.toString(); 61 | } 62 | } 63 | } 64 | 65 | var webClient = fetcher.getWebClient(false); 66 | 67 | var page = webClient.getPage("https://api.portfolio-report.net/v1/securities/search?q=" + s); 68 | var json = JSON.parse(page.getWebResponse().getContentAsString()); 69 | var uuid = json[0]["uuid"]; 70 | 71 | var startDate = new Date(y1, m1, d1); 72 | 73 | var start = startDate.toISOString().substring(0, 10); 74 | page = webClient.getPage("https://api.portfolio-report.net/securities/uuid/" + uuid + "/prices/" + currency + "?from=" + start); 75 | var jsondata = page.getWebResponse().getContentAsString(); 76 | 77 | var data = JSON.parse(jsondata); 78 | 79 | var res = new ArrayList(); 80 | for (var i = 0; i < data.length; i++) { 81 | var price = data[i]; 82 | var dc = new Packages.jsq.datastructes.Datacontainer(); 83 | dc.put("currency", currency); 84 | dc.put("date", Packages.jsq.tools.VarTools.parseDate(price["date"], "yyyy-MM-dd")); 85 | dc.put("last", Packages.jsq.tools.VarTools.stringToBigDecimal(price["close"])); 86 | 87 | //dc.put("first", Packages.jsq.tools.VarTools.stringToBigDecimal(record.get("Open"))); 88 | //dc.put("last", Packages.jsq.tools.VarTools.stringToBigDecimal(price["close"])); 89 | //dc.put("low", Packages.jsq.tools.VarTools.stringToBigDecimal(record.get("Low"))); 90 | //dc.put("high", Packages.jsq.tools.VarTools.stringToBigDecimal(record.get("High"))); 91 | //dc.put("currency", defaultcur); 92 | res.add(dc); 93 | } 94 | fetcher.setHistQuotes(res); 95 | } 96 | -------------------------------------------------------------------------------- /lib/apache-commons-csv/LICENSE-header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | -------------------------------------------------------------------------------- /lib/apache-commons-csv/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /lib/apache-commons-csv/NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Commons CSV 2 | Copyright 2005-2014 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | src/main/resources/contract.txt 8 | This file was downloaded from http://www.ferc.gov/docs-filing/eqr/soft-tools/sample-csv/contract.txt and contains neither copyright notice nor license. 9 | 10 | src/main/resources/transaction.txt 11 | This file was downloaded from http://www.ferc.gov/docs-filing/eqr/soft-tools/sample-csv/transaction.txt and contains neither copyright notice nor license. 12 | -------------------------------------------------------------------------------- /lib/apache-commons-csv/commons-csv-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/apache-commons-csv/commons-csv-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/commons-codec-1.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/commons-codec-1.11.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/commons-io-2.8.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/commons-io-2.8.0.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/commons-lang3-3.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/commons-lang3-3.11.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/commons-logging-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/commons-logging-1.2.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/commons-net-3.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/commons-net-3.7.2.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/commons-text-1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/commons-text-1.9.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/dec-0.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/dec-0.1.2.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/httpclient-4.5.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/httpclient-4.5.13.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/httpcore-4.4.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/httpcore-4.4.13.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/httpmime-4.5.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/httpmime-4.5.13.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/jetty-client-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/jetty-client-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/jetty-http-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/jetty-http-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/jetty-io-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/jetty-io-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/jetty-util-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/jetty-util-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/salvation2-3.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/salvation2-3.0.0.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/serializer-2.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/serializer-2.7.2.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/websocket-api-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/websocket-api-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/websocket-client-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/websocket-client-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/websocket-common-9.4.34.v20201102.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/websocket-common-9.4.34.v20201102.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/xalan-2.7.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/xalan-2.7.2.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/xercesImpl-2.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/xercesImpl-2.12.0.jar -------------------------------------------------------------------------------- /lib/htmlunit-2.45/xml-apis-1.4.01.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/htmlunit-2.45/xml-apis-1.4.01.jar -------------------------------------------------------------------------------- /lib/org.htmlunit/htmlunit-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/org.htmlunit/htmlunit-3.2.0.jar -------------------------------------------------------------------------------- /lib/org.htmlunit/htmlunit-core-js-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/org.htmlunit/htmlunit-core-js-3.2.0.jar -------------------------------------------------------------------------------- /lib/org.htmlunit/htmlunit-cssparser-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/org.htmlunit/htmlunit-cssparser-3.2.0.jar -------------------------------------------------------------------------------- /lib/org.htmlunit/htmlunit-xpath-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/org.htmlunit/htmlunit-xpath-3.2.0.jar -------------------------------------------------------------------------------- /lib/org.htmlunit/neko-htmlunit-3.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/org.htmlunit/neko-htmlunit-3.2.0.jar -------------------------------------------------------------------------------- /lib/rhino/rhino-1.7.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faiteanu/JavaStockQuotes/f0a84296fe6225235e7eaf94409c629576512741/lib/rhino/rhino-1.7.14.jar -------------------------------------------------------------------------------- /src/jsq/config/Config.java: -------------------------------------------------------------------------------- 1 | package jsq.config; 2 | import java.util.ArrayList; 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | 7 | 8 | public class Config { 9 | private List auswahlen; 10 | private String beschreibung; 11 | 12 | private List selectedOptions; 13 | 14 | public Config(String beschreibung) { 15 | auswahlen = new ArrayList(); 16 | selectedOptions = new ArrayList(); 17 | this.beschreibung = beschreibung; 18 | } 19 | 20 | public String getBeschreibung() { 21 | return beschreibung; 22 | } 23 | 24 | public void addAuswahl(ConfigTuple s) { 25 | auswahlen.add(s); 26 | }; 27 | 28 | public void addAuswahl(String description, Object s) { 29 | auswahlen.add(new ConfigTuple(description, s)); 30 | }; 31 | 32 | public void addSelectedOptions(ConfigTuple opt) { 33 | selectedOptions.add(opt); 34 | } 35 | 36 | 37 | public List getOptions() { 38 | return Collections.unmodifiableList(auswahlen); 39 | } 40 | 41 | public List getSelected() { 42 | return Collections.unmodifiableList(selectedOptions); 43 | } 44 | 45 | public String toString() { 46 | return beschreibung + ": " + auswahlen + " / " + selectedOptions; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/jsq/config/ConfigTuple.java: -------------------------------------------------------------------------------- 1 | package jsq.config; 2 | 3 | public class ConfigTuple { 4 | private final String description; 5 | private final Object obj; 6 | 7 | public String getDescription() { 8 | return description; 9 | } 10 | 11 | public Object getObj() { 12 | return obj; 13 | } 14 | 15 | public ConfigTuple(String desc, Object obj) { 16 | this.description = desc; 17 | this.obj = obj; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return description; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /src/jsq/datastructes/Const.java: -------------------------------------------------------------------------------- 1 | package jsq.datastructes; 2 | 3 | public class Const { 4 | 5 | final static public String SUBSCRIPTIONRIGHTS = "Subscription Rights"; 6 | 7 | final static public String CASHDIVIDEND = "Cash Dividend"; 8 | 9 | final static public String STOCKSPLIT = "Stock Split"; 10 | 11 | final static public String STOCKREVERSESPLIT = "Stock Reverse Split"; 12 | 13 | final static public String STOCKDIVIDEND = "Stock Dividend"; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/jsq/datastructes/Datacontainer.java: -------------------------------------------------------------------------------- 1 | package jsq.datastructes; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Datacontainer { 7 | 8 | public Map data; 9 | 10 | public Datacontainer() { 11 | data = new HashMap(); 12 | } 13 | 14 | public Datacontainer(Map data) { 15 | this.data = data; 16 | } 17 | 18 | public void put(String key, Object value) { 19 | data.put(key, value); 20 | } 21 | 22 | public String toString() { 23 | return data.entrySet().toString(); 24 | } 25 | 26 | public Map getMap() { 27 | return data; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/jsq/fetch/factory/Factory.java: -------------------------------------------------------------------------------- 1 | package jsq.fetch.factory; 2 | 3 | import java.net.InetSocketAddress; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.htmlunit.ProxyConfig; 8 | 9 | import jsq.fetcher.history.BaseFetcher; 10 | import jsq.fetcher.history.GenericJSFetcher; 11 | import jsq.fetcher.history.Yahoo; 12 | 13 | public class Factory { 14 | 15 | private static ProxyConfig pc; 16 | 17 | private static List historylist; 18 | 19 | public synchronized static List getHistoryFetcher() { 20 | if (historylist == null) { 21 | historylist = new ArrayList(); 22 | historylist.add(new Yahoo()); 23 | } 24 | return historylist; 25 | } 26 | 27 | public synchronized static void setProxy(String host, int port) { 28 | pc = new ProxyConfig(); 29 | pc.setProxyHost(host); 30 | pc.setProxyPort(port); 31 | } 32 | 33 | public synchronized static ProxyConfig getProxyConfig() { 34 | return pc; 35 | } 36 | 37 | public synchronized static void addJSFetcher(String string) throws Exception { 38 | if (historylist == null) { 39 | getHistoryFetcher(); 40 | } 41 | historylist.add(new GenericJSFetcher(string)); 42 | } 43 | 44 | public synchronized static void addJavaFetcher(BaseFetcher n) { 45 | List liste = getHistoryFetcher(); 46 | liste.add(n); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/jsq/fetcher/history/BaseFetcher.java: -------------------------------------------------------------------------------- 1 | package jsq.fetcher.history; 2 | import java.util.Date; 3 | import java.util.List; 4 | 5 | import jsq.config.Config; 6 | import jsq.datastructes.Datacontainer; 7 | 8 | 9 | public abstract class BaseFetcher { 10 | 11 | 12 | private List resultEvents; 13 | private List resultQuotes; 14 | private Datacontainer stockDetails; 15 | 16 | public Datacontainer getStockDetails() { 17 | return stockDetails; 18 | } 19 | 20 | public void setStockDetails(Datacontainer stockDetails) { 21 | this.stockDetails = stockDetails; 22 | } 23 | 24 | private List options = null; 25 | protected Date startdate; 26 | protected Date stopdate; 27 | 28 | public abstract String getName(); 29 | 30 | public abstract String getURL(); 31 | 32 | 33 | @SuppressWarnings("deprecation") 34 | public void prepare(String search, int beginYear, int beginMon, int beginDay, int stopYear, int stopMon, int stopDay) throws Exception { 35 | reset(); 36 | startdate = new Date(beginYear-1900, beginMon - 1, beginDay); 37 | stopdate = new Date(stopYear-1900, stopMon - 1, stopDay); 38 | } 39 | 40 | 41 | public boolean hasMoreConfig() { 42 | return options != null; 43 | } 44 | 45 | public List getConfigs() { 46 | if (options == null) { 47 | throw new IllegalStateException("No Configs found!"); 48 | } 49 | return options; 50 | } 51 | 52 | public void process(List options) { 53 | setConfig(null); 54 | } 55 | 56 | protected void setConfig(List options) { 57 | this.options = options; 58 | } 59 | 60 | 61 | protected void reset() { 62 | options = null; 63 | startdate = null; 64 | stopdate = null; 65 | resultQuotes = null; 66 | resultEvents = null; 67 | stockDetails = null; 68 | } 69 | 70 | public List getHistQuotes() { 71 | return resultQuotes; 72 | } 73 | 74 | public void setHistQuotes(List res) { 75 | resultQuotes = res; 76 | } 77 | 78 | 79 | 80 | public List getHistEvents() { 81 | return resultEvents; 82 | } 83 | 84 | public void setHistEvents(List resultEvents) { 85 | this.resultEvents = resultEvents; 86 | } 87 | 88 | public String toString() { 89 | return getName(); 90 | } 91 | 92 | public Date getStartdate() { 93 | return startdate; 94 | } 95 | 96 | public Date getStopdate() { 97 | return stopdate; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/jsq/fetcher/history/GenericJSFetcher.java: -------------------------------------------------------------------------------- 1 | package jsq.fetcher.history; 2 | 3 | import java.io.File; 4 | import java.io.FileReader; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | import org.htmlunit.SilentCssErrorHandler; 10 | import org.htmlunit.ThreadedRefreshHandler; 11 | import org.htmlunit.WebClient; 12 | import org.mozilla.javascript.Context; 13 | import org.mozilla.javascript.Function; 14 | import org.mozilla.javascript.NativeJavaObject; 15 | import org.mozilla.javascript.Scriptable; 16 | import org.mozilla.javascript.ScriptableObject; 17 | 18 | import jsq.config.Config; 19 | import jsq.fetch.factory.Factory; 20 | 21 | public class GenericJSFetcher extends BaseFetcher { 22 | private Calendar start; 23 | private Calendar stop; 24 | 25 | private Scriptable scope; 26 | 27 | private File scriptFile; 28 | private long modifiedTs; 29 | 30 | /** 31 | * Create a new generic fetcher from the JavaScript file passed in {@code filename}. 32 | * @param filename 33 | * @throws Exception 34 | */ 35 | public GenericJSFetcher(String filename) throws Exception { 36 | try { 37 | this.scriptFile = new File(filename); 38 | reloadScriptIfNeeded(); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | throw e; 42 | } 43 | } 44 | 45 | private Context enterContext() { 46 | Context context = Context.enter(); 47 | context.setLanguageVersion(Context.VERSION_ES6); 48 | context.setOptimizationLevel(-1); 49 | context.getWrapFactory().setJavaPrimitiveWrap(false); 50 | return context; 51 | } 52 | 53 | private void reloadScriptIfNeeded() throws Exception { 54 | if (scriptFile.lastModified() == modifiedTs) 55 | return; 56 | modifiedTs = scriptFile.lastModified(); 57 | 58 | Context context = enterContext(); 59 | 60 | scope = context.initStandardObjects(); 61 | Object jsFetcher = Context.javaToJS(this, scope); 62 | ScriptableObject.putProperty(scope, "fetcher", jsFetcher); 63 | 64 | 65 | // print function is not part of default rhino 66 | context.evaluateString(scope, "function print() { " 67 | + "Packages.jsq.fetcher.history.GenericJSFetcher.print(Array.from(arguments).map((x) => x.toString()).join(' '))" 68 | + "}", "", 1, null); 69 | 70 | FileReader reader = new FileReader(scriptFile); 71 | context.evaluateReader(scope, reader, scriptFile.getName(), 1, null); 72 | 73 | context.exit(); 74 | } 75 | 76 | public static void print(Object o) { 77 | System.out.println(o.toString()); 78 | } 79 | 80 | @Override 81 | public String getName() { 82 | return (String) callFunc("getName", null); 83 | } 84 | 85 | @Override 86 | public String getURL() { 87 | return (String) callFunc("getURL", null); 88 | } 89 | 90 | public String getAPIVersion() { 91 | return (String) callFunc("getAPIVersion", null); 92 | } 93 | public String getVersion() { 94 | return (String) callFunc("getVersion", null); 95 | } 96 | 97 | @Override 98 | public void prepare(String search, int beginYear, int beginMon, 99 | int beginDay, int stopYear, int stopMon, int stopDay) throws Exception { 100 | reloadScriptIfNeeded(); 101 | 102 | super.prepare(search, beginYear, beginMon, beginDay, stopYear, stopMon, stopDay); 103 | start = Calendar.getInstance(); 104 | start.setTime(getStartdate()); 105 | stop = Calendar.getInstance(); 106 | stop.setTime(getStopdate()); 107 | try { 108 | Object x = callFunc("prepare", new Object[] { this, search, beginYear, beginMon, beginDay, stopYear, stopMon, stopDay }); 109 | setConfig((List) x); 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | throw e; 113 | } 114 | } 115 | 116 | 117 | @Override 118 | public void process(List options) { 119 | super.process(options); 120 | try { 121 | callFunc("process", new Object[] { options} ); 122 | } catch (Exception e) { 123 | // TODO Auto-generated catch block 124 | e.printStackTrace(); 125 | } 126 | } 127 | 128 | public WebClient getWebClient(boolean useJavaScript) { 129 | WebClient webClient = new WebClient(); 130 | if (Factory.getProxyConfig() != null) { 131 | webClient.getOptions().setProxyConfig(Factory.getProxyConfig()); 132 | } 133 | webClient.setCssErrorHandler(new SilentCssErrorHandler()); 134 | webClient.setRefreshHandler(new ThreadedRefreshHandler()); 135 | webClient.getOptions().setJavaScriptEnabled(useJavaScript); 136 | webClient.getOptions().setThrowExceptionOnScriptError(false); 137 | java.util.logging.Logger.getLogger("org").setLevel(java.util.logging.Level.OFF); 138 | return webClient; 139 | } 140 | 141 | public boolean within(Date d) { 142 | return (d.getTime() >= getStartdate().getTime()) && 143 | (d.getTime() <= getStopdate().getTime()); 144 | } 145 | 146 | public Object callFunc(String funcname, Object[] args) { 147 | try { 148 | Context context = enterContext(); 149 | if (args == null) 150 | args = new Object[0]; 151 | Function f = (Function) scope.get(funcname, scope); 152 | Object result = f.call(context, scope, f, args); 153 | if (result instanceof NativeJavaObject) 154 | result = ((NativeJavaObject) result).unwrap(); 155 | return result; 156 | } catch (Exception e) { 157 | e.printStackTrace(); 158 | } finally { 159 | Context.exit(); 160 | } 161 | return null; 162 | } 163 | public void search(String string) { 164 | try { 165 | Context context = enterContext(); 166 | Function f = (Function) scope.get("search", scope); 167 | f.call(context, scope, f, new Object[] { string }); 168 | } catch (Exception e) { 169 | // TODO Auto-generated catch block 170 | e.printStackTrace(); 171 | } finally { 172 | Context.exit(); 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/jsq/fetcher/history/Yahoo.java: -------------------------------------------------------------------------------- 1 | package jsq.fetcher.history; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | import java.net.URLEncoder; 6 | import java.text.DateFormat; 7 | import java.text.ParseException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.ArrayList; 10 | import java.util.Date; 11 | import java.util.List; 12 | import java.util.Locale; 13 | import java.util.Map; 14 | 15 | import jsq.config.Config; 16 | import jsq.datastructes.Datacontainer; 17 | import jsq.fetch.factory.Factory; 18 | import jsq.tools.HtmlUnitTools; 19 | import jsq.tools.VarTools; 20 | 21 | import org.apache.commons.csv.CSVFormat; 22 | import org.apache.commons.csv.CSVParser; 23 | import org.apache.commons.csv.CSVRecord; 24 | 25 | import org.htmlunit.FailingHttpStatusCodeException; 26 | import org.htmlunit.Page; 27 | import org.htmlunit.SilentCssErrorHandler; 28 | import org.htmlunit.TextPage; 29 | import org.htmlunit.ThreadedRefreshHandler; 30 | import org.htmlunit.UnexpectedPage; 31 | import org.htmlunit.WebClient; 32 | import org.htmlunit.html.HtmlPage; 33 | import org.htmlunit.html.HtmlTable; 34 | 35 | public class Yahoo extends BaseFetcher { 36 | 37 | private String history = "http://ichart.finance.yahoo.com/table.csv?ignore=.csv" 38 | + "&s=%1$s" 39 | + "&a=%2$s&b=%3$s&c=%4$s&d=%5$s&e=%6$s&f=%7$s&g=d"; 40 | 41 | private WebClient webClient; 42 | 43 | private String currency; 44 | 45 | 46 | @Override 47 | public String getName() { 48 | return "Yahoo Finance!"; 49 | } 50 | 51 | @Override 52 | public String getURL() { 53 | return "http://www.yahoo.de"; 54 | } 55 | 56 | /** 57 | * 58 | * @param wkn 59 | * @return 60 | * @throws Exception 61 | */ 62 | @Override 63 | public void prepare(String search, int beginYear, int beginMon, int beginDay, int stopYear, int stopMon, int stopDay) throws Exception { 64 | super.prepare(search, beginYear, beginMon, beginDay, stopYear, stopMon, stopDay); 65 | webClient = new WebClient(); 66 | if (Factory.getProxyConfig() != null) { 67 | webClient.getOptions().setProxyConfig(Factory.getProxyConfig()); 68 | } 69 | webClient.setCssErrorHandler(new SilentCssErrorHandler()); 70 | webClient.setRefreshHandler(new ThreadedRefreshHandler()); 71 | webClient.getOptions().setJavaScriptEnabled(false); 72 | try { 73 | HtmlPage page = webClient.getPage("https://de.finance.yahoo.com/q?s=" + URLEncoder.encode(search, "UTF-8") + "&ql=1"); 74 | 75 | HtmlTable datatable = HtmlUnitTools.getTableByPartContent(page, "Ticker"); 76 | if (datatable == null) { 77 | throw new IllegalStateException("Table 'Hist. Ereignisse' not found!"); 78 | } 79 | 80 | List> liste = HtmlUnitTools.analyse(datatable); 81 | 82 | List configs = new ArrayList(); 83 | Config config = new Config("Handelsplatz"); 84 | for (Map x : liste) { 85 | config.addAuswahl(x.get("Börsenplatz") + " [" + x.get("Ticker") + "]", 86 | x.get("Ticker")); 87 | } 88 | configs.add(config); 89 | setConfig(configs); 90 | 91 | } catch (FailingHttpStatusCodeException | IOException e) { 92 | e.printStackTrace(); 93 | } finally { 94 | } 95 | 96 | } 97 | @Override 98 | public void process(List config) { 99 | super.process(config); 100 | try { 101 | String ticker = URLEncoder.encode((String) config.get(0).getSelected().get(0).getObj(), "UTF-8"); 102 | getData(ticker); 103 | 104 | 105 | Date start = getStartdate(); 106 | Date stop = getStopdate(); 107 | String url = String.format(history, ticker, 108 | start.getMonth(), start.getDate(), start.getYear() + 1900, 109 | stop.getMonth(), stop.getDate(), stop.getYear() + 1900); 110 | TextPage page = webClient.getPage(url); 111 | evalCSV(page.getContent(), currency); 112 | } catch (FailingHttpStatusCodeException | IOException e) { 113 | e.printStackTrace(); 114 | } 115 | } 116 | 117 | private void evalCSV(String s, String defaultcur) throws IOException { 118 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.GERMAN); 119 | CSVFormat format = CSVFormat.RFC4180.withHeader().withDelimiter(',').withIgnoreEmptyLines(true); 120 | CSVParser parser = new CSVParser(new StringReader(s), format); 121 | ArrayList resultQuotes = new ArrayList(); 122 | for(CSVRecord record : parser){ 123 | Datacontainer dc = new Datacontainer(); 124 | try { 125 | dc.data.put("date", df.parse(record.get("Date"))); 126 | dc.data.put("first", VarTools.stringToBigDecimal(record.get("Open"))); 127 | dc.data.put("last", VarTools.stringToBigDecimal(record.get("Close"))); 128 | dc.data.put("low", VarTools.stringToBigDecimal(record.get("Low"))); 129 | dc.data.put("high", VarTools.stringToBigDecimal(record.get("High"))); 130 | dc.data.put("currency", defaultcur); 131 | resultQuotes.add(dc); 132 | } catch (ParseException e) { 133 | e.printStackTrace(); 134 | } 135 | } 136 | setHistQuotes(resultQuotes); 137 | parser.close(); 138 | } 139 | 140 | 141 | private void getData(String ticker) throws FailingHttpStatusCodeException, IOException { 142 | UnexpectedPage page = webClient.getPage("http://de.finance.yahoo.com/d/quotes.csv?s=" + ticker + "&f=c4n0s"); 143 | CSVFormat format = CSVFormat.RFC4180.withHeader().withDelimiter(',').withIgnoreEmptyLines(true); 144 | CSVParser parser = new CSVParser(new StringReader("c4,n0,s\n" + page.getWebResponse().getContentAsString()), format); 145 | List records = parser.getRecords(); 146 | if (records.size() == 0) { 147 | parser.close(); 148 | return; 149 | } 150 | currency = records.get(0).get("c4"); 151 | Datacontainer dc = new Datacontainer(); 152 | dc.put("name", records.get(0).get("n0")); 153 | dc.put("ticker", records.get(0).get("s")); 154 | setStockDetails(dc); 155 | parser.close(); 156 | } 157 | 158 | 159 | } 160 | -------------------------------------------------------------------------------- /src/jsq/tools/CsvTools.java: -------------------------------------------------------------------------------- 1 | package jsq.tools; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | import java.util.List; 6 | 7 | import org.apache.commons.csv.CSVFormat; 8 | import org.apache.commons.csv.CSVParser; 9 | import org.apache.commons.csv.CSVRecord; 10 | 11 | public class CsvTools { 12 | 13 | public static List getRecordsFromCsv(char sep, String content) throws IOException { 14 | CSVFormat format = CSVFormat.RFC4180.withHeader().withDelimiter(sep).withIgnoreEmptyLines(true); 15 | CSVParser parser = new CSVParser(new StringReader(content), format); 16 | List liste = parser.getRecords(); 17 | parser.close(); 18 | return liste; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/jsq/tools/CurrencyTools.java: -------------------------------------------------------------------------------- 1 | package jsq.tools; 2 | 3 | public class CurrencyTools { 4 | 5 | public static String correctCurrency(String cur) { 6 | String t = cur.toLowerCase(); 7 | if (t.equals("euro") || t.equals("€")) { 8 | return "EUR"; 9 | } if (t.equals("$") || t.equals("us-dollar")) { 10 | return "USD"; 11 | } 12 | return cur.toUpperCase(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/jsq/tools/HtmlUnitTools.java: -------------------------------------------------------------------------------- 1 | package jsq.tools; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | 7 | import org.htmlunit.html.DomElement; 8 | import org.htmlunit.html.HtmlElement; 9 | import org.htmlunit.html.HtmlPage; 10 | import org.htmlunit.html.HtmlTable; 11 | import org.htmlunit.html.HtmlTableRow; 12 | 13 | public class HtmlUnitTools { 14 | 15 | /** 16 | * Searches a Table that TextContent starts with startstring 17 | * [table.getTextContent().trim().startsWith(startstring)] 18 | * 19 | * @param page Page 20 | * @return HTML Table or null if not found 21 | */ 22 | public static HtmlTable getTableByPartContent(HtmlPage page, String startstring) { 23 | List tablelist = page.getElementsByTagName("table"); 24 | for (DomElement table : tablelist) { 25 | if (table.getTextContent().trim().startsWith(startstring)) { 26 | return (HtmlTable) table; 27 | } 28 | } 29 | return null; 30 | } 31 | 32 | /** 33 | * Searches a Table that TextContent starts with startstring 34 | * [table.getTextContent().trim().startsWith(startstring)] 35 | * 36 | * @param page Page 37 | * @return HTML Table or null if not found 38 | */ 39 | public static HtmlElement getElementByPartContent(HtmlPage page, String startstring, String tagname) { 40 | List tablelist = page.getElementsByTagName(tagname); 41 | for (DomElement table : tablelist) { 42 | if (table.getTextContent().trim().startsWith(startstring)) { 43 | return (HtmlElement) table; 44 | } 45 | } 46 | return null; 47 | } 48 | 49 | /** 50 | * Puts the content of a table in a list of hashmap. 51 | * One Hashmap for each row 52 | * 53 | * @param datatable 54 | * @return 55 | */ 56 | public static List> analyse(HtmlTable datatable) { 57 | List> liste = new ArrayList>(); 58 | int rows = datatable.getRows().size(); 59 | HtmlTableRow header = datatable.getRows().get(0); 60 | for (int idx = 1; idx < rows; idx++) { 61 | HashMap hash = new HashMap(); 62 | HtmlTableRow row = datatable.getRows().get(idx); 63 | if (row.getCells().size() != header.getCells().size()) { 64 | System.out.println("Spalten der aktuellen Zeile stimmten mit den Zeilen des Kopfes nicht überein." + row.getTextContent()); 65 | continue; 66 | } 67 | for (int i = 0; i < row.getCells().size(); i++) { 68 | String d = row.getCells().get(i).getTextContent().trim(); 69 | hash.put(header.getCells().get(i).getTextContent().trim(), 70 | (d.equals("") ? null : d)); 71 | } 72 | liste.add(hash); 73 | } 74 | return liste; 75 | } 76 | 77 | public static HtmlElement getFirstElementByXpath(HtmlPage page, String xpath) { 78 | List x = page.getByXPath(xpath); 79 | if (x.size() == 0) { 80 | return null; 81 | } 82 | return (HtmlElement) x.get(0); 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/jsq/tools/VarTools.java: -------------------------------------------------------------------------------- 1 | package jsq.tools; 2 | 3 | import java.math.BigDecimal; 4 | import java.text.DateFormat; 5 | import java.text.ParseException; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | public class VarTools { 10 | 11 | public static BigDecimal stringToBigDecimalGermanFormat(String string) { 12 | return stringToBigDecimal(string.replace(".", "").replace(",", ".")); 13 | } 14 | 15 | public static BigDecimal stringToBigDecimal(String string) { 16 | if (string.trim().isEmpty()) { 17 | return null; 18 | } 19 | return new BigDecimal(string); 20 | } 21 | 22 | public static Date parseDate(String date, String format) { 23 | DateFormat df = new SimpleDateFormat(format); 24 | try { 25 | return df.parse(date); 26 | } catch (ParseException e) { 27 | return null; 28 | } 29 | } 30 | 31 | public static String date2String(String date, String format) { 32 | DateFormat df = new SimpleDateFormat(format); 33 | return df.format(date); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/label.txt: -------------------------------------------------------------------------------- 1 | name Company or Mutual Fund Name 2 | 3 | price Price 4 | first First Price 5 | last Last Price 6 | low Lowest trade today 7 | high Highest trade today 8 | 9 | currency (three letter code, see ISO 4217) 10 | 11 | date Last Trade Date 12 | time Last Trade Time 13 | volume Volume 14 | 15 | net Net Change 16 | p_change Percent Change from previous day's close 17 | avg_vol Average Daily Vol 18 | bid Bid 19 | ask Ask 20 | close Previous Close 21 | day_range Day's Range 22 | year_range 52-Week Range 23 | eps Earnings per Share 24 | pe P/E Ratio 25 | div_date Dividend Pay Date 26 | div Dividend per Share 27 | div_yield Dividend Yield 28 | cap Market Capitalization 29 | ex_div Ex-Dividend Date. 30 | nav Net Asset Value 31 | yield Yield (usually 30 day avg) 32 | exchange The exchange the information was obtained from. 33 | success Did the stock successfully return information? (true/false) 34 | errormsg If success is false, this field may contain the reason why. 35 | method The module (as could be passed to fetch) which found this 36 | information. 37 | type The type of equity returned -------------------------------------------------------------------------------- /tests/AllJSTests.java: -------------------------------------------------------------------------------- 1 | import static org.junit.Assert.*; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.List; 7 | 8 | import jsq.config.Config; 9 | import jsq.fetch.factory.Factory; 10 | import jsq.fetcher.history.BaseFetcher; 11 | import jsq.fetcher.history.GenericJSFetcher; 12 | import junit.framework.Assert; 13 | 14 | import org.junit.Test; 15 | import org.junit.runner.RunWith; 16 | import org.junit.runners.Parameterized; 17 | import org.junit.runners.Parameterized.Parameters; 18 | 19 | 20 | @RunWith(Parameterized.class) 21 | public class AllJSTests { 22 | 23 | /** 24 | * Liefert aus der XML-Datei alle -Nodes zurück, die getestet werden sollen 25 | * @return Liste mit Nodes 26 | * @throws Throwable Diverse Fehler 27 | */ 28 | @Parameters 29 | public static Collection data() throws Throwable { 30 | System.out.println("Working Directory: " + System.getProperty("user.dir")); 31 | Collection params = new ArrayList(); 32 | File dir = new File("js"); 33 | if (dir.exists()) { 34 | for (final File fileEntry : dir.listFiles()) { 35 | if (!fileEntry.isDirectory() && fileEntry.getName().toLowerCase().endsWith(".js")) { 36 | try { 37 | Object[] arr = new Object[] { fileEntry.getAbsolutePath() }; 38 | params.add(arr); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | throw new IllegalStateException("Fehler beim Laden von " + fileEntry.getName()); 42 | } 43 | } 44 | } 45 | } 46 | for (BaseFetcher x : Factory.getHistoryFetcher()) { 47 | Object[] arr = new Object[] { x }; 48 | params.add(arr); 49 | } 50 | return params; 51 | } 52 | 53 | private Object x; 54 | 55 | /** 56 | * Init 57 | * @param h Held 58 | */ 59 | public AllJSTests(Object s) { 60 | x = s; 61 | } 62 | 63 | /** 64 | * Der eigentliche Test 65 | * @throws Exception 66 | */ 67 | @Test 68 | public void runit() throws Exception { 69 | System.out.println("==================================================================="); 70 | System.out.println(x); 71 | BaseFetcher fetcher; 72 | if (x instanceof String) { 73 | fetcher = new GenericJSFetcher((String) x); 74 | } else { 75 | fetcher = (BaseFetcher) x; 76 | } 77 | System.out.println(" Name: " + fetcher.getName()); 78 | System.out.println(" URL: " + fetcher.getURL()); 79 | assertNotNull(fetcher.getName()); 80 | assertNotNull(fetcher.getURL()); 81 | if (fetcher instanceof GenericJSFetcher) { 82 | GenericJSFetcher f = (GenericJSFetcher) fetcher; 83 | System.out.println(" Api: " + f.getAPIVersion()); 84 | System.out.println(" Version: " + f.getVersion()); 85 | assertNotNull(f.getAPIVersion()); 86 | assertNotNull(f.getVersion()); 87 | assertTrue(f.getAPIVersion().equals("1")); 88 | } 89 | 90 | //fetcher.prepare("DE0007236101", 2012, 5, 29, 2014, 6, 1); // Siemens 91 | fetcher.prepare("603474", 2016, 1, 1, 2020, 6, 25); 92 | while (fetcher.hasMoreConfig()) { 93 | List config = fetcher.getConfigs(); 94 | // Set always the first option 95 | for (Config c : config) { 96 | System.out.println(" Config " + c.toString()); 97 | System.out.println(" Setting " + c.getBeschreibung() + " to " + c.getOptions().get(0)); 98 | c.addSelectedOptions(c.getOptions().get(0)); 99 | } 100 | fetcher.process(config); 101 | } 102 | //System.out.println(" Quotes:" + fetcher.getHistQuotes()); 103 | System.out.println(" Details:" + fetcher.getStockDetails()); 104 | System.out.println(" Events:" + fetcher.getHistEvents()); 105 | assertNotNull(fetcher.getStockDetails()); 106 | } 107 | } 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /tests/TestJS.java: -------------------------------------------------------------------------------- 1 | import static org.junit.Assert.assertNotNull; 2 | 3 | import java.util.List; 4 | 5 | import jsq.config.Config; 6 | import jsq.fetcher.history.GenericJSFetcher; 7 | 8 | import org.junit.Test; 9 | 10 | 11 | public class TestJS { 12 | 13 | @Test 14 | public void testArivaAktie() throws Exception { 15 | //GenericJSFetcher fetcher = new GenericJSFetcher("js/finanzennet.js"); 16 | GenericJSFetcher fetcher = new GenericJSFetcher("js/ariva.js"); 17 | assertNotNull(fetcher); 18 | System.out.println(fetcher); 19 | //fetcher.prepare("LYX0AG", 2020, 12, 15, 2021, 1, 11); 20 | //fetcher.prepare("DE0007100000", 2013, 1, 15, 2013, 1, 31); 21 | //fetcher.prepare("US88160R1014", 2020, 1, 01, 2021, 1, 31); 22 | //fetcher.prepare("LU0119124781", 1995, 1, 1, 2014, 6, 25); 23 | //fetcher.prepare("DE0005933931", 2000, 1, 1, 2021, 1, 13); 24 | //fetcher.prepare("603474", 1995, 1, 1, 2014, 6, 25); 25 | fetcher.prepare("XC0009655157", 2010, 1, 1, 2021, 1, 13); 26 | 27 | //LU0274211217 db x-tr.EO STOXX 50 28 | //fetcher.prepare("LU0274211217", 1995, 1, 1, 2014, 6, 25); // Fond 29 | while (fetcher.hasMoreConfig()) { 30 | List config = fetcher.getConfigs(); 31 | // Set always the first option 32 | for (Config c : config) { 33 | System.out.println("Config " + c.toString()); 34 | System.out.println("Setting " + c.getBeschreibung() + " to " + c.getOptions().get(0)); 35 | c.addSelectedOptions(c.getOptions().get(0)); 36 | } 37 | fetcher.process(config); 38 | } 39 | System.out.println("Quotes:"); 40 | System.out.println(fetcher.getHistQuotes()); 41 | System.out.println("HistEvents:"); 42 | System.out.println(fetcher.getHistEvents()); 43 | System.out.println("StockDetails"); 44 | System.out.println(fetcher.getStockDetails()); 45 | assertNotNull(fetcher.getStockDetails()); 46 | } 47 | 48 | @Test 49 | public void testArivaEtf() throws Exception { 50 | //GenericJSFetcher fetcher = new GenericJSFetcher("js/finanzennet.js"); 51 | GenericJSFetcher fetcher = new GenericJSFetcher("js/ariva.js"); 52 | assertNotNull(fetcher); 53 | System.out.println(fetcher); 54 | //fetcher.prepare("A113FM", 2020, 12, 15, 2021, 1, 11); 55 | //fetcher.prepare("LYX0AG", 2020, 12, 15, 2021, 1, 11); 56 | //fetcher.prepare("DE0007100000", 2013, 1, 15, 2013, 1, 31); 57 | // fetcher.prepare("DE0007236101", 2013, 1, 15, 2013, 1, 31); 58 | //fetcher.prepare("LU0119124781", 1995, 1, 1, 2014, 6, 25); 59 | fetcher.prepare("IE00B9CQXS71", 2021, 3, 1, 2021, 3, 8); 60 | //fetcher.prepare("603474", 1995, 1, 1, 2014, 6, 25); 61 | 62 | //LU0274211217 db x-tr.EO STOXX 50 63 | //fetcher.prepare("LU0274211217", 1995, 1, 1, 2014, 6, 25); // Fond 64 | while (fetcher.hasMoreConfig()) { 65 | List config = fetcher.getConfigs(); 66 | // Set always the first option 67 | for (Config c : config) { 68 | System.out.println("Config " + c.toString()); 69 | System.out.println("Setting " + c.getBeschreibung() + " to " + c.getOptions().get(0)); 70 | c.addSelectedOptions(c.getOptions().get(0)); 71 | } 72 | fetcher.process(config); 73 | } 74 | System.out.println("Quotes:"); 75 | System.out.println(fetcher.getHistQuotes()); 76 | System.out.println("HistEvents:"); 77 | System.out.println(fetcher.getHistEvents()); 78 | System.out.println("StockDetails"); 79 | System.out.println(fetcher.getStockDetails()); 80 | assertNotNull(fetcher.getStockDetails()); 81 | } 82 | 83 | public static void main(String [] args) throws Exception { 84 | TestJS js = new TestJS(); 85 | js.testArivaAktie(); 86 | js.testArivaEtf(); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /tests/TestYahoo.java: -------------------------------------------------------------------------------- 1 | import static org.junit.Assert.*; 2 | 3 | import java.util.List; 4 | 5 | import jsq.config.Config; 6 | import jsq.fetcher.history.Yahoo; 7 | 8 | import org.junit.Test; 9 | 10 | 11 | public class TestYahoo { 12 | 13 | @Test 14 | public void test() throws Exception { 15 | Yahoo x = new Yahoo(); 16 | x.prepare("DE0007236101", 2012, 1, 1, 2013, 1, 1); // Siemens 17 | while (x.hasMoreConfig()) { 18 | List config = x.getConfigs(); 19 | // Set always the first option 20 | for (Config c : config) { 21 | System.out.println("Setting " + c.getBeschreibung() + " to " + c.getOptions().get(0)); 22 | c.addSelectedOptions(c.getOptions().get(0)); 23 | } 24 | x.process(config); 25 | } 26 | System.out.println(x.getHistQuotes()); 27 | System.out.println(x.getHistEvents()); 28 | System.out.println(x.getStockDetails()); 29 | assertNotNull(x.getHistQuotes()); 30 | assertNotNull(x.getHistEvents()); 31 | assertNotNull(x.getStockDetails()); 32 | } 33 | 34 | } 35 | --------------------------------------------------------------------------------