Skip to content

Commit

Permalink
Increased trend duration to 365 days
Browse files Browse the repository at this point in the history
Also corrected bug with trend that would display previous year's months
after current year due to sorting issues.  Changed the date format to
ISO (YYYY-MM-DD) to correct
  • Loading branch information
frossm committed Sep 14, 2023
1 parent 884a78d commit 6597a4e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.fross</groupId>
<artifactId>quoter</artifactId>
<version>5.0.22</version>
<version>5.0.23</version>
<packaging>jar</packaging>

<name>quoter</name>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: quoter
version: '5.0.22'
version: '5.0.23'
summary: Command line utility to pull stock and index quotes
description: |
Quoter fetches online stock quotes and index data for easy display on
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/fross/quoter/CommandLineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ public void validate(String name, String value) {
int intVal;
try {
intVal = Integer.parseInt(value);
if (intVal < 1 || intVal > 99) {
Output.fatalError("Trend duration can not be '" + value + "'. Value must be between 1 and 99", 1);
if (intVal < 1 || intVal > 365) {
Output.fatalError("Trend duration can not be '" + value + "'. Value must be between 1 and 365", 1);
}
} catch (Exception e) {
Output.fatalError("Trend duration can not be '" + value + "'. Value must be between 1 and 99", 1);
Output.fatalError("Trend duration can not be '" + value + "'. Value must be between 1 and 365", 1);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/fross/quoter/HistoricalQuotes.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public Map<String, Float[]> getHistoricalQuotes(String symb) {

// Loop through each day and populate the hash. Data order: Date,Open,High,Low,Close,Volume
for (int rowRead = (historicalData.length - 1); rowRead > 0; rowRead--) {
// The date is not quoted. Easier to quote the data so the following split works
historicalData[rowRead] = historicalData[rowRead].replaceFirst("^", "\"");
historicalData[rowRead] = historicalData[rowRead].replaceFirst(",", "\",");
// Change the date field to be ISO format instead of US format so the sorted display works
// Also quote the date so the future split will work
historicalData[rowRead] = historicalData[rowRead].replaceFirst("^(\\d+)\\/(\\d+)\\/(\\d+),", "\"$3-$1-$2\",");

// Pull the first field (date) and set as the hash key
String dateKey = historicalData[rowRead].split(",")[0].replaceAll("\"", "");
Expand Down

0 comments on commit 6597a4e

Please sign in to comment.