Fetching Trades

Retrieve a list of trades with optional filters using the get_trades() method:

trades = client.get_trades(
    instrument_id=instrument_id,
    instrument_name=instrument_name,
    instrument_type=instrument_type,
    strike_price=strike_price,
    expiration_timestamp=expiration_timestamp,
    option_type=option_type,
    limit=limit,
    offset=offset
)

Parameters:

  • instrument_id (Optional[Union[int, List[int]]]): Filter by instrument ID (default is None)
  • instrument_name (Optional[Union[str, List[str]]]): Filter by instrument name (default is None)
  • instrument_type (Optional[Union[str, List[str]]]): Filter by instrument type (default is None)
  • strike_price (Optional[Union[float, List[float]]]): Filter by strike price (default is None)
  • expiration_timestamp (Optional[Union[str, List[str]]]): Filter by expiration timestamp (default is None)
  • option_type (Optional[Union[str, List[str]]]): Filter by option type (default is None)
  • limit (Optional[int]): Limit the number of results (default is None)
  • offset (Optional[int]): Offset the results (default is None)

The returned list contains Trade objects with the following attributes:

  • created_at: The timestamp when the trade was created, as a string
  • instrument: The instrument associated with the trade, as an Instrument object
  • price: The price of the trade, as a float
  • quantity: The quantity of the trade, as a float
  • order_type (Optional): The type of order associated with the trade, as an OrderType enum
  • order_side (Optional): The side of the order associated with the trade, as an OrderSide enum
  • pnl (Optional): The profit and loss of the trade, as a float
  • fees (Optional): The fees of the trade, as a float
  • is_maker (Optional): Indicates whether the trade was a maker or not, as a boolean
  • taker_side (Optional): The side of the taker order associated with the trade, as an OrderSide enum

Fetching All Trades

Retrieve a list of all trades across instruments with optional filters using the get_all_trades() method:

all_trades = client.get_all_trades(
    instrument_id=instrument_id,
    instrument_name=instrument_name,
    instrument_type=instrument_type,
    strike_price=strike_price,
    expiration_timestamp=expiration_timestamp,
    option_type=option_type,
    limit=limit,
    offset=offset
)

Parameters:

Same as get_trades() method.

The returned list contains Trade objects with the same attributes as described in the get_trades() section.