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 extends Map> 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