The Python stack trace for exceptions in scheduled events (in particular in class functions called from such event) is quite cryptic with limited information and lacks line numbers.
Can this be improved?
Example below. Good luck trying to find location of this error!
QuantConnect.Scheduling.ScheduledEventException: In Scheduled Event 'SPY: MonthEnd: SPY: 15 min before MarketClose', ---> System.Exception: ValueError : cannot reindex from a duplicate axis ---> Python.Runtime.PythonException: ValueError : cannot reindex from a duplicate axis
at Python.Runtime.PyObject.Invoke (Python.Runtime.PyObject[] args) [0x00035] in <0f995c28c5b446ad8835419f76b319a3>:0
at QuantConnect.Scheduling.ScheduleManager+<>c__DisplayClass15_0. b__0 (System.String name, System.DateTime time) [0x00007] in :0
at QuantConnect.Scheduling.ScheduledEvent.OnEventFired (System.DateTime triggerTime) [0x00036] in :0
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
Jing Wu
It seems in your scheduled event SPY: MonthEnd: SPY: 15 min before MarketClose you are reindexing the dataframe and there are duplicates in the index. You could try sort the index and drop duplicates. The error message comes from a func object which does not have line numbers,
See this google search for common reasons for this Python Value Error (https://www.google.com/search?q=ValueError+%3A+cannot+reindex+from+a+duplicate+axis&rlz=1C1CHBF_enUS755US755&oq=ValueError+%3A+cannot+reindex+from+a+duplicate+axis&aqs=chrome..69i57&sourceid=chrome&ie=UTF-8)
JM 99
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!