pub struct SyncTDAClient { /* private fields */ }

Implementations§

source§

impl SyncTDAClient

source

pub fn new( client_id: String, redirect_uri: String, token_path: String ) -> Result<SyncTDAClient, TDAClientError>

Create New Synchronous TDAClient

source

pub fn clone(&self) -> Self

source

pub fn get_account( &self, acct_id: i64, fields: Option<&Vec<&str>> ) -> Result<String, TDAClientError>

Account balances, positions, and orders for a specific account

Parameters

  • acct_id: Account number
  • fields: Balances displayed by default. Valid fields are positions or orders (Optional)

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D-0

source

pub fn get_accounts( &self, fields: Option<&Vec<&str>> ) -> Result<String, TDAClientError>

Account balances, positions, and orders for all linked accounts

Parameters

  • fields: Balances displayed by default. Valid fields are positions or orders (Optional)

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/accounts-0

source

pub fn search_instruments( &self, symbol: &str, projection: &str ) -> Result<String, TDAClientError>

Search or retrieve instrument data, including fundamental data

Parameters

  • symbol: Value to pass to the search. See projection description for more information
  • projection: The type of request
    • symbol-search: Retrieve instrument data of a specific symbol or cusip
    • symbol-regex: Retrieve instrument data for all symbols matching regex. Example: symbol=XYZ.* will return all symbols beginning with XYZ
    • desc-search: Retrieve instrument data for instruments whose description contains the word supplied. Example: symbol=FakeCompany will return all instruments with FakeCompany in the description
    • desc-regex: Search description with full regex support. Example: symbol=XYZ.[A-C] returns all instruments whose descriptions contain a word beginning with XYZ followed by a character A through C
    • fundamental: Returns fundamental data for a single instrument specified by exact symbol

Official Documentation: https://developer.tdameritrade.com/instruments/apis/get/instruments

source

pub fn get_instrument(&self, cusip: &str) -> Result<String, TDAClientError>

Get an instrument by CUSIP

Parameters

  • cusip: CUSIP string

Official Documentation: https://developer.tdameritrade.com/instruments/apis/get/instruments/%7Bcusip%7D

source

pub fn get_hours_for_multiple_markets( &self, markets: &Vec<&str>, date: &str ) -> Result<String, TDAClientError>

Retrieve market hours for specified markets

Parameters

  • markets: The markets for which you’re requesting market hours. Valid markets are EQUITY, OPTION, FUTURE, BOND, or FOREX
  • date: The date for which market hours information is requested. Valid ISO-8601 formats are yyyy-MM-dd or yyyy-MM-dd'T'HH:mm:ssz

Official Documentation: https://developer.tdameritrade.com/market-hours/apis/get/marketdata/hours

source

pub fn get_hours_for_single_market( &self, market: &str, date: &str ) -> Result<String, TDAClientError>

Retrieve market hours for specified single market

Parameters

  • markets: The markets for which you’re requesting market hours. Valid markets are EQUITY, OPTION, FUTURE, BOND, or FOREX
  • date: The date for which market hours information is requested. Valid ISO-8601 formats are yyyy-MM-dd or yyyy-MM-dd'T'HH:mm:ssz

Official Documentation: https://developer.tdameritrade.com/market-hours/apis/get/marketdata/%7Bmarket%7D/hours

source

pub fn get_movers( &self, index: &str, direction: &str, change: &str ) -> Result<String, TDAClientError>

Top 10 (up or down) movers by value or percent for a particular market

Parameters

  • index: The index symbol to get movers from. Valid indexes are $COMPX, $DJI, or $SPX.X
  • direction: To return movers with the specified directions. Valid directions are up or down
  • change: To return movers with the specified change types. Valid change types are percent or value

Official Documentation: https://developer.tdameritrade.com/movers/apis/get/marketdata/%7Bindex%7D/movers

source

