I try to create Decimal with string in constructor, but I have error:
An error occurred during this backtest:
During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/project/main.pyc. AlgorithmPythonWrapper():
Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'str'>) method. Please checkout the
API documentation.
at <module>
tick_size = Decimal('0.01')
^^^^^^^^^^^^^^^
in main.py: line 100
No method matches given arguments for .ctor: (<class 'str'>)
Workspace python is 3.12.
Mia Alissi
The error message you're seeing is due to an issue with the way you're trying to create a Decimal object in Python. The error message suggests that there's a problem with the arguments you're passing to the Decimal constructor.
In Python, you can create a Decimal object from a string like this:
This should work without any issues. If you're still encountering problems, it might be due to other parts of your code. Make sure that the 'Decimal' class is properly imported and that the string you're passing to the Decimal constructor is a valid number.
If you're still having trouble, you might want to check out the QuantConnect forum for more help. There are many discussions there about various issues users have encountered, and you might find a solution to your problem.
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.
Igor
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!