Skip to content

Async Client

AsyncTradingClient provides full parity with TradingClient. Every sync method has an async equivalent.

Basic Usage

python
import asyncio
from aqc_trading_sdk import AsyncTradingClient

async def main():
    client = AsyncTradingClient(strategy_id="AQC-P1A2B3C4")

    # All methods are async
    account = await client.get_account()
    quote = await client.get_quote("SPY")
    positions = await client.get_positions()
    result = await client.buy_market("SPY", 10)

    await client.close()

asyncio.run(main())

Position Cache

AsyncTradingClient has the same 1-second position cache as the sync client:

python
positions = await client.get_positions()                    # Cached
position = await client.get_position("AAPL")                # From cache
position = await client.get_position("AAPL", force_refresh=True)  # Fresh
client.invalidate_position_cache()                          # Clear cache

Session Management

Always call close() when done:

python
await client.close()

Or use async context management:

python
async with AsyncTradingClient(strategy_id="AQC-P1A2B3C4") as client:
    quote = await client.get_quote("SPY")

Streaming

python
async def on_order_update(update):
    print("Order:", update)

await client.stream_order_updates(on_order_update)

Method Parity

All sync methods are available as async:

CategoryMethods
Accountget_account, get_account_summary, get_account_id, get_account_values, get_account_value, get_pnl, get_position_pnl, get_margin
Positionsget_positions, get_position, has_position, get_open_position, close_position, invalidate_position_cache
Ordersget_orders, get_open_orders, get_open_trades, get_trades, place_order, buy_market, sell_market, buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit, sell_stop_limit, buy_trail, sell_trail, cancel_order, cancel_all_orders, modify_order, get_order_status, wait_for_fill, wait_for_submitted, place_bracket_order, place_trailing_stop, place_adaptive_order, get_order_impact, place_combo_order, place_vertical_spread, place_iron_condor
Market Dataget_quote, get_price, get_tickers, get_dividend_yield, get_history, get_historical_bars, get_historical_data, get_market_depth, get_last_trade, get_ticks, get_halt_status, is_halted, get_trading_hours, is_market_open_for
Optionsget_option_contract, get_option_contracts, get_options_chain, get_strikes, get_option_by_delta, get_atm_strike, get_option_expirations, get_option_quote, get_option_quotes, get_greeks, get_option_greeks_batch, get_option_oi, get_option_volume
Contractsget_conid, get_index_conid, search_contracts, get_contract_details, qualify_contract
Calendarget_market_time, is_market_open, get_eastern_time, is_within_trade_window, is_eod, get_trading_calendar, get_next_market_open, get_next_market_close, count_trading_days
Emergencyaccount_kill_switch, flatten_all, strategy_kill_switch
Statusget_status, is_connected, get_connection_status
Streamingstream_order_updates