py_alpaca_api.models.position_model

Attributes

KEY_PROCESSORS

Classes

PositionModel

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.

position_class_from_dict(→ PositionModel)

Returns a PositionModel object created from a given data dictionary.

Module Contents

py_alpaca_api.models.position_model.KEY_PROCESSORS[source]
py_alpaca_api.models.position_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.position_model.PositionModel[source]
asset_id: str[source]
symbol: str[source]
exchange: str[source]
asset_class: str[source]
avg_entry_price: float[source]
qty: float[source]
qty_available: float[source]
side: str[source]
market_value: float[source]
cost_basis: float[source]
profit_dol: float[source]
profit_pct: float[source]
intraday_profit_dol: float[source]
intraday_profit_pct: float[source]
portfolio_pct: float[source]
current_price: float[source]
lastday_price: float[source]
change_today: float[source]
asset_marginable: bool[source]
py_alpaca_api.models.position_model.position_class_from_dict(data_dict: dict) PositionModel[source]

Returns a PositionModel object created from a given data dictionary.

Parameters:

data_dict – A dictionary containing the data for creating a PositionModel object.

Returns:

A PositionModel object created using the data from the dictionary.

Return type:

PositionModel