Hi,
I'm trying to run a very simple BTCUSD algorithm with QuantConnect Paper Trading.
The algorithm receives fresh BTCUSD minute data correctly, but a Market Order remains indefinitely in Submitted status and is never filled.
Configuration:
- QuantConnect Paper Trading
- L-MICRO live node
- NY7
- QuantConnect data provider
- BTCUSD / Coinbase
- Minute resolution
- USD cash account
Example from the live log:
FRESH BTC DATA | Price=77267.04
Immediately after receiving that fresh data:
SENDING MARKET BUY | Qty=0.001
The resulting order event is:
Status=Submitted | Qty=0 | Fill=0.00
The order remains Submitted in the Orders tab with $0.00 fill.
I also tested both BrokerageName.QuantConnectBrokerage and BrokerageName.Coinbase, with the same result.
Minimal reproduction:
using QuantConnect;
using QuantConnect.Algorithm;
using QuantConnect.Brokerages;
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Orders;
public class BtcPaperFillTest : QCAlgorithm
{
private Symbol _btc;
private bool _sent;
public override void Initialize()
{
SetCash(10000);
SetBrokerageModel(
BrokerageName.QuantConnectBrokerage,
AccountType.Cash
);
_btc = AddCrypto(
"BTCUSD",
Resolution.Minute,
Market.Coinbase
).Symbol;
}
public override void OnData(Slice data)
{
if (_sent || !data.Bars.ContainsKey(_btc))
return;
var price = Securities[_btc].Price;
if (price <= 0)
return;
Log($"FRESH BTC DATA | Price={price:F2}");
MarketOrder(
_btc,
0.001m,
tag: "PAPER FILL TEST"
);
_sent = true;
}
public override void OnOrderEvent(OrderEvent orderEvent)
{
Log(
$"ORDER EVENT | " +
$"Status={orderEvent.Status} | " +
$"Qty={orderEvent.FillQuantity} | " +
$"Fill={orderEvent.FillPrice:F2} | " +
$"Message={orderEvent.Message}"
);
}
}
Since BTCUSD trades 24/7 and the algorithm is receiving fresh data immediately before submitting the order, I expected the Paper Trading market order to fill immediately.
Is there anything missing from this configuration, or is there currently an issue with BTCUSD fills in QuantConnect Paper Trading?
Thanks.
Alexandre Catarino
Hi Eric,
Thanks for the minimal reproduction. Your configuration is fine; nothing is missing from it.
We have seen this exact symptom before on live Paper Trading with Coinbase crypto pairs. The default crypto fill model prices market orders off the latest quote (bid/ask) data. When the live quote bars for a pair stop updating while trade bars keep arriving, the fill model sees the quote as stale and keeps waiting for fresh quote data, so the order sits in Submitted with no further event. Fresh trade bars in OnData do not unblock it, which matches what you see.
A quick way to confirm it on your deployment is to log the quote side next to the trade side:
If HasQuote stays false and the bid/ask do not move while the price does, that is the cause.
Workaround: use the Equity fill model for the crypto security. It falls back to trade data when the quote is stale, so the market order fills (with a warning message on the order event):
Note that this fills at the last trade price instead of the bid/ask, so paper fills will be slightly optimistic compared with a real exchange. When quote data is flowing normally, both models fill at the same price.
Best regards,
Alex
Eric S.
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!