santoshlite / Empyrial

An Open Source Portfolio Backtesting Engine for Everyone | 面向所有人的开源投资组合回测引擎
https://empyrial.gitbook.io/empyrial/
MIT License
914 stars 124 forks source link

Rebalancing error. #78

Closed thisisloze closed 1 year ago

thisisloze commented 1 year ago

Describe the bug `from empyrial import empyrial, Engine

portfolio = Engine( start_date = "2020-01-01", end_date = "2023-02-25", portfolio = ["CNQ.TO","MFC.TO","SHOP.TO","CNR.TO","CVE.TO","BCE.TO","ABX.TO","TOU.TO","ENB.TO","RY.TO","ATVI","TRP.TO","SU.TO"], benchmark = ["^GSPTSE"], #SPY is set by default rebalance = "1y" #rebalance every month )

empyrial(portfolio)`

`AttributeError Traceback (most recent call last) in 1 from empyrial import empyrial, Engine 2 ----> 3 portfolio = Engine( 4 start_date = "2020-01-01", 5 end_date = "2023-02-25",

2 frames /usr/local/lib/python3.8/dist-packages/empyrial.py in valid_range(start_date, end_date, rebalance) 753 754 # have to make end date a datetime because strptime is not supported for date --> 755 end_date = dt.datetime(end_date.year, end_date.month, end_date.day) 756 757 # gets the number of days

AttributeError: 'str' object has no attribute 'year'`

Using the Google Colab link on your homepage.

santoshlite commented 1 year ago

Hey, sorry for the late reply! This has now been fixed ;)