Topic: Some OFXGet Feedback
Hi, saw that OFXGet was your first Java Program. Pretty good, but found some things.
Testing was done with Fidelity. There are 2 institution problem threads that pertain to Fidelity. I did not respond to those old threads as those people are likely gone, but include everything here.
The first is the invalid date. The ofx.generateInvestRequest() appears to put too early a date in the <DTSTART> tag for transaction inclusion. I just changed to a hardcoded:
line 116: "<DTEND>20110801000000\n" +
Everything worked. Using the end date form of the request is probably more resilient, as you could specify yesterday on the fly. To do that:
- Change' import java.util.Date;' to 'import java.util.*;' This allows the Calendar class to be short hand referenced too. Calendar is kind of a Date replacement.
- Take the 'SimpleDateFormat format' local var in generateDate() and make it a class member, so it can be used in multiple places.
- Easier to just list the entire function:
private String generateInvestRequest()
Calendar now = Calendar.getInstance();
String ret =
"<BROKERID>" + brokerId + "\n" +
"<ACCTID>" + accountId + "\n" +
"<DTEND>" + format.format(now.getTime() ) + "\n" +
"<DTASOF>" + generateDate() + "\n" +
The second relates to how you are processing the return from generateAccountRequest(), when the person does not put in an account. Fidelity accounts sometimes have non-numeric elements. Your Regex pattern "<ACCTID>\\s*([0-9]*)\\s*<" means that if the person only has an account with a alpha in it that no account will be found, to the user id is used, which fails.
First ([0-9])* really should be ([0-9])+. The * means 0 or more, + means 1 or more. To include anything up to the next '<', use "<ACCTID>([^<]+)".
Both changes I just tested on Fidelity, & it works. I have multiple accounts, the first one listed started with an X. Before the change I got the 2nd account, now I get the first.