TD Ameritrade API Questions

Discussion in 'Automated Trading' started by earth_imperator, Jan 24, 2023.

  1. Getting the account data via API gives such a JSON:
    ...
    "currentBalances" : {
    "cashAvailableForTrading" : 123456.78,
    "cashAvailableForWithdrawal" : 123000.00,
    ...

    Question:
    Is the following relation always true: cashAvailableForWithdrawal <= cashAvailableForTrading ?
    Can cashAvailableForTrading ever be less than cashAvailableForWithdrawal ?
     
    murray t turtle likes this.
  2. Matt_ORATS

    Matt_ORATS Sponsor

    ETJ likes this.
  3. Thx for confirmation.
    In AT I'm going to use cashAvailableForWithdrawal over (or instead of ) cashAvailableForTrading to simplify the program logic... But this of course means not making any use of the possibilities of the "unsettledCash" (ie. opening new positions allowed, but not closing during the T+1/T+2 settlement period).
    Maybe will optimize this logic sometime later.

    Thx, I'm so far fine with the TDA API.
     
  4. It seems it has to do with Ex-Div as described here:
    https://www.investopedia.com/terms/d/dnr.asp
    I just wonder whether it also applies to options orders.

    One thing I don't understand is this:
    I'm using ALL_OR_NONE, but sometimes I get response messages that say that the total Qty was filled in multiple parts (hence multiple messages for each filled part). Isn't that illogical with AON?
     
  5. The API function GetQuote / GetQuotes ( https://developer.tdameritrade.com/quotes/apis/get/marketdata/quotes ) gives such volatility values for the ticker:
    AMD: "volatility": 0.0152,
    INTC: "volatility": 0.0208,

    How to interpret these values? Multiplying by 100 gives a HV of just 1.5 and 2.0 respectively.
    This of course can't be true.
    Or has it to be multiplied by 1000 ? Since when & why?

    I'm also missing a MA value in the quote data, for example a 20 day or so moving average for spot.
     
    Last edited: Jun 7, 2023
  6. Occam

    Occam

    Probably it's daily (based on trading days only). So, assuming that's true, and since "volatility" in the retail options world is really an sd (or square root of "volatility" in the statistics world), convert this daily value to yearly by multipling it by sqrt(252), 252 being approx. the number of trading days per year.

    TDAmeritrade's API, while not horrible by historical standards, is perhaps the worst offered by a major broker today.

    More importantly, they may fire you as a "client" if you are highly profitable using the API -- instantly, for life, and refusing any explanation whatsoever.

    Their true clients are the wholesalers (especially Citadel, but a handful of other oligopolistic actors as well), and they don't like it when you eat their lunch on a regular basis.
     
    Last edited: Jun 7, 2023
    MoreLeverage, earth_imperator and spy like this.
  7. Matt_ORATS

    Matt_ORATS Sponsor

    ORATS is starting a beta trial of our Dashboard product using the TDA API. You can use the scanners, options chain, and positions tab to identify trades and execute through TDA. Email me in the signature if you want to join the beta.
     
  8. It somehow does not fit: for example AMD:
    0.0152 * 100 * sqrt(252) = 24.1292
    0.0152 * 100 * sqrt(365) = 29.0395

    The following expert site on volatility (IVolatility / OCC) gives much different (twice higher) HV values:

    AMD_HV_etc.png
     
    Last edited: Jun 8, 2023
  9. Occam

    Occam

    Yeah, the INTC historical volatility was closer to the mark I'd say.

    In any event, I would not trust TDAmeritrade's API to pick my sock color in the morning not to mention provide important financial data off of which to trade, and there are an infinite number of ways to calculate historical volatility anyway, so if you want the "best answer" for you, you probably need to compute your own from a high-quality data source on the underlying. Or find a source you can trust that also provides real documentation of their method.
     
    #10     Jun 8, 2023
    spy likes this.