On the other note, I was finally able to implement a near-reality workflow model that supports a Limit Order for buys, Cancel for buy orders that are not good any more, and Market Order for sells. I chose this because when I get a sell signal, I don't want to take any risk of waiting for a Limit Sell to happen. So I just sell it for whatever market offers.
Anyway, I tested a sample algo with two models: A. buy at the market value and B. buy with a limit order, By comparing the downloaded trades side by side I can see that backtesting in LEAN is very optimistic at high frequencies such as Second. This is true even for very liquid assets. Basically LEAN just fills the order at the close price or better put, the last price.
The thing is that the close price even at the Second resolution belongs to the past and if I want to buy something at that price, there may or may not be someone out there that offers that ask price.
Of course using Limit Orders could go both ways. I could end up getting a better deal or not anything at all. The problem is that, when I tested the algorithm with those two models, model B turned a profitable results (of the model A) into loss! In the begining I was excited as I thought enabling Limit Order would make the results better for me because either I would only buy at the price that is accepted for the algo. But I guess this surprising outcome is very much related to the level of optimism that comes with the default immediate-fill-at-close-price of LEAN that is, you always get the best offers!
This is a little disappointing and I'm not sure what my next options are at this point especially with the fact that QC doesn't provide historical trade data so you can't even code based on the bid/ask data.
The only remaining hope is that, in real market there is still a good chance that most of the orders that are submitted at the close price are filled one or two seconds later. But even that maybe an optimistic assumption.
By any chance do you have any stats on what percentage of the orders get cancelled in a liquid asset such as SPY?
Thanks again.