pub fn get_option_chain( &self, option_params: &OptionChain ) -> Result<String, TDAClientError>

Get option chain for an optionable symbol

Parameters

  • option_params: OptionChain object
    • symbol: Enter one symbol (case-sensitive)
    • contract_type: Type of contracts to return in the chain. Valid contract types are CALL, PUT, or ALL. Default is ALL (Optional)
    • strike_count: The number of strikes to return above and below the at-the-money price (Optional)
    • include_quotes: Include quotes for options in the option chain. Default is false (Optional)
    • strategy: Passing a value returns a strategy chain. Valid strategy values are SINGLE, ANALYTICAL (allows use of the volatility, underlyingPrice, interestRate, and daysToExpiration params to calculate theoretical values), COVERED, VERTICAL, CALENDAR, STRANGLE, STRADDLE, BUTTERFLY, CONDOR, DIAGONAL, COLLAR, or ROLL. Default is SINGLE (Optional)
    • interval: Strike interval for spread strategy chains (Optional)
    • strike: Provide a strike price to return options only at that strike price (Optional)
    • range: Returns options for the given range. Valid ranges are ITM (In the money), NTM (Near the money), OTM (Out of the money), SAK (Strikes above market), SBK (Strikes below market), SNK (Strikes near market), or ALL (All strikes). Default is ALL (Optional)
    • from_date: Only return expirations after this date. For strategies, expiration refers to the nearest term expiration in the strategy. Valid ISO-8601 formats are yyyy-MM-dd or yyyy-MM-dd'T'HH:mm:ssz (Optional)
    • to_date: Only return expirations before this date. For strategies, expiration refers to the nearest term expiration in the strategy. Valid ISO-8601 formats are yyyy-MM-dd or yyyy-MM-dd'T'HH:mm:ssz (Optional)
    • volatility: Volatility to use in calculations. Applies only to ANALYTICAL strategy chains (Optional)
    • underlying_price: Underlying price to use in calculations. Applies only to ANALYTICAL strategy chains (Optional)
    • interest_rate: Interest rate to use in calculations. Applies only to ANALYTICAL strategy chains (Optional)
    • days_to_expiration: Days to expiration to use in calculations. Applies only to ANALYTICAL strategy chains (Optional)
    • expiration_month: Return only options expiring in the specified month. Month is given in the three character format. Example: JAN. Default is ALL (Optional)
    • option_type: Type of contracts to return. Valid option types are S (Standard contracts), NS (Non-standard contracts), or ALL (All contracts). Default is ALL (Optional)

Official Documentation: https://developer.tdameritrade.com/option-chains/apis/get/marketdata/chains

source

pub fn get_preferences(&self, acct_id: i64) -> Result<String, TDAClientError>

Preferences for a specific account

Parameters

  • acct_id: Account number

Official Documentation: https://developer.tdameritrade.com/user-principal/apis/get/accounts/%7BaccountId%7D/preferences-0

source

pub fn update_preferences( &self, acct_id: i64, preference_spec: &str ) -> Result<(), TDAClientError>

Update preferences for a specific account. Please note that the directOptionsRouting and directEquityRouting values cannot be modified via this operation

Parameters

  • acct_id: Account number
  • preference_spec: Preference body

Official Documentation: https://developer.tdameritrade.com/user-principal/apis/put/accounts/%7BaccountId%7D/preferences-0

source

pub fn get_price_history( &self, history_params: &PriceHistory ) -> Result<String, TDAClientError>

Get price history for a symbol

