Closed higgsja closed 3 years ago
I went out to the developer.tdameritrade.com site, tried a couple tickers including DIS with no issue at all. Remain scratching my head.
Turns out GE and RUN cause the same issue.
Let me test with unit tests for DIS, GE, and RUN. They may have added a new enumeration type that will be easy to add.
Excellent. Sounds right that maybe they have some with STOCK and some with EQUITY or something like that.
a
--
Thanks! West Point 1976 H-3 Join us! https://hlh-tx.com Mission: To measurably improve investor performance
"We enjoy the comfort of opinion without the discomfort of thought." -- J.F. Kennedy
On 1/6/21 2:52 PM, William Studer wrote:
Let me test with unit tests for DIS, GE, and RUN. They may have added a new enumeration type that will be easy to add.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/studerw/td-ameritrade-client/issues/35#issuecomment-755677497, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKGI5MTT7GFMNGWM4CE4TSYTER7ANCNFSM4VX2DYDA.
Add CVX to the list ...
Ok, may be as simple as changing the following in OptionDeliverable.java (or not as I messed with a lot of things beyond my understanding).
change:
public enum AssetType { CASH_EQUIVALENT, CURRENCY, EQUITY, FIXED_INCOME, INDEX, MUTUAL_FUND, OPTION }
to: `public enum AssetType { CASH_EQUIVALENT, CURRENCY, EQUITY, FIXED_INCOME, INDEX, MUTUAL_FUND, OPTION, STOCK }'
Yes I think that might just be enough to fix it. If you want to test it out, checkout the master branch and make your fix to the OptionDeliverable.AssetType enum in master branch.
Then, run a maven clean install. You'll see that you now installed the api with version 2.4.0-SNAPSHOT into your local Maven repository. Then in your actual app, change the version from whatever you were using (2.3.0) to 2.4.0-SNAPSHOT. Then rebuild your app and try to run the same query that was giving you problems.
Let me know if it works. If so, you could either add a Pull Request with the change (so you can get the Github Cred!!) or I can just do it manually. I think your other error in issue #36 might be as easy to fix. It is just the TDA keeps changing their API for no good reason and breaking code that depends on it :(
@higgsja Thanks for your help on this. I just looked on TDA's dev site and apparently they don't have any Enumeration for AssetType nor Currency Type (previously it was USD, CAD, JPY, EUR). Instead their Json Schema just lists them as Strings, so I'm going to do the same and convert them to string. Merged into Master which is 2.4.0-SNAPSHOT. I'll make a full 2.4.0 release later this week with other issues. Thanks Again!
Using 2.3.0
This is odd. I get the errors noted below but not on every ticker. DIS fails every time while the other 17 I'm after are fine every time. I cannot discover why DIS would be unique in this way.
I set all the properties, then call into an instance of HttpTdaClient as: httpTdaClient.getOptionChain("DIS").
The output notes that 'STOCK' is not part of an enum but I cannot find that enum. Also, most of the ones I'm after are stocks, e.g., aal, appl, amzn, docu, hd, jpm, etc.
[main] INFO TDA_HTTP - REQUEST GET: https://api.tdameritrade.com/v1/marketdata/chains?symbol=DIS [main] INFO TDA_HTTP - RESPONSE [200 - OK]: https://api.tdameritrade.com/v1/marketdata/chains?symbol=DIS in 214.5 ms Exception in thread "main" java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type
com.studerw.tda.model.account.OptionDeliverable$AssetTypefrom String "STOCK": not one of the values accepted for Enum class: [MUTUAL_FUND, CURRENCY, INDEX, FIXED_INCOME, OPTION, CASH_EQUIVALENT, EQUITY] at [Source: (BufferedInputStream); line: 1, column: 57843] (through reference chain: com.studerw.tda.model.option.OptionChain["callExpDateMap"]->java.util.LinkedHashMap["2021-01-15:9"]->java.util.LinkedHashMap["23.0"]->java.util.ArrayList[0]->com.studerw.tda.model.option.Option["optionDeliverablesList"]->java.util.ArrayList[1]->com.studerw.tda.model.account.OptionDeliverable["assetType"]) at com.studerw.tda.parse.DefaultMapper.fromJson(DefaultMapper.java:91) at com.studerw.tda.parse.TdaJsonParser.parseOptionChain(TdaJsonParser.java:218) at com.studerw.tda.client.HttpTdaClient.getOptionChain(HttpTdaClient.java:595) at com.hpi.appcontrollers.TDAmeritradeFetchOptionsController2.doPrices(TDAmeritradeFetchOptionsController2.java:52) at com.hpi.appcontrollers.CmdLineController.doCommandLine(CmdLineController.java:238) at com.hpi.appcontrollers.AppController.startApp(AppController.java:56) at com.hpi.appTPCcli.TPCcliEx.main(TPCcliEx.java:19)
followed by
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type
com.studerw.tda.model.account.OptionDeliverable$AssetTypefrom String "STOCK": not one of the values accepted for Enum class: [MUTUAL_FUND, CURRENCY, INDEX, FIXED_INCOME, OPTION, CASH_EQUIVALENT, EQUITY] at [Source: (BufferedInputStream); line: 1, column: 57843] (through reference chain: com.studerw.tda.model.option.OptionChain["callExpDateMap"]->java.util.LinkedHashMap["2021-01-15:9"]->java.util.LinkedHashMap["23.0"]->java.util.ArrayList[0]->com.studerw.tda.model.option.Option["optionDeliverablesList"]->java.util.ArrayList[1]->com.studerw.tda.model.account.OptionDeliverable["assetType"]) at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1698) at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:947) at com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeAltString(EnumDeserializer.java:255) at com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:179) at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:285) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27) at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:285) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27) at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBind(MapDeserializer.java:465) at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:367) at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29) at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:527) at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:364) at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29) at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4482) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3479) at com.studerw.tda.parse.DefaultMapper.fromJson(DefaultMapper.java:89) ... 6 more