I'm new to QuantConnect. Very impressed so far.
I'm trying to backtest an external system I wrote that produces buy/short signals on stocks using QC's python environment. I am simply reading in a csv formatted blob of text into a dictionary and executing trades based on that. In order to determine the volume of the trade, however, I want to get the current price info so that I can make a better order with limits and calculate how many shares to buy.
In the attached code, `self.Identity(symbol).Current.Value` always returns 0.0. How can I get the price info? Preferrably something like hi/lo or bid/ask values.
Another question: How do I configure the trade fee?
Also, many of the trades come back as Invalid with no explanation. I assume that some of these are due to the fact that hedging is not supported, but not all the invalid trades are hedges. How can I get more details on the Invalid status?
To get this far I've had to explore the Lean source, but it's slow going as I learn the structure.
Thanks
Michael Manus
Michael Manus
ups sorry i copied the wrong code. i forgot to klick on the pyhton examples. my fault. sorry
James Salsman
James Salsman
James Salsman
Alexandre Catarino
We can get OHLC (and/or Bid/Ask if we are trading FX and CDF) from the OnData parameter:
def OnData(self, slice): stock_price = slice[symbol].Price
Please checkout the attached project where we changed the original code.
About custom fees:
It is a feature that will be implemented in the new python framework.
Spencer Wasden
Alexandre,
Your comment says:
Your code says:
Are the Price and Value members the same?
Thanks,
Spencer
Louis Szeto
Hi Spencer
Yes, they're the same in this case.
Best
Louis
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.
Jordan Sitkin
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!