Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option Chain Parse failure from getOptionChain() #40

Open
bosohn opened this issue Feb 9, 2021 · 7 comments
Open

Option Chain Parse failure from getOptionChain() #40

bosohn opened this issue Feb 9, 2021 · 7 comments

Comments

@bosohn
Copy link

bosohn commented Feb 9, 2021

Hi,

I am getting the following exception from getOptionChain() when I issued it today for OSTK. Could you please check this issue? I just tested with 2.4.0. If you cannot reproduce with OSTK, I can try to find other symbol that has the same issue.

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.math.BigDecimal from String "NaN": not a valid representation
at [Source: (BufferedInputStream); line: 1, column: 681] (through reference chain: com.studerw.tda.model.option.OptionChain["putExpDateMap"]->java.util.LinkedHashMap["2021-02-12:3"]->java.util.LinkedHashMap["46.0"]->java.util.ArrayList[0]->com.studerw.tda.model.option.Option["volatility"])

Thank you!

@studerw
Copy link
Owner

studerw commented Feb 10, 2021

hi @bosohn

I just tried this using this branch of an example here and it worked. Just add your client id and refresh token to src/main/resources/tda-api.properties file then run mvn clean install and run mvn exec:java -Dexec.cleanupDaemonThreads=false.

I can attach the output if you want, but the point is that it didn't have an issue using the version in this pom (2.4.0).

@bosohn
Copy link
Author

bosohn commented Feb 10, 2021

Hi,

It works fine for other symbols but there are certain symbols that fails with the exception.
I tried SRNE and got
java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.math.BigDecimal from String "NaN": not a valid representation
at [Source: (BufferedInputStream); line: 1, column: 309603] (through reference chain: com.studerw.tda.model.option.OptionChain["callExpDateMap"]->java.util.LinkedHashMap["2022-01-21:346"]->java.util.LinkedHashMap["1.0"]->java.util.ArrayList[0]->com.studerw.tda.model.option.Option["volatility"])

For OSTK this time, I got
java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type com.studerw.tda.model.account.OptionDeliverable$AssetType from 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: 441577] (through reference chain: com.studerw.tda.model.option.OptionChain["putExpDateMap"]->java.util.LinkedHashMap["2022-01-21:346"]->java.util.LinkedHashMap["2.5"]->java.util.ArrayList[1]->com.studerw.tda.model.option.Option["optionDeliverablesList"]->java.util.ArrayList[1]->com.studerw.tda.model.account.OptionDeliverable["assetType"])

For INO, I get correct response
Option Chain: com.studerw.tda.model.option.OptionChain@6b5176f2[
symbol=INO
status=SUCCESS
underlying=
strategy=SINGLE
interval=0.0
isDelayed=false
isIndex=false
daysToExpiration=0.0
interestRate=0.1
underlyingPrice=13.825
volatility=29.0
callExpDateMap={2021-02-12:3={2.0=[com.studerw.tda.model.option.Option@ec0c838[
putCall=CALL
symbol=INO_021221C2
description=INO Feb 12 2021 2 Call (Weekly)
exchangeName=OPR
....

Somehow it consistently fails for some symbols and works for others.

@studerw
Copy link
Owner

studerw commented Feb 10, 2021 via email

@studerw
Copy link
Owner

studerw commented Feb 11, 2021

I just tried again with that same branch using all three of the symbols you listed and it works fine.

https://github.com/studerw/tda-client-example/blob/option_chain_test/src/main/java/org/example/MainExample.java

I also deleted all the saved artifacts for this client in my ~/.m2/repository/com/studerw/ directory to force a download of the 2.4.0 version from Maven Central.

Again, I think you are using a bad version somehow. Do you want to check in your project (without any token / client_id) stuff, of course? I can take a look. I will try it again a few more times during the day - maybe it's just an issue when prices are at a certain level, but I don't think that's it.

@bosohn
Copy link
Author

bosohn commented Feb 12, 2021

Sorry, I've been busy. I will get back to it over the weekend. I appreciate your help and thanks for the nice software.

Just wanted to ask you whether there's any TD API that provides earning dates and ex-dividend dates. I tried instrument info API from your API but it didn't return those information, also wondering whether there's an example on how to place spread or synthetic option order with multiple legs.

@bosohn
Copy link
Author

bosohn commented Feb 18, 2021

I verified that it works fine with 2.4.0. Thanks for your help. Any information on the items I mentioned above for API?

@bosohn
Copy link
Author

bosohn commented Feb 19, 2021

One more question: When I retrieve option chain 'underlyingPrice' field of OptionChain is often not valid as shown below for GLRE $4.25 (retrieved after market close today) while today's close is $7.86. For some symbols underlying price is $0.

  1. Could you check why incorrect price is returned for 'underlyingPrice' field?
  2. Field 'underlying' of OptionChain seems to be null. Is it not supplied by TD or dropped by client?

{"delayed":false,"index":false,"symbol":"GLRE","status":"SUCCESS","strategy":"SINGLE","interval":0.0,"isDelayed":false,"isIndex":false,"daysToExpiration":0.0,"interestRate":0.1,"underlyingPrice":4.25,"volatility":29.0,"callExpDateMap":{"2021-02-19:1":{"2.5":[{"inTheMoney":true,"mini":false,"nonStandard":false,"putCall":"CALL","symbol":"GLRE_021921C2.5","description":"GLRE Feb 19 2021 2.5 Call","exchangeName":"OPR","bidPrice":4.5,"askPrice":6.6,"lastPrice":0.0,"bidAskSize":"80X20","markPrice":5.55,"bidSize":80,"askSize":20,"lastSize":0,"highPrice":0.0,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants