@@ -39,7 +39,13 @@ public GoogleStockHistoryServer(Code code) throws StockHistoryNotFoundException
3939 public GoogleStockHistoryServer (Code code , Duration duration ) throws StockHistoryNotFoundException {
4040 this .code = code ;
4141 this .duration = duration ;
42- this .googleCode = Utils .toGoogleFormat (code );
42+
43+ String _googleCode = Utils .toCompleteUnitedStatesGoogleFormat (code );
44+ if (_googleCode == null ) {
45+ _googleCode = Utils .toGoogleFormat (code );
46+ }
47+
48+ this .googleCode = _googleCode ;
4349
4450 final StringBuilder stringBuilder = new StringBuilder ("http://www.google.com/finance/getprices?f=d,c,v,o,h,l&i=86400&p=" );
4551
@@ -55,7 +61,7 @@ public GoogleStockHistoryServer(Code code, Duration duration) throws StockHistor
5561 //stringBuilder.append(days).append("d&ts=");
5662 //stringBuilder.append(duration.getEndDate().getTime().getTime()).append("d");
5763
58- String googleCodeStr = googleCode . toString () ;
64+ String googleCodeStr = googleCode ;
5965 // Turn "INDEXDJX:.DJI" into "INDEXDJX" and ".DJI".
6066 String [] result = googleCodeStr .split (":" );
6167
@@ -175,7 +181,7 @@ private boolean parse(String respond) {
175181
176182 if (initialized == false ) {
177183 try {
178- Stock stock = stockServer .getStock (googleCode );
184+ Stock stock = stockServer .getStock (code );
179185 symbol = stock .symbol ;
180186 name = stock .getName ();
181187 board = stock .getBoard ();
@@ -321,7 +327,7 @@ public long getMarketCapital() {
321327 private final java .util .Map <Long , Stock > historyDatabase = new HashMap <Long , Stock >();
322328 private final java .util .List <Long > timestamps = new ArrayList <Long >();
323329 private final Code code ;
324- private final Code googleCode ;
330+ private final String googleCode ;
325331 private final StockServer stockServer = new GoogleStockServer ();
326332 private final Duration duration ;
327333
0 commit comments