Exemplo n.º 1
0
        /// <summary>
        /// Starts this instance for conversion.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <exception cref="Exception">Could not derive datasource from filename!</exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public override void Start(Options options)
        {
            //Get files
            var filesfound = Directory.GetFiles(options.InputFolder, options.Wildcard, SearchOption.AllDirectories).Select(x => new FileInfo(x).Name);
            var datasource = filesfound.FirstOrDefault(x => x.Contains("_"))?.Split("_")[0];

            //Try and get datasource and if needed the datafeed
            if (!Enum.TryParse(typeof(DataSource), datasource, true, out object objsource))
            {
                throw new Exception("Could not derive datasource from filename!");
            }

            //Check if datafeed is loaded
            DataSource source = (DataSource)objsource;

            if (DataFeed == null)
            {
                switch (source)
                {
                case DataSource.Bittrex:
                    DataFeed = new BittrexDataFeed();
                    DataFeed.Initialize(new LiveTradingMessage());
                    break;

                case DataSource.HitBtc:
                    DataFeed = new HitBtcDataFeed();
                    DataFeed.Initialize(new LiveTradingMessage());
                    break;

                case DataSource.Binance:
                    DataFeed = new BinanceDataFeed();
                    DataFeed.Initialize(new LiveTradingMessage());
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            //Continue with base
            base.Start(options);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HitBTCDataConversionModel"/> class.
 /// </summary>
 public BinanceDataConversionModel()
 {
     _binanceDataFeed = new BinanceDataFeed();
     _binanceDataFeed.Initialize(new LiveTradingMessage());
     DataFeed = _binanceDataFeed;
 }