1
+ from datetime import datetime
1
2
from investing_algorithm_framework .domain import PortfolioConfiguration , \
2
3
OperationalException
3
4
from .portfolio_service import PortfolioService
@@ -10,8 +11,10 @@ class BacktestPortfolioService(PortfolioService):
10
11
not check if the initial balance is present on the exchange or broker.
11
12
"""
12
13
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
15
18
):
16
19
"""
17
20
Wil create a portfolio from a portfolio configuration for backtesting.
@@ -20,6 +23,9 @@ def create_portfolio_from_configuration(
20
23
portfolio_configuration (PortfolioConfiguration):
21
24
Portfolio configuration to create the portfolio from
22
25
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.
23
29
24
30
Returns:
25
31
Portfolio: The created portfolio
@@ -41,6 +47,7 @@ def create_portfolio_from_configuration(
41
47
"market" : portfolio_configuration .market ,
42
48
"trading_symbol" : portfolio_configuration .trading_symbol ,
43
49
"unallocated" : amount ,
44
- "initialized" : True
50
+ "initialized" : True ,
51
+ "created_at" : created_at
45
52
}
46
53
return self .create (data )
0 commit comments