Parameters

  • history_params: PriceHistory object
    • symbol: Enter one symbol (case-sensitive)
    • period_type: The type of period to show. Valid period types are day, month, year, or ytd (year to date)
    • period: The number of periods to show. Valid periods for day are 1, 2, 3, 4, 5, or 10. Valid periods for month are 1, 2, 3, or 6. Valid periods for year are 1, 2, 3, 5, 10, 15, or 20. Valid periods for ytd are 1 (Optional)
    • frequency_type: The type of frequency with which a new candle is formed. Valid frequency types for day are minute. Valid frequency types for month are daily or weekly. Valid frequency types for year are daily, weekly, or monthly. Valid frequency types for ytd are daily or weekly
    • frequency: The number of the frequency_type to be included in each candle. Valid frequencies for minute are 1, 5, 10, 15, or 30. Valid frequencies for daily are 1. Valid frequencies for weekly are 1. Valid frequencies for monthly are 1
    • start_date: Start date as milliseconds since epoch. If start_date and end_date are provided, period should not be provided (Optional)
    • end_date: End date as milliseconds since epoch. If start_date and end_date are provided, period should not be provided (Optional)
    • need_extended_hours_data: Returns extended hours data. Default is true (Optional)

Official Documentation: https://developer.tdameritrade.com/price-history/apis/get/marketdata/%7Bsymbol%7D/pricehistory

source

pub fn get_quote(&self, symbol: &str) -> Result<String, TDAClientError>

Get quote for a symbol

Parameters

  • symbol: Enter one symbol (case-sensitive)

Official Documentation: https://developer.tdameritrade.com/quotes/apis/get/marketdata/%7Bsymbol%7D/quotes

source

pub fn get_quotes(&self, symbols: &Vec<&str>) -> Result<String, TDAClientError>

Get quote for one or more symbols

Parameters

  • symbols: Enter one or more symbols in a vector (case-sensitive)

Official Documentation: https://developer.tdameritrade.com/quotes/apis/get/marketdata/quotes

source

pub fn get_order( &self, acct_id: i64, order_id: i64 ) -> Result<String, TDAClientError>

Get a specific order for a specific account

Parameters

  • acct_id: Account number
  • order_id: Order number

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D/orders/%7BorderId%7D-0

source

pub fn get_orders_by_path( &self, acct_id: i64, max_results: i64, from_entered_time: &str, to_entered_time: &str, status: &str ) -> Result<String, TDAClientError>

Orders for a specific account

Parameters

  • acct_id: Account number
  • max_results: The max number of orders to retrieve
  • from_entered_time: Specifies that no orders entered before this time should be returned. Valid ISO-8601 formats are yyyy-MM-dd
  • to_entered_time: Specifies that no orders entered after this time should be returned. Valid ISO-8601 formats are yyyy-MM-dd
  • status: Specifies that only orders of this status should be returned. Valid statuses are AWAITING_PARENT_ORDER, AWAITING_CONDITION, AWAITING_MANUAL_REVIEW, ACCEPTED, AWAITING_UR_OUT, PENDING_ACTIVATION, QUEUED, WORKING, REJECTED, PENDING_CANCEL, CANCELLED, PENDING_REPLACE, REPLACED, FILLED, or EXPIRED

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D/orders-0

source

pub fn get_orders_by_query( &self, acct_id: Option<i64>, max_results: i64, from_entered_time: &str, to_entered_time: &str, status: &str ) -> Result<String, TDAClientError>

All orders for a specific account or, if acct_id isn’t specified, orders will be returned for all linked accounts

Parameters

  • acct_id: Account number (Optional)
  • max_results: The max number of orders to retrieve
  • from_entered_time: Specifies that no orders entered before this time should be returned. Valid ISO-8601 formats are yyyy-MM-dd
  • to_entered_time: Specifies that no orders entered after this time should be returned. Valid ISO-8601 formats are yyyy-MM-dd
  • status: Specifies that only orders of this status should be returned. Valid statuses are AWAITING_PARENT_ORDER, AWAITING_CONDITION, AWAITING_MANUAL_REVIEW, ACCEPTED, AWAITING_UR_OUT, PENDING_ACTIVATION, QUEUED, WORKING, REJECTED, PENDING_CANCEL, CANCELLED, PENDING_REPLACE, REPLACED, FILLED, or EXPIRED

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/orders-0

