/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using QuantConnect.Data.Market;
using Python.Runtime;
namespace QuantConnect.Data.Consolidators
{
///
/// A data consolidator that can make bigger bars from any base data
///
/// This type acts as the base for other consolidators that produce bars on a given time step or for a count of data.
///
/// The input type into the consolidator's Update method
public abstract class TradeBarConsolidatorBase : PeriodCountConsolidatorBase
where T : IBaseData
{
///
/// Creates a consolidator to produce a new 'TradeBar' representing the period
///
/// The minimum span of time before emitting a consolidated bar
protected TradeBarConsolidatorBase(TimeSpan period)
: base(period)
{
}
///
/// Creates a consolidator to produce a new 'TradeBar' representing the last count pieces of data
///
/// The number of pieces to accept before emiting a consolidated bar
protected TradeBarConsolidatorBase(int maxCount)
: base(maxCount)
{
}
///
/// Creates a consolidator to produce a new 'TradeBar' representing the last count pieces of data or the period, whichever comes first
///
/// The number of pieces to accept before emiting a consolidated bar
/// The minimum span of time before emitting a consolidated bar
protected TradeBarConsolidatorBase(int maxCount, TimeSpan period)
: base(maxCount, period)
{
}
///
/// Creates a consolidator to produce a new 'TradeBar' representing the last count pieces of data or the period, whichever comes first
///
/// Func that defines the start time of a consolidated data
protected TradeBarConsolidatorBase(Func func)
: base(func)
{
}
///
/// Creates a consolidator to produce a new 'TradeBar' representing the last count pieces of data or the period, whichever comes first
///
/// Python function object that defines the start time of a consolidated data
protected TradeBarConsolidatorBase(PyObject pyfuncobj)
: base(pyfuncobj)
{
}
///
/// Gets a copy of the current 'workingBar'.
///
public TradeBar WorkingBar => (TradeBar) WorkingData;
}
}