示例#1
0
        private void start()
        {
            //Loading system startup data for all the exchanges
            List <Exchange> exchanges = new List <Exchange>();

            exchanges.Add(Exchange.FAKE_NASDAQ);

            InMemoryObjects.LoadInMemoryObjects(exchanges);

            //Initiate fake data generation from fake market
            //Later it will also include data generation from google finance
            TimeSpan updateDuration = TimeSpan.FromMilliseconds(Constants.FAKE_DATA_GENERATE_PERIOD);

            FakeDataGenerator.StartFakeDataGeneration(300);


            IFeeder feeder = FeederFactory.GetFeeder(FeederSourceSystem.FAKEMARKET);
            ISender sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);

            List <StockModel.Symbol> symbols = InMemoryObjects.ExchangeSymbolList.SingleOrDefault(x => x.Exchange == Exchange.FAKE_NASDAQ).Symbols;

            while (true)
            {
                Parallel.ForEach(symbols, (symbol) =>
                {
                    feedList = feeder.GetFeedList(symbol.Id, 1, 10);                      // Get the list of values for a given symbolId of a market for given time-span
                    sender.SendFeed(feedList);
                });
            }
        }
示例#2
0
        /// <summary>
        /// Application arguments:
        /// arg0: Selected Exchange. Has to be enum StockModel.Master.Exchange
        /// arg1: Data generator to use. Has to be IDataPublisher.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Loading system startup data for all the exchanges
            List <Exchange> exchanges = new List <Exchange>();

            //defaults selected...
            selectedExchange = Exchange.FAKE_NASDAQ;
            dataGenerator    = YahooDataGenerator.Instance;

            ResolveAppArgs(args);

            exchanges = Enum.GetValues(typeof(Exchange)).OfType <Exchange>().ToList();

            InMemoryObjects.LoadInMemoryObjects(exchanges);

            TimeSpan updateDuration = TimeSpan.FromMilliseconds(Constants.FAKE_DATA_GENERATE_PERIOD);

            //Start data generation - this will start fetching data for all symbols of current exchange
            //Later, need to change this to only subscribe to the specific symbol(s) selected.
            dataGenerator.StartDataGeneration(300, selectedExchange);

            sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);

            List <StockModel.Symbol> symbols = InMemoryObjects.ExchangeSymbolList.SingleOrDefault(x => x.Exchange == selectedExchange).Symbols;

            List <SymbolFeeds>       generatedData = new List <SymbolFeeds>();
            List <StockModel.Symbol> symbolList    = new List <StockModel.Symbol>();


            Action <double, string> addMovingAverage = new Action <double, string>((val, MVA_id) => {
                sender.SendMVA(val, MVA_id);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Sent value {0} to redis", val);
                Console.ResetColor();
            });

            Parallel.ForEach(symbols, (symbol) =>
            {
                //subscribe
                dataGenerator.SubscribeFeed(symbol.Id, (Feed fd) =>
                {
                    sender.SendFeed(fd, selectedExchange.ToString());

                    Console.WriteLine(fd.ToString());
                });

                //add subscription for each aggregator configured
                //RXProcessing.AddAggregator(dataGenerator, new MovingAverage(),
                //    addMovingAverage
                //    , symbol.Id);
            });

            Console.Read();
        }
示例#3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            List <Exchange> exchanges = Enum.GetValues(typeof(Exchange)).OfType <Exchange>().ToList();

            InMemoryObjects.LoadInMemoryObjects(exchanges);
        }