Skip to content

Commit

Permalink
Bug: Swapped Index 52W High and Low. Corrected.
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Mar 28, 2022
1 parent a94b22c commit 2c4f61a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.fross</groupId>
<artifactId>quoter</artifactId>
<version>3.0.1</version>
<version>3.0.2</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: '3.0.1'
version: '3.0.2'
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
10 changes: 7 additions & 3 deletions src/main/java/org/fross/quoter/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ protected static String[] getIndex(String idx) {
// Define the regular expression patterns to look for in the URL provided above
// Current Price
searchPatterns[1] = "\"price\"\\s+content=\"(.*?)\"";

// Change
searchPatterns[2] = "\"priceChange\"\\s+content=\"(.*?)\"";

// Change Percent
searchPatterns[3] = "\"priceChangePercent\"\\s+content=\"(.*?)\"";
// 52Week Low
searchPatterns[4] = "\"label\"\\>52 Week Range\\<\\/small>\\n.+?primary\\s+\"\\>(.+?)\\s";

// 52Week High
searchPatterns[5] = "\"label\"\\>52 Week Range\\<\\/small>\\n.+?primary\\s+\"\\>.*?\\s-\\s(.+?)\\<";
searchPatterns[4] = "\"label\"\\>52 Week Range\\<\\/small>\\n.+?primary\\s+\"\\>.*?\\s-\\s(.+?)\\<";

// 52Week Low
searchPatterns[5] = "\"label\"\\>52 Week Range\\<\\/small>\\n.+?primary\\s+\"\\>(.+?)\\s";

// Set the first element of the return array to the index name
retArray[0] = idx;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/fross/quoter/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,22 +437,22 @@ public static void main(String[] args) {
// Format the Output
// Symbol
outString[0] = String.format("%-10s", result[0]);

// Current
outString[1] = String.format("%,10.2f", Float.valueOf(result[1].replace(",", "")));

// Change Amount
outString[2] = String.format("%+,10.2f", Float.valueOf(result[2].replace(",", "")));

// Change Percentage
outString[3] = String.format("%+,10.2f%%", Float.valueOf(result[3].replace("%", "")));

// 52Week High
outString[4] = String.format("%,14.2f", Float.valueOf(result[4].replace(",", "")));

// 52Week Low
outString[5] = String.format("%,13.2f", Float.valueOf(result[5].replace(",", "")));

// 52Week Change Percentage between low value and high value
Float h = Float.valueOf(result[4]);
Float l = Float.valueOf(result[5]);
Expand Down

0 comments on commit 2c4f61a

Please sign in to comment.