source

pub fn place_order( &self, acct_id: i64, order_spec: &str ) -> Result<(), TDAClientError>

Place an order for a specific account. Order throttle limits may apply

Parameters

  • acct_id: Account number
  • order_spec: Order body

Order Examples: https://developer.tdameritrade.com/content/place-order-samples

Official Documentation: https://developer.tdameritrade.com/account-access/apis/post/accounts/%7BaccountId%7D/orders-0

source

pub fn replace_order( &self, acct_id: i64, order_id: i64, order_spec: &str ) -> Result<(), TDAClientError>

Replace an existing order for an account. The existing order will be replaced by the new order. Once replaced, the old order will be canceled and a new order will be created. Order throttle limits may apply

Parameters

  • acct_id: Account number
  • order_id: Order number
  • order_spec: Order body

Order Examples: https://developer.tdameritrade.com/content/place-order-samples

Official Documentation: https://developer.tdameritrade.com/account-access/apis/put/accounts/%7BaccountId%7D/orders/%7BorderId%7D-0

source

pub fn cancel_order( &self, acct_id: i64, order_id: i64 ) -> Result<(), TDAClientError>

Cancel a specific order for a specific account. Order throttle limits may apply

Parameters

  • acct_id: Account number
  • order_id: Order number

Official Documentation: https://developer.tdameritrade.com/account-access/apis/delete/accounts/%7BaccountId%7D/orders/%7BorderId%7D-0

source

pub fn get_saved_order( &self, acct_id: i64, order_id: i64 ) -> Result<String, TDAClientError>

Specific saved order by its ID, for a specific account

Parameters

  • acct_id: Account number
  • order_id: Saved order number

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D/savedorders/%7BsavedOrderId%7D-0

source

pub fn get_saved_orders_by_path( &self, acct_id: i64 ) -> Result<String, TDAClientError>

Saved orders for a specific account

Parameters

  • acct_id: Account number

Official Documentation: https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D/savedorders-0

source

pub fn create_saved_order( &self, acct_id: i64, order_spec: &str ) -> Result<(), TDAClientError>

Save an order for a specific account

Parameters

  • acct_id: Account number
  • order_spec: Order body

Order Examples: https://developer.tdameritrade.com/content/place-order-samples

Official Documentation: https://developer.tdameritrade.com/account-access/apis/post/accounts/%7BaccountId%7D/savedorders-0

source

pub fn replace_saved_order( &self, acct_id: i64, order_id: i64, order_spec: &str ) -> Result<(), TDAClientError>

Replace an existing saved order for an account. The existing saved order will be replaced by the new order

Parameters

  • acct_id: Account number
  • order_id: Order number
  • order_spec: Order body

Order Examples: https://developer.tdameritrade.com/content/place-order-samples

Official Documentation: https://developer.tdameritrade.com/account-access/apis/put/accounts/%7BaccountId%7D/savedorders/%7BsavedOrderId%7D-0

source

pub fn delete_saved_order( &self, acct_id: i64, order_id: i64 ) -> Result<(), TDAClientError>

Delete a specific saved order for a specific account

Parameters

  • acct_id: Account number
  • order_id: Order number

Official Documentation: https://developer.tdameritrade.com/account-access/apis/delete/accounts/%7BaccountId%7D/savedorders/%7BsavedOrderId%7D-0

source

pub fn get_transaction( &self, acct_id: i64, transaction_id: i64 ) -> Result<String, TDAClientError>

Transaction for a specific account

Parameters

  • acct_id: Account number
  • transaction_id: Transaction number

Official Documentation: https://developer.tdameritrade.com/transaction-history/apis/get/accounts/%7BaccountId%7D/transactions/%7BtransactionId%7D-0

source

pub fn get_transactions( &self, acct_id: i64, transaction_type: &str, symbol: Option<&str>, start_date: &str, end_date: &str ) -> Result<String, TDAClientError>

