jrhurley2 / TDInterface-Public

Windows Form application that uses TD Ameritrade Apis
3 stars 1 forks source link

Determine Asset Type #132

Open jrhurley2 opened 1 year ago

jrhurley2 commented 1 year ago

Currently we can only handle equities, even though any asset type can be entered. To support futures trading we need to know what type of asset has been entered into the symbol is it an Equity or Future

brandoncorry commented 1 year ago

This should help determine which asset type for TDA, not sure if it will also work for TS

    public static bool IsFutureSymbol(string symbol)
    {
        return symbol != null && symbol.Length > 1 && symbol[0] == '/';
    }

    public static bool IsIndexSymbol(string symbol)
    {
        return symbol != null && symbol.Length > 1 && symbol[0] == '$';
    }

    public static bool IsOptionSymbol(string symbol)
    {
        return symbol != null && symbol.Length > 12;
    }

    public static bool IsEquitySymbol(string symbol)
    {
        return symbol != null && !IsFutureSymbol(symbol) && !IsIndexSymbol(symbol) && !IsOptionSymbol(symbol);
    }

Found this here

jrhurley2 commented 1 year ago

Probably going to use the web api, it has endpoints that identify the asset type:

routeGetInstrument = "v1/instruments/{0}";