예제 #1
0
        public SignalCharting(ISignalChart chartControl, TickerType tickerType, BarItemType barType, object dataStreamSource)
        {
            this.dataStreamSource    = dataStreamSource;
            this.tickerType          = tickerType;
            this.barType             = barType;
            this.chartControl        = chartControl;
            this.registeredAnalytics = new List <AnalyticsItem>();

            SharedCacheFactory.Instance.CacheWriter = new FileCacheWriter("cache");
            SharedCacheFactory.Instance.CacheReader = new FileCacheReader("cache");

            if (dataStreamSource is string)
            {
                FileInfo    file        = new FileInfo(dataStreamSource.ToString());
                long        fileHash    = file.Attributes.GetHashCode() ^ file.CreationTime.Ticks ^ file.LastWriteTime.Ticks ^ file.Length;
                CacheConfig cacheConfig = new CacheConfig("cache");
                cacheConfig.Initialize();
                cacheConfig.Open(CachingModeOption.Reading);
                CacheRow row = cacheConfig.Read(fileHash);
                cacheConfig.Close();

                if (row == null)
                {
                    cacheConfig.Open(CachingModeOption.Writing);
                    cacheId = Guid.NewGuid();
                    cacheConfig.Append(fileHash, cacheId, SessionModeOption.Backtesting);
                    cacheConfig.Close();
                }
                else
                {
                    cacheId = new Guid((byte[])row["SessionId"]);
                }
            }
        }