Transactions for a specific account

Parameters

  • acct_id: Account number
  • transaction_type: Only transactions with the specified type will be returned. Valid transaction types are ALL, TRADE, BUY_ONLY, SELL_ONLY, CASH_IN_OR_CASH_OUT, CHECKING, DIVIDEND, INTEREST, OTHER, or ADVISOR_FEES
  • symbol: Only transactions with the specified symbol will be returned (Optional)
  • start_date: Only transactions after the start date will be returned. The maximum date range is one year. Valid ISO-8601 formats are yyyy-MM-dd
  • end_date: Only transactions before the end date will be returned. The maximum date range is one year. Valid ISO-8601 formats are yyyy-MM-dd

Official Documentation: https://developer.tdameritrade.com/transaction-history/apis/get/accounts/%7BaccountId%7D/transactions-0

source

pub fn get_streamer_subscription_keys( &self, acct_ids: &Vec<i64> ) -> Result<String, TDAClientError>

SubscriptionKey for provided accounts or default accounts

Parameters

  • acct_ids: Account number(s)

Official Documentation: https://developer.tdameritrade.com/user-principal/apis/get/userprincipals/streamersubscriptionkeys-0

source

pub fn get_user_principals( &self, fields: Option<&Vec<&str>> ) -> Result<String, TDAClientError>

User principal details

Parameters

  • fields: Enter additional fields into a vector. None of these fields are returned by default. Valid fields are streamerSubscriptionKeys, streamerConnectionInfo, preferences, or surrogateIds (Optional)

Official Documentation: https://developer.tdameritrade.com/user-principal/apis/get/userprincipals-0

source

pub fn get_watchlist( &self, acct_id: i64, watchlist_id: i64 ) -> Result<String, TDAClientError>

Specific watchlist for a specific account

Parameters

  • acct_id: Account number
  • watchlist_id: Watchlist number

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/get/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

source

pub fn get_watchlists_for_single_account( &self, acct_id: i64 ) -> Result<String, TDAClientError>

All watchlists of an account

Parameters

  • acct_id: Account number

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/get/accounts/%7BaccountId%7D/watchlists-0

source

pub fn get_watchlists_for_multiple_accounts( &self ) -> Result<String, TDAClientError>

All watchlists for all of the user’s linked accounts

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/get/accounts/watchlists-0

source

pub fn create_watchlist( &self, acct_id: i64, watchlist_spec: &str ) -> Result<(), TDAClientError>

Create watchlist for specific account. This method does not verify that the symbol or asset type are valid

Parameters

  • acct_id: Account number
  • watchlist_spec: Watchlist body

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/post/accounts/%7BaccountId%7D/watchlists-0

source

pub fn replace_watchlist( &self, acct_id: i64, watchlist_id: i64, watchlist_spec: &str ) -> Result<(), TDAClientError>

Replace watchlist for a specific account. This method does not verify that the symbol or asset type are valid

Parameters

  • acct_id: Account number
  • watchlist_id: Watchlist number
  • watchlist_spec: Watchlist body

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/put/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

source

pub fn update_watchlist( &self, acct_id: i64, watchlist_id: i64, watchlist_spec: &str ) -> Result<(), TDAClientError>

Partially update watchlist for a specific account: change watchlist name, add to the beginning/end of a watchlist, update or delete items in a watchlist. This method does not verify that the symbol or asset type are valid

Parameters

  • acct_id: Account number
  • watchlist_id: Watchlist number
  • watchlist_spec: Watchlist body

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/patch/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

source

pub fn delete_watchlist( &self, acct_id: i64, watchlist_id: i64 ) -> Result<(), TDAClientError>

Delete watchlist for a specific account

Parameters

  • acct_id: Account number
  • watchlist_id: Watchlist number

Official Documentation: https://developer.tdameritrade.com/watchlist/apis/delete/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more