1+ from datetime import datetime
12from investing_algorithm_framework .domain import PortfolioConfiguration , \
23 OperationalException
34from .portfolio_service import PortfolioService
@@ -10,8 +11,10 @@ class BacktestPortfolioService(PortfolioService):
1011 not check if the initial balance is present on the exchange or broker.
1112 """
1213 def create_portfolio_from_configuration (
13- self , portfolio_configuration : PortfolioConfiguration ,
14- initial_amount = None
14+ self ,
15+ portfolio_configuration : PortfolioConfiguration ,
16+ initial_amount = None ,
17+ created_at : datetime = None
1518 ):
1619 """
1720 Wil create a portfolio from a portfolio configuration for backtesting.
@@ -20,6 +23,9 @@ def create_portfolio_from_configuration(
2023 portfolio_configuration (PortfolioConfiguration):
2124 Portfolio configuration to create the portfolio from
2225 initial_amount (Decimal): Initial balance for the portfolio
26+ created_at (datetime): The date and time when the portfolio
27+ is created. If not provided, the current date and time
28+ will be used.
2329
2430 Returns:
2531 Portfolio: The created portfolio
@@ -41,6 +47,7 @@ def create_portfolio_from_configuration(
4147 "market" : portfolio_configuration .market ,
4248 "trading_symbol" : portfolio_configuration .trading_symbol ,
4349 "unallocated" : amount ,
44- "initialized" : True
50+ "initialized" : True ,
51+ "created_at" : created_at
4552 }
4653 return self .create (data )
0 commit comments