py_alpaca_api.models.order_model

Attributes

KEY_PROCESSORS

Classes

OrderModel

Functions

extract_class_data(data_dict, field_processors, data_class)

Extracts and processes data from a dictionary based on a given data class and field processors.

process_legs(→ list[OrderModel])

Process the legs and create a list of OrderModel objects based on the provided data.

order_class_from_dict(→ OrderModel)

Creates an instance of OrderModel using the provided dictionary data.

Module Contents

py_alpaca_api.models.order_model.KEY_PROCESSORS[source]
py_alpaca_api.models.order_model.extract_class_data(data_dict: dict, field_processors: dict, data_class: type[Any])[source]

Extracts and processes data from a dictionary based on a given data class and field processors.

Parameters:
  • data_dict (dict) – The dictionary containing the data to be processed.

  • field_processors (Dict) – A dictionary of field processors.

  • data_class (type[Any]) – The data class used to define the fields and types.

Returns:

A dictionary containing processed data, with keys corresponding to the fields of the data class.

Return type:

dict

Raises:

KeyError – When a field processor is not found for a specific data type.

class py_alpaca_api.models.order_model.OrderModel[source]
id: str[source]
client_order_id: str[source]
created_at: datetime.datetime[source]
updated_at: datetime.datetime[source]
submitted_at: datetime.datetime[source]
filled_at: datetime.datetime[source]
expired_at: datetime.datetime[source]
canceled_at: datetime.datetime[source]
failed_at: datetime.datetime[source]
replaced_at: datetime.datetime[source]
replaced_by: str[source]
replaces: str[source]
asset_id: str[source]
symbol: str[source]
asset_class: str[source]
notional: float[source]
qty: float[source]
filled_qty: float[source]
filled_avg_price: float[source]
order_class: str[source]
order_type: str[source]
type: str[source]
side: str[source]
time_in_force: str[source]
limit_price: float[source]
stop_price: float[source]
status: str[source]
extended_hours: bool[source]
legs: list[object][source]
trail_percent: float[source]
trail_price: float[source]
hwm: float[source]
subtag: str[source]
source: str[source]
py_alpaca_api.models.order_model.process_legs(legs: list[dict]) list[OrderModel][source]

Process the legs and create a list of OrderModel objects based on the provided data.

Parameters:

legs (List[Dict]) – A list of dictionaries representing the legs.

Returns:

A list of OrderModel objects generated from the leg data.

Return type:

List[OrderModel]

Note

If the legs parameter is empty, an empty list will be returned.

py_alpaca_api.models.order_model.order_class_from_dict(data_dict: dict) OrderModel[source]

Creates an instance of OrderModel using the provided dictionary data.

Parameters:

data_dict (Dict) – A dictionary containing the data used to create the OrderModel instance.

Returns:

An instance of OrderModel created using the provided data.

Return type:

OrderModel

Raises:

None