QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.66k stars 3.24k forks source link

Trading hours on Independence Day 2017 and after Thanksgiving Day #641

Closed michaelsrew closed 7 years ago

michaelsrew commented 7 years ago

I think QuantConnect.Lean trades during after hours like it would be normal trading hours on the 25.11. The after hours startet on the 25.11 at 13:00 till 17:00 i think.

https://www.nyse.com/markets/hours-calendars

check also Christmas Eve Observed on the 23.11 maybe it is also till 13:00.

best regards

michaelsrew commented 7 years ago

From Terminal: //test public class BasicTemplateAlgorithm : QCAlgorithm { public override void Initialize() { SetStartDate(2016, 11, 25);
SetEndDate(2016, 11, 26); SetCash(25000); AddSecurity(SecurityType.Equity, "VRX", Resolution.Minute, true, false); }

    public void OnData(TradeBars data) 
    {   
        if (!Portfolio.HoldStock) 
        {
            int quantity = (int)Math.Floor(Portfolio.Cash / data["VRX"].Close);      
            if (Time.Hour > 14) {
                Order("VRX",  quantity);
                Debug("Purchased SPY on " + Time.ToShortDateString() + " " + Time.ToShortTimeString());
            }
        }
    }
}

Downloaded Trade CSV File: Time,Symbol,Price,Quantity,Type,Status,Value,Tag 2016-11-25T20:00:00Z,VRX,17.03,1467,Market,3,24983.01,

Backtest Console: Successfully sent backtest request for 'Muscular Black Cormorant', (Compile Id: 0760a76d23f295a7b1ba092dee6af187) 166 | 10:56:38: Backtest ID: 98f4ea612126666675c34def8d46c5a6 successfully sent to cloud. 167 | 10:56:47: Launching analysis for 98f4ea612126666675c34def8d46c5a6 with LEAN Engine v2.2.0.2.893 168 | 10:56:47: Purchased SPY on 11/25/2016 15:00 169 | 10:56:47: Algorithm Id:(98f4ea612126666675c34def8d46c5a6) completed in 0.25 seconds at 2k data points per second. Processing total of 394 data points.

best regards

jaredbroad commented 7 years ago

Might be a data issue? It should not have any data after 1pm, so the OnData shouldn't be called

On Fri, Dec 2, 2016 at 10:58 AM, michaelsrew notifications@github.com wrote:

From Terminal: //test public class BasicTemplateAlgorithm : QCAlgorithm { public override void Initialize() { SetStartDate(2016, 11, 25); SetEndDate(2016, 11, 26); SetCash(25000); AddSecurity(SecurityType.Equity, "VRX", Resolution.Minute, true, false); }

public void OnData(TradeBars data)
{
    if (!Portfolio.HoldStock)
    {
        int quantity = (int)Math.Floor(Portfolio.Cash / data["VRX"].Close);
        if (Time.Hour > 14) {
          Order("VRX",  quantity);
          Debug("Purchased SPY on " + Time.ToShortDateString() + " " + Time.ToShortTimeString());
        }
    }
}

}

Downloaded Trade CSV File: Time,Symbol,Price,Quantity,Type,Status,Value,Tag 2016-11-25T20:00:00Z,VRX,17.03,1467,Market,3,24983.01,

Backtest Console: Successfully sent backtest request for 'Muscular Black Cormorant', (Compile Id: 0760a76d23f295a7b1ba092dee6af187) 166 | 10:56:38: Backtest ID: 98f4ea612126666675c34def8d46c5a6 successfully sent to cloud. 167 | 10:56:47: Launching analysis for 98f4ea612126666675c34def8d46c5a6 with LEAN Engine v2.2.0.2.893 168 | 10:56:47: Purchased SPY on 11/25/2016 15:00 169 | 10:56:47: Algorithm Id:(98f4ea612126666675c34def8d46c5a6) completed in 0.25 seconds at 2k data points per second. Processing total of 394 data points.

best regards

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/QuantConnect/Lean/issues/641#issuecomment-264488280, or mute the thread https://github.com/notifications/unsubscribe-auth/ACI6mY1OuAgyo78QPGeYKl5vRaKorhfsks5rEEAXgaJpZM4K87DD .

-- Jared Broad

www.quantconnect.com Phone-USA: +1 917 327 0556 Democratizing Finance, Empowering Individuals Facebook http://www.facebook.com/QuantConnect | Twitter https://twitter.com/#!/QuantConnect | LinkedIn http://www.linkedin.com/company/quantconnect | Skype: jaredbroad

michaelsrew commented 7 years ago

Hmm it works with almost every stock.... SPY, GOOG,..... :)

michaelsrew commented 7 years ago

Or, i dont exactly know how it works but..... the FILLFORWARD is true so because of the trading hours it bought the stock... maybe.

jaredbroad commented 7 years ago

Yes that'll be it -- the FF is creating the bars and the market hours don't support half days yet. Thank you for reporting, we'll try and submit a fix soon.

jaredbroad commented 7 years ago

Fixed in #656