Skip to content

Commit

Permalink
Index provider changed their page - updated regex's
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Jan 15, 2021
1 parent 00fca15 commit d6fefd7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 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>2.3.2</version>
<version>2.3.3</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: '2.3.2'
version: '2.3.3'
summary: Command line utility to pull stock and index quotes
description: |
Quote fetches stock quotes and index data from IEXCloud.IO.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fross/quoter/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ protected static String[] getIndex(String idx) {
searchPatterns[1] = "\"last\":\"(.*?)\"";
searchPatterns[2] = "\"change\":\"(.*?)\"";
searchPatterns[3] = "\"change_pct\":\"(.*?)\"";
searchPatterns[4] = "'year high'.*?\\>(.*?)\\<";
searchPatterns[5] = "'year low'.*?\\>(.*?)\\<";
searchPatterns[4] = "QuoteStrip-fiftyTwoWeekRange\"\\>(.*?)\\<";
searchPatterns[5] = "QuoteStrip-fiftyTwoWeekRange.*? - .*?\\>(.*?)\\<";

retArray[0] = idx;
for (int i = 1; i < searchPatterns.length; i++) {
Expand Down
31 changes: 14 additions & 17 deletions src/main/java/org/fross/quoter/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public static void main(String[] args) {
Properties prop = new Properties();
prop.load(iStream);
VERSION = prop.getProperty("Application.version");
COPYRIGHT = "Copyright " + prop.getProperty("Application.inceptionYear") + "-" + org.fross.library.Date.getCurrentYear()
+ " by Michael Fross";
COPYRIGHT = "Copyright " + prop.getProperty("Application.inceptionYear") + "-" + org.fross.library.Date.getCurrentYear() + " by Michael Fross";
} catch (IOException ex) {
Output.fatalError("Unable to read property file '" + PROPERTIES_FILE + "'", 3);
}
Expand Down Expand Up @@ -141,7 +140,7 @@ public static void main(String[] args) {
Output.println(COPYRIGHT);
System.exit(0);
break;

// Disable colorized output
case 'z':
Output.enableColor(false);
Expand Down Expand Up @@ -334,11 +333,12 @@ public static void main(String[] args) {

// Loop through the three indexes and display the results
String[] indexList = { "DOW", "NASDAQ", "S&P" };
try {
for (int i = 0; i < indexList.length; i++) {
for (int i = 0; i < indexList.length; i++) {
String[] outString = new String[6];
String[] result = Index.getIndex(indexList[i]);
try {
// Download the web page and return the results array
Output.debugPrint("Getting Index data for: " + indexList[i]);
String[] result = Index.getIndex(indexList[i]);

// Determine the color based on the change amount
Ansi.Color outputColor = Ansi.Color.WHITE;
Expand All @@ -347,21 +347,18 @@ public static void main(String[] args) {
}

// Format the Output
// Index Name
String[] outString = new String[6];

// Symbol
outString[0] = String.format("%-10s", result[0]);
// Current
outString[1] = String.format("%,10.2f", Float.valueOf(result[1]));
outString[1] = String.format("%,10.2f", Float.valueOf(result[1].replace(",", "")));
// Change Amount
outString[2] = String.format("%+,10.2f", Float.valueOf(result[2]));
outString[2] = String.format("%+,10.2f", Float.valueOf(result[2].replace(",", "")));
// Change Percentage
outString[3] = String.format("%+,10.2f%%", Float.valueOf(result[3]));
outString[3] = String.format("%+,10.2f%%", Float.valueOf(result[3].replace("%", "")));
// 52Week High
outString[4] = String.format("%,14.2f", Float.valueOf(result[4]));
outString[4] = String.format("%,14.2f", Float.valueOf(result[4].replace(",", "")));
// 52Week Low
outString[5] = String.format("%,14.2f", Float.valueOf(result[5]));
outString[5] = String.format("%,14.2f", Float.valueOf(result[5].replace(",", "")));

// Display Index results to the screen
for (int k = 0; k < outString.length; k++) {
Expand All @@ -375,10 +372,10 @@ public static void main(String[] args) {
if (exportFlag == true && exporter.canWrite()) {
exporter.exportIndexes(result);
}
}
} catch (Exception Ex) {
Output.printColorln(Ansi.Color.RED, outString[0] + ": No Data");

} catch (Exception Ex) {
Output.printColor(Ansi.Color.RED, "No Data");
}
}

// Display date of the data as pulled from iecloud.net. If no symbols were provided and
Expand Down

0 comments on commit d6fefd7

Please sign in to comment.