I noticed in my backtest results, that where previously when I saw the status as 'Canceled' that the order had not fills, but now see that that is not necessarily true. For example, I had the following lines in the downloaded orders CSV, which matches the 'Orders' list in the results JSON
2011-10-10T14:00:00Z,WAG 120121P00017500,0.05,365,Limit,Filled,18.25,Accumulate, 365, 0.04, 0.0400, 0.0600, 0.00 %, 3715289.1, 0.0, 0, 0, 0, 33.8350, 0.595236, 0.000058, -0.000037, 0.002879, 0.0000, 0.0000, 3715289.1, 12750.0, 22750.0, 28437.5, 29065.3, 29065.3, 0.05
2011-10-11T14:00:00Z,WAG 120121P00017500,0.06,365,Limit,Filled,21.9,Accumulate, 365, 0.04, 0.0400, 0.0600, 0.00 %, 3715289.1, 1904450.0, 365, 0, 0, 33.4450, 0.589682, 0.000043, -0.000029, 0.002210, -0.0013, 0.0000, 1810839.1, 12750.0, 22750.0, 28437.5, 28781.9, 28781.9, 0.05, 0.06
2011-11-23T15:00:00Z,WAG 120121P00017500,0.02,-730,Limit,Canceled,-14.6,MinExp Unwind, -730, 0.08, 0.0200, 0.1500, 50.00 %, 3701961.6, 3716200.0, 730, 0, 0, 30.4750, 0.752179, 0.000000, 0.000000, 0.000006, 0.0000, 0.0000, -14238.4, 0.07, 0.06, 0.05, 0.04, 0.03, 0.02
2011-12-08T16:00:00Z,WAG 120121P00017500,0,-692,Limit,Canceled,0,MinExp Unwind, -692, 0.02, 0.0200, 0.0300, 100.00 %, 3688556.4, 4073650.0, 692, 0, 0, 34.1750, 0.835793, 0.000000, 0.000000, 0.000002, 0.0000, 0.0000, -385093.6
It turns out when I look at the 'ClosedTrades' in the JSON that the third order to unwind 730 contracts in fact did trade 38 with the remainder canceled. SHouldn't the status here be partially filled and not canceled? If it filled 0 then I would agree it should show canceled, but with anything filled I would expect it to show that status. Additionally, I would have expected the quantity to show -38, not -730 which was the original submitted but not what executed.
Derek Melchin
HI Ari,
We were unable to reproduce this error. Please attach a backtest which produces it.
Best,
Derek Melchin
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.
Ari Cooperman
My guess why you can't reproduce is because you are using the default fill model which never has partial fills (always fills the full amount. If you attach a test fill model (or maybe copy CustomPartialFillModel in CustomPartialFillModelAlgorithm) that forces partial fills, then once you get that partial fill, you cancel the rest of the order (for instance in OnOrderEvent), you should see that the orders.csv and the orders section in the JSON results show the status as canceled and the quantity as the full quantity.
The backtest that had this occur also uses a custom fill model that only fills based on what is available/showing on the bid or ask at the inside price. I no longer have the test that created this data but here is that orders data again but a little clearer, also along with the relevant ClosedTrades json from the results
2011-10-10T14:00:00Z WAG 120121P00017500 0.05 365 Limit Filled 18.25 2011-10-11T14:00:00Z WAG 120121P00017500 0.06 365 Limit Filled 21.9 2011-11-23T15:00:00Z WAG 120121P00017500 0.02 -730 Limit Canceled -14.6 2011-12-08T16:00:00Z WAG 120121P00017500 0 -692 Limit Canceled 0
Â
{ "Symbol": { "Value": "WAG 120121P00017500", .... } }, "EntryTime": "2011-10-10T14:06:00Z", "EntryPrice": 0.05, "Direction": 0, "Quantity": 34, "ExitTime": "2011-11-23T15:36:00Z", "ExitPrice": 0.02, .... } { "Symbol": { "Value": "WAG 120121P00017500", .... } }, "EntryTime": "2011-10-10T14:07:00Z", "EntryPrice": 0.05, "Direction": 0, "Quantity": 4, "ExitTime": "2011-11-23T15:36:00Z", "ExitPrice": 0.02, .... }
You can see that I only was able to fill 38 contracts with that order and the rest was canceled (I removed irrelevant fields for brevity). Then back to the orders.csv, we see that I then later try to unwind the remaining position which is only long 692 now because I partially filled on the earlier.Â
Derek Melchin
Hi Ari,
When an order ticket has been cancelled, it's status is set to cancelled, even if it has been partially filled.
Best,
Derek Melchin
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.
Ari Cooperman
That was my assumption and part of my original question. If you specified partially filled I feel like that provides more information than canceled in that case (Canceled does not tell you anything about whether there were 0 or any fills). If you were to keep it canceled, then why not specify the quantity as the amount canceled and not the whole size? For instance in my example, instead of the line showing a quantity of 730, it would show 692 as that was what was 'canceled'. Even better would be an additional column that shows filled quantity, then by showing a status of canceled and a different fill quantity that the originally submitted quantity I know both that it ended up canceled before it was fully filled AND that some of it was filled and how many.
I wonder what Jared Broad thinks...
Ari Cooperman
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!