/// <summary> /// Creates a new Bars stream instance. /// If barsNumber is less than zero then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: /// Bar.From >= startTime for forward enumeration /// Bar.To <= startTime for backward enumeration /// </summary> /// <param name="datafeed">Datafeed instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="barsNumber">Requested bars number; positive value means forward enumeration; negative value means backward enumeration.</param> /// <param name="preferredBufferSize">Bars enumeration requests bars from server by chunks. This is preferred chunk size. It should be positive.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">If preferredBufferSize is less than 2.</exception> public PairBars(DataFeed datafeed, string symbol, BarPeriod period, DateTime startTime, int barsNumber, int preferredBufferSize) { this.bids = new Bars(datafeed, symbol, PriceType.Bid, period, startTime, barsNumber, preferredBufferSize); this.asks = new Bars(datafeed, symbol, PriceType.Ask, period, startTime, barsNumber, preferredBufferSize); this.positive = (barsNumber >= 0); this.count = Math.Abs(barsNumber); }
/// <summary> /// The constructor takes snapshot from manager. /// </summary> /// <param name="snapshot">a snapshot instance</param> /// <param name="storage"></param> /// <param name="symbol"></param> /// <param name="periodicity"></param> /// <param name="priceType"></param> /// <exception cref="System.ArgumentNullException">if snapshot is null</exception> public Snapshot(Snapshot snapshot, DataFeedStorage storage, string symbol, BarPeriod periodicity, PriceType priceType) { if (snapshot == null) throw new ArgumentNullException(nameof(snapshot)); if (storage == null) throw new ArgumentNullException(nameof(storage)); this.IsFeedLoggedOn = snapshot.IsFeedLoggedOn; this.IsTradeLoggedOn = snapshot.IsTradeLoggedOn; this.AccountInfo = snapshot.AccountInfo; this.FeedSessionInfo = snapshot.FeedSessionInfo; this.TradeSessionInfo = snapshot.TradeSessionInfo; this.TradeRecords = snapshot.TradeRecords; this.Positions = snapshot.Positions; this.Quotes = snapshot.Quotes; this.Symbols = snapshot.Symbols; this.storage = storage; this.symbol = symbol; this.periodicity = periodicity; this.priceType = priceType; this.synchronizer = snapshot.synchronizer; }
/// <summary> /// Creates a new Bars stream instance. /// If barsNumber is less than zero then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: /// Bar.From >= startTime for forward enumeration /// Bar.To <= startTime for backward enumeration /// </summary> /// <param name="storage">Online/Offline provider of data feed storage instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="barsNumber">Requested bars number; positive value means forward enumeration; negative value means backward enumeration.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> public PairBars(IStorage storage, string symbol, BarPeriod period, DateTime startTime, int barsNumber) { this.bids = new Bars(storage, symbol, PriceType.Bid, period, startTime, barsNumber); this.asks = new Bars(storage, symbol, PriceType.Ask, period, startTime, barsNumber); this.positive = (barsNumber >= 0); this.count = Math.Abs(barsNumber); }
public BarsCountEnumerator(DataFeed dataFeed, IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber, int preferredBufferSize) : base(dataFeed, storage, symbol, priceType, period, startTime, preferredBufferSize) { this.barsNumber = barsNumber; this.Reset(); }
public BarsTimeIntervalEnumerator(DataFeed dataFeed, IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime, int preferredBufferSize) : base(dataFeed, storage, symbol, priceType, period, startTime, preferredBufferSize) { this.endTime = endTime; this.Reset(); }
public Exporter(string storageLocation, string outputFile, string symbol, BarPeriod period, DateTime from, DateTime to, double contractSize, bool removeDuplicateEntries, int progressResolution) { this.m_storageLocation = storageLocation; this.m_outputFile = outputFile; this.m_symbol = symbol; this.m_period = period; this.m_from = from; this.m_to = to; this.m_contractSize = contractSize; var interval = m_to - m_from; this.m_interval = interval.TotalSeconds; this.m_removeDuplicateEntries = removeDuplicateEntries; this.m_progressResolution = progressResolution; this.thread = new Thread(ThreadMethod); }
internal override void Initialize(Manager manager, IStrategyLog log, string symbol, PriceType priceType, BarPeriod periodicity) { if (manager == null) throw new ArgumentNullException("manager"); if (log == null) throw new ArgumentNullException("log"); this.manager = manager; this.log = log; this.symbol = symbol; this.priceType = priceType; this.periodicity = periodicity; this.manager.Updated += this.OnUpdated; }
static void ValidateArguments(IStorage storage, string symbol, BarPeriod period) { if (storage == null) { throw new ArgumentNullException(nameof(storage), "Storage provider instance can not be null."); } if (symbol == null) { throw new ArgumentNullException(nameof(symbol), "Symbol can not be null."); } if (period == null) { throw new ArgumentNullException(nameof(period), "Bar period instance can not be null."); } }
private DateTime GetBarPeriodicity(DateTime timestamp, BarPeriod barPeriod) { Periodicity periodicity = new Periodicity(); Periodicity.TryParse(barPeriod.ToString(), out periodicity); if (this.GetDirection() == Direction.Forward) { return(periodicity.GetPeriodStartTime(timestamp)); } else if (this.GetDirection() == Direction.Backward) { return(periodicity.GetPeriodStartTime(periodicity.Shift(timestamp, 1))); } else { return(timestamp); } }
static void ValidateArguments(DataFeed datafeed, string symbol, BarPeriod period, int preferredBufferSize) { if (datafeed == null) { throw new ArgumentNullException(nameof(datafeed), "DataFeed instance can not be null."); } if (symbol == null) { throw new ArgumentNullException(nameof(symbol), "Symbol can not be null."); } if (period == null) { throw new ArgumentNullException(nameof(period), "Bar period instance can not be null."); } if (preferredBufferSize <= 1) { throw new ArgumentOutOfRangeException(nameof(preferredBufferSize), preferredBufferSize, "Preferred buffer size should be more than 1."); } }
public BarsTimeIntervalEnumerator(DataFeed dataFeed, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime, int preferredBufferSize) : this(dataFeed, null, symbol, priceType, period, startTime, endTime, preferredBufferSize) { }
public BarsTimeIntervalEnumerator(IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime) : this(null, storage, symbol, priceType, period, startTime, endTime, 0) { }
protected DirectionalBarsEnumerator(DataFeed dataFeed, IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int preferredBufferSize) : base(dataFeed, storage, symbol, priceType, period, startTime, preferredBufferSize) { }
public BarsCountEnumerator(DataFeed dataFeed, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber, int preferredBufferSize) : this(dataFeed, null, symbol, priceType, period, startTime, barsNumber, preferredBufferSize) { }
/// <summary> /// Creates a new Bars stream instance. /// If startTime is less or equal than endTime then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: Min(startTime, endTime) <= Bar.From and Bar.To <= Max(startTime, endTime) /// </summary> /// <param name="datafeed">Datafeed instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="endTime">A end time of bars enumeration.</param> /// <param name="preferredBufferSize">Bars enumeration requests bars from server by chunks. This is preferred chunk size. It should be positive.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">If preferredBufferSize is less than 2.</exception> public PairBars(DataFeed datafeed, string symbol, BarPeriod period, DateTime startTime, DateTime endTime, int preferredBufferSize) { this.bids = new Bars(datafeed, symbol, PriceType.Bid, period, startTime, endTime, preferredBufferSize); this.asks = new Bars(datafeed, symbol, PriceType.Ask, period, startTime, endTime, preferredBufferSize); this.positive = DateTime.Compare(startTime, endTime) >= 0; }
/// <summary> /// The method takes the full snapshot of the manager state. /// </summary> /// <returns></returns> public Snapshot TakeSnapshot(string symbol, PriceType priceType, BarPeriod periodicity) { lock (this.synchronizer) { var result = new Snapshot(this.Snapshot, this.storage, symbol, periodicity, priceType); return result; } }
/// <summary> /// Creates a new Bars stream instance. /// If startTime is less or equal than endTime then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: Min(startTime, endTime) <= Bar.From and Bar.To <= Max(startTime, endTime) /// </summary> /// <param name="datafeed">DataFeed instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="endTime">A end time of bars enumeration.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> public Bars(DataFeed datafeed, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime) : this(datafeed, symbol, priceType, period, startTime, endTime, DefaultBufferSize) { }
/// <summary> /// Returns history bars for a specified symbol /// </summary> /// <param name="symbol">a requested symbol</param> /// <param name="period">a requested period</param> /// <returns></returns> public Bar[] GetBars(string symbol, BarPeriod period) { var request = string.Format("{0}:{1}", symbol, period); Bar[] result; this.requestToBars.TryGetValue(request, out result); if (result != null) return result; var priceType = PriceType.Bid; if (symbol.EndsWith(AskSuffix, StringComparison.InvariantCulture)) { symbol = symbol.Substring(0, symbol.Length - AskSuffix.Length); priceType = PriceType.Ask; } if (this.ServerDateTime > DateTime.MinValue) result = storage.Online.GetBars(symbol, priceType, period, this.ServerDateTime, -RequestedBarsNumber); else result = new Bar[0]; this.requestToBars[request] = result; return result; }
public BarsCountEnumerator(IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber) : this(null, storage, symbol, priceType, period, startTime, barsNumber, 0) { }
static PairBar[] GetPairBarsSymbolArray(string symbol, BarPeriod period, DateTime startTime, int barsNumber) { return FdkHelper.Wrapper.ConnectLogic.Storage.Online.GetPairBars(symbol, period, startTime, barsNumber).ToArray(); }
internal static PairBar[] GetPairBarsSymbolArrayRangeTime(string symbol, BarPeriod period, DateTime startTime, DateTime endTime) { return FdkHelper.Wrapper.ConnectLogic.Storage.Online.GetPairBars(symbol, period, startTime, endTime).ToArray(); }
/// <summary> /// Creates a new Bars stream instance. /// If barsNumber is less than zero then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: /// Bar.From >= startTime for forward enumeration /// Bar.To <= startTime for backward enumeration /// </summary> /// <param name="storage">Online/Offline provider of data feed storage instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="barsNumber">Requested bars number; positive value means forward enumeration; negative value means backward enumeration.</param> /// <exception cref="System.ArgumentNullException">If storage, period or symbol is null.</exception> public Bars(IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber) { ValidateArguments(storage, symbol, period); this.enumerator = new BarsCountEnumerator(storage, symbol, priceType, period, startTime, barsNumber); }
/// <summary> /// Creates a new Bars stream instance. /// If startTime is less or equal than endTime then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: Min(startTime, endTime) <= Bar.From and Bar.To <= Max(startTime, endTime) /// </summary> /// <param name="datafeed">DataFeed instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="endTime">A end time of bars enumeration.</param> /// <param name="preferredBufferSize">Bars enumeration requests bars from server by chunks. This is preferred chunk size. It should be positive.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">If preferredBufferSize is less than 2.</exception> public Bars(DataFeed datafeed, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime, int preferredBufferSize) { ValidateArguments(datafeed, symbol, period, preferredBufferSize); this.enumerator = new BarsTimeIntervalEnumerator(datafeed, symbol, priceType, period, startTime, endTime, preferredBufferSize); }
/// <summary> /// Creates a new Bars stream instance. /// If barsNumber is less than zero then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: /// Bar.From >= startTime for forward enumeration /// Bar.To <= startTime for backward enumeration /// </summary> /// <param name="datafeed">Datafeed instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="barsNumber">Requested bars number; positive value means forward enumeration; negative value means backward enumeration.</param> /// <param name="preferredBufferSize">Bars enumeration requests bars from server by chunks. This is preferred chunk size. It should be positive.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">If preferredBufferSize is less than 2.</exception> public Bars(DataFeed datafeed, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber, int preferredBufferSize) { ValidateArguments(datafeed, symbol, period, preferredBufferSize); this.enumerator = new BarsCountEnumerator(datafeed, symbol, priceType, period, startTime, barsNumber, preferredBufferSize); }
/// <summary> /// The method gets history bars from the server. /// </summary> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="time">Date and time which specifies the historical point.</param> /// <param name="barsNumber">The maximum number of bars in the requested chart. The value can be negative or positive. /// Positive value means historical chart from the specified historical point to future.</param> /// <param name="priceType">Can be bid or ask.</param> /// <param name="period">Chart periodicity.</param> /// <returns>Can not be null.</returns> public DataHistoryInfo GetHistoryBars(string symbol, DateTime time, int barsNumber, PriceType priceType, BarPeriod period) { return(this.GetHistoryBarsEx(symbol, time, barsNumber, priceType, period, this.Client.SynchOperationTimeout)); }
/// <summary> /// Creates a new PairBars stream instance. /// If startTime is less or equal than endTime then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: Min(startTime, endTime) <= Bar.From and Bar.To <= Max(startTime, endTime) /// </summary> /// <param name="storage">Online/Offline provider of data feed storage instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="endTime">A end time of bars enumeration.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> public PairBars(IStorage storage, string symbol, BarPeriod period, DateTime startTime, DateTime endTime) { this.bids = new Bars(storage, symbol, PriceType.Bid, period, startTime, endTime); this.asks = new Bars(storage, symbol, PriceType.Ask, period, startTime, endTime); this.positive = DateTime.Compare(startTime, endTime) >= 0; }
/// <summary> /// Creates a new Bars stream instance. /// If startTime is less or equal than endTime then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: Min(startTime, endTime) <= Bar.From and Bar.To <= Max(startTime, endTime) /// </summary> /// <param name="storage">Online/Offline provider of data feed storage instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="endTime">A end time of bars enumeration.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> public Bars(IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime) { ValidateArguments(storage, symbol, period); this.enumerator = new BarsTimeIntervalEnumerator(storage, symbol, priceType, period, startTime, endTime); }
static Bar[] CalculateBarsForSymbolArrayRangeTime( string symbol, PriceType priceType, DateTime startTime, DateTime endTime, BarPeriod barPeriod) { return FdkHelper.Wrapper.ConnectLogic.Storage.Online.GetBars(symbol, priceType, barPeriod, startTime, endTime).ToArray(); }
/// <summary> /// Creates a new Bars stream instance. /// If barsNumber is less than zero then this is forward bars enumeration (from past to future), otherwise this is backward enumeration (from future to past). /// Anyway all bars should be in the following time range: /// Bar.From >= startTime for forward enumeration /// Bar.To <= startTime for backward enumeration /// </summary> /// <param name="datafeed">Datafeed instance; can not be null.</param> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="barsNumber">Requested bars number; positive value means forward enumeration; negative value means backward enumeration.</param> /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception> public Bars(DataFeed datafeed, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int barsNumber) : this(datafeed, symbol, priceType, period, startTime, barsNumber, DefaultBufferSize) { }
protected BarsEnumeratorBase(DataFeed dataFeed, IStorage storage, string symbol, PriceType priceType, BarPeriod period, DateTime startTime, int preferredBufferSize) { this.DataFeed = dataFeed; this.Storage = storage; this.Symbol = symbol; this.PriceType = priceType; this.Period = period; this.StartTime = startTime; this.PreferredBufferSize = preferredBufferSize; }
/// <summary> /// The method gets history bars from the server. /// </summary> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="priceType">A required price type: Bid or Ask.</param> /// <param name="startTime">A start time of bars enumeration.</param> /// <param name="endTime">A end time of bars enumeration.</param> /// <param name="period">Bar period instance; can not be null.</param> /// <returns></returns> public Bars GetBarsHistory(string symbol, PriceType priceType, BarPeriod period, DateTime startTime, DateTime endTime) { return(new Bars(this.Client, symbol, priceType, period, startTime, endTime)); }
/// <summary> /// The method gets history bars from the server. /// </summary> /// <param name="symbol">A required symbol; can not be null.</param> /// <param name="time">Date and time which specifies the historical point.</param> /// <param name="barsNumber">The maximum number of bars in the requested chart. The value can be negative or positive. /// Positive value means historical chart from the specified historical point to future.</param> /// <param name="priceType">Can be bid or ask.</param> /// <param name="period">Chart periodicity.</param> /// <param name="timeoutInMilliseconds">timeout of the operation</param> /// <returns>Can not be null.</returns> public DataHistoryInfo GetHistoryBarsEx(string symbol, DateTime time, int barsNumber, PriceType priceType, BarPeriod period, int timeoutInMilliseconds) { return(this.Client.DataFeedHandle.GetHistoryBars(symbol, time, barsNumber, priceType, period, timeoutInMilliseconds)); }
internal abstract void Initialize(Manager manager, IStrategyLog log, string symbol, PriceType priceType, BarPeriod periodicity);
static HistoryInfo GetBarsInfo(string symbol, PriceType priceType, BarPeriod period) { return FdkHelper.Wrapper.ConnectLogic.Storage.Online.GetBarsInfo(symbol, priceType, period); }