Beispiel #1
0
        public static BarCompressor GetCompressor(BarTypeSize barTypeSize, DataSource dataSource)
        {
            BarCompressor barCompressor;

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

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

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

            case BarType.Range:
                barCompressor = new RangeBarCompressor();
                break;

            default:
                throw new ArgumentException(string.Format("Unsupported bar type - {0}", barTypeSize.BarType));
            }
            barCompressor.barSize    = barTypeSize.BarSize;
            barCompressor.dataSource = dataSource;
            return(barCompressor);
        }
Beispiel #2
0
		public static BarCompressor GetCompressor(BarTypeSize barTypeSize, DataSource dataSource)
		{
			BarCompressor barCompressor;
			switch (barTypeSize.BarType)
			{
				case BarType.Time:
					barCompressor = new TimeBarCompressor();
					break;
				case BarType.Tick:
					barCompressor = new TickBarCompressor();
					break;
				case BarType.Volume:
					barCompressor = new VolumeBarCompressor();
					break;
				case BarType.Range:
					barCompressor = new RangeBarCompressor();
					break;
				default:
					throw new ArgumentException(string.Format("Unsupported bar type - {0}", barTypeSize.BarType));
			}
			barCompressor.barSize = barTypeSize.BarSize;
			barCompressor.dataSource = dataSource;
			return barCompressor;
		}
Beispiel #3
0
        private BarTypeSize[] GetAllowedBarTypeSizeList()
        {
            List <BarTypeSize> list = new List <BarTypeSize>();

            list.Add(new BarTypeSize((BarType)1, 1L));
            list.Add(new BarTypeSize((BarType)1, 2L));
            list.Add(new BarTypeSize((BarType)1, 5L));
            list.Add(new BarTypeSize((BarType)1, 10L));
            list.Add(new BarTypeSize((BarType)1, 15L));
            list.Add(new BarTypeSize((BarType)1, 20L));
            list.Add(new BarTypeSize((BarType)1, 30L));
            list.Add(new BarTypeSize((BarType)1, 60L));
            list.Add(new BarTypeSize((BarType)1, 120L));
            list.Add(new BarTypeSize((BarType)1, 180L));
            list.Add(new BarTypeSize((BarType)1, 300L));
            list.Add(new BarTypeSize((BarType)1, 600L));
            list.Add(new BarTypeSize((BarType)1, 900L));
            list.Add(new BarTypeSize((BarType)1, 1200L));
            list.Add(new BarTypeSize((BarType)1, 1800L));
            list.Add(new BarTypeSize((BarType)1, 3600L));
            list.Add(new BarTypeSize((BarType)1, 7200L));
            list.Add(new BarTypeSize((BarType)1, 10800L));
            list.Add(new BarTypeSize((BarType)1, 21600L));
            list.Add(new BarTypeSize((BarType)1, 43200L));
            list.Add(new BarTypeSize((BarType)1, 86400L));
            list.Add(new BarTypeSize((BarType)2, 1L));
            list.Add(new BarTypeSize((BarType)2, 5L));
            list.Add(new BarTypeSize((BarType)2, 10L));
            list.Add(new BarTypeSize((BarType)2, 50L));
            list.Add(new BarTypeSize((BarType)2, 100L));
            list.Add(new BarTypeSize((BarType)2, 500L));
            list.Add(new BarTypeSize((BarType)2, 1000L));
            list.Add(new BarTypeSize((BarType)3, 10L));
            list.Add(new BarTypeSize((BarType)3, 50L));
            list.Add(new BarTypeSize((BarType)3, 100L));
            list.Add(new BarTypeSize((BarType)3, 500L));
            list.Add(new BarTypeSize((BarType)3, 1000L));
            list.Add(new BarTypeSize((BarType)3, 5000L));
            list.Add(new BarTypeSize((BarType)3, 10000L));
            list.Add(new BarTypeSize((BarType)3, 50000L));
            list.Add(new BarTypeSize((BarType)3, 100000L));
            list.Add(new BarTypeSize((BarType)4, 10L));
            list.Add(new BarTypeSize((BarType)4, 100L));
            list.Add(new BarTypeSize((BarType)4, 500L));
            list.Add(new BarTypeSize((BarType)4, 1000L));
            list.Add(new BarTypeSize((BarType)4, 5000L));
            list.Add(new BarTypeSize((BarType)4, 10000L));
            if (this.cbxDataSources.SelectedItem != null)
            {
                DataSource dataSource = (DataSource)this.cbxDataSources.SelectedItem;
                if (dataSource.Input == DataSourceInput.Bar)
                {
                    BarDataSource barDataSource = (BarDataSource)dataSource;
                    int           index         = 0;
                    while (index < list.Count)
                    {
                        BarTypeSize barTypeSize = list[index];
                        if (barTypeSize.BarType == barDataSource.BarType && barTypeSize.BarSize != barDataSource.BarSize && barTypeSize.BarSize % barDataSource.BarSize == 0L)
                        {
                            ++index;
                        }
                        else
                        {
                            list.RemoveAt(index);
                        }
                    }
                }
            }
            return(list.ToArray());
        }