Пример #1
0
        public static BarCompressor GetCompressor(int instrumentId, BarType barType, long oldBarSize, long newBarSize, TimeSpan time1 = default(TimeSpan), TimeSpan time2 = default(TimeSpan))
        {
            BarCompressor barCompressor;

            switch (barType)
            {
            case BarType.Time:
                barCompressor = new TimeBarCompressor();
                break;

            case BarType.Tick:
                barCompressor = new TickBarCompressor();
                break;

            case BarType.Volume:
                barCompressor = new VolumeBarCompressor();
                break;

            case BarType.Session:
                barCompressor = new SessionBarCompressor(time1, time2);
                break;

            default:
                throw new ArgumentException($"Unknown bar type - {barType}");
            }

            barCompressor.instrumentId = instrumentId;
            barCompressor.oldBarSize   = oldBarSize;
            barCompressor.newBarSize   = newBarSize;
            return(barCompressor);
        }
Пример #2
0
        public static BarCompressor GetCompressor(int instrumentId, BarType barType, long oldBarSize, long newBarSize, TimeSpan time1 = default(TimeSpan), TimeSpan time2 = default(TimeSpan))
        {
            BarCompressor compressor;
            switch (barType)
            {
                case BarType.Time:
                    compressor = new TimeBarCompressor();
                    break;
                case BarType.Tick:
                    compressor = new TickBarCompressor();
                    break;
                case BarType.Volume:
                    compressor = new VolumeBarCompressor();
                    break;
                case BarType.Session:
                    compressor = new SessionBarCompressor(time1, time2);
                    break;
                case BarType.Renko:
                    compressor = new RenkoBarCompressor(instrumentId, newBarSize);
                    break;
                default:
                    throw new ArgumentException($"Unknown bar type - {barType}");
            }

            compressor.instrumentId = instrumentId;
            compressor.oldBarSize = oldBarSize;
            compressor.newBarSize = newBarSize;
            return compressor;
        }