alpheast.portfolio.portfolio module¶
- class alpheast.portfolio.portfolio.Portfolio(initial_cash, transaction_cost_percent=Decimal('0.001'))[source]¶
Bases:
object- buy(symbol, quantity, price, timestamp, commission=Decimal('0.0'))[source]¶
Executes a buy order, updates cash, holdings, and logs the trade. Assumes the order is valid (e.g., sufficient cash checked externally by PortfolioManager). Accepts commission directly from the fill event.
- Return type:
Dict[str,Any]
- sell(symbol, quantity, price, timestamp, commission=Decimal('0.0'))[source]¶
Executes a sell order, updates cash, holdings, and logs the trade. Assumes the order is valid (e.g., sufficient holdings checked externally by PortfolioManager). Accepts commission directly from the fill event.
- Return type:
Dict[str,Any]
- get_current_value(current_prices)[source]¶
Calculates the current total value of the portfolio(cash + value of holdings).
- Parameters:
current_prices (
Dict[str,Decimal]) – A dictionary of {symbol: current_price} for held assets. This will be passed from the Backtester using the current day’s close price.- Return type:
Decimal
- get_total_value(current_market_prices)[source]¶
Calculates the total current value of the portfolio (cash + value of holdings).
- Parameters:
current_market_prices (
Dict[str,Decimal]) – A dictionary mapping symbol (str) to its latest price (Decimal). This dict should contain prices for all symbols currently held.- Return type:
Decimal- Returns:
The total value of the portfolio as a Decimal.