<commit_before>﻿namespace SoftFX.Extended
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using SoftFX.Extended.Storage;

    /// <summary>
    /// Bars enumeration.
    /// </summary>
    public class PairBars : IEnumerable<PairBar>
    {
        #region Construction

        internal PairBars(IEnumerable<Bar> bids, IEnumerable<Bar> asks, bool positive)
        {
            if (bids == null)
                throw new ArgumentNullException(nameof(bids), "bids bar enumeration can not be null");

            if (asks == null)
                throw new ArgumentNullException(nameof(asks), "asks bar enumeration can not be null");

            this.bids = bids;
            this.asks = asks;
            this.positive = positive;
        }

        /// <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) &lt;= Bar.From and Bar.To &lt;= 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>
        /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception>
        public PairBars(DataFeed datafeed, string symbol, BarPeriod period, DateTime startTime, DateTime endTime)
        {
            this.bids = new Bars(datafeed, symbol, PriceType.Bid, period, startTime, endTime);
            this.asks = new Bars(datafeed, symbol, PriceType.Ask, period, startTime, endTime);
            this.positive = DateTime.Compare(startTime, endTime) >= 0;
        }

        /// <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) &lt;= Bar.From and Bar.To &lt;= 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) &lt;= Bar.From and Bar.To &lt;= 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>
        /// 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 &gt;= startTime for forward enumeration
        ///		Bar.To &lt;= 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><commit_msg>FDKPRO-640: FDK1 DataFeedStorage.GetPairBars() function doesn't return any bars by BTCUSD_L symbol<commit_after>﻿namespace SoftFX.Extended
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using SoftFX.Extended.Storage;

    /// <summary>
    /// Bars enumeration.
    /// </summary>
    public class PairBars : IEnumerable<PairBar>
    {
        #region Construction

        internal PairBars(IEnumerable<Bar> bids, IEnumerable<Bar> asks, bool positive)
        {
            if (bids == null)
                throw new ArgumentNullException(nameof(bids), "bids bar enumeration can not be null");

            if (asks == null)
                throw new ArgumentNullException(nameof(asks), "asks bar enumeration can not be null");

            this.bids = bids;
            this.asks = asks;
            this.positive = positive;
            this.count = int.MaxValue;
        }

        /// <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) &lt;= Bar.From and Bar.To &lt;= 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>
        /// <exception cref="System.ArgumentNullException">If datafeed, period or symbol is null.</exception>
        public PairBars(DataFeed datafeed, string symbol, BarPeriod period, DateTime startTime, DateTime endTime)
        {
            this.bids = new Bars(datafeed, symbol, PriceType.Bid, period, startTime, endTime);
            this.asks = new Bars(datafeed, symbol, PriceType.Ask, period, startTime, endTime);
            this.positive = DateTime.Compare(startTime, endTime) >= 0;
            this.count = int.MaxValue;
        }

        /// <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) &lt;= Bar.From and Bar.To &lt;= 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;
            this.count = int.MaxValue;
        }

        /// <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) &lt;= Bar.From and Bar.To &lt;= 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;
            this.count = int.MaxValue;
        }

        /// <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 &gt;= startTime for forward enumeration
        ///		Bar.To &lt;= 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>
{'fraction_non_alphanumeric': 0.11450954246187182, 'fraction_numerical': 0.0010000833402783566, 'mean_word_length': 2.6286664650740854, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5388225', 'n_tokens_mistral': 3167, 'n_tokens_neox': 3020, 'n_words': 1153}