Esempio n. 1
0
        public void Engine_Validate_NotEnoughtMarketMoney_Throws_Error(string amount)
        {
            var input = new[] { Helpers.GetCsvFileFullPath(), amount };

            Assert.That(() => {
                var service = new QuoteEngine();
                var output  = service.GetQuote(input);
            }, Throws.TypeOf <Core.Validation.ValidationException>(), LendQuoteProvider.ErrorUnavailableMarketMoney);
        }
Esempio n. 2
0
        public void Engine_Validate_InvalidAmmount_Throws_Error(string amount)
        {
            var input = new[] { Helpers.GetCsvFileFullPath(), amount };

            Assert.That(() => {
                var service = new QuoteEngine();
                var output  = service.GetQuote(input);
            }, Throws.TypeOf <Core.Validation.ValidationException>());
        }
Esempio n. 3
0
        public void Engine_Validate_InputWrongParams_Throws_Error()
        {
            var input = new[] { "1000" };

            Assert.That(() => {
                var service = new QuoteEngine();
                var output  = service.GetQuote(input);
            }, Throws.TypeOf <Core.Validation.ValidationException>(), QuoteEngine.ErrorWrongParams);
        }
Esempio n. 4
0
        public void Engine_Validate_WrongFileName_Throws_Error()
        {
            var input = new[] { "somefile", "1000" };

            Assert.That(() => {
                var service = new QuoteEngine();
                var output  = service.GetQuote(input);
            }, Throws.TypeOf <Core.Validation.ValidationException>());
        }
Esempio n. 5
0
        public void Engine_FullTest_OK()
        {
            var input = new[] { Helpers.GetCsvFileFullPath(), "1000" };

            var service = new QuoteEngine();
            var output  = service.GetQuote(input);

            Assert.AreEqual(ExpectedOutputForFullTest, output);
        }
Esempio n. 6
0
        //
        //
        //
        //
        // ****************************************
        // ****     Setup Initialize()         ****
        // ****************************************
        /// <summary>
        /// The Strategy has been created, and now we add its engines.
        /// When we call Engine.SetupInitialize() the engine can make NO assumptions
        /// about the Strategy, except that it and its StrategyHub exists.
        /// Other Engines may or may not exist.
        /// What is allowed is that Engines can spawn other Engines and add them
        /// to the *end* of the Strategy.m_Engines[] list freely.
        /// </summary>
        public void SetupInitialize(IEngineHub myHub)
        {
            StrategyHub = (StrategyHub)myHub;                           // store ptr to new parent hub.

            // First initialize each of my engines.
            int id = 0;

            while (id < m_Engines.Count)                                // Loop using while so that Engines can ADD new engines to end of list.
            {                                                           // Adding new engines spontaneously is allowed here only.
                Engine engine = m_Engines[id];
                engine.SetupInitialize(StrategyHub, this, id);          // Tell Engine his new Hub, and owner, and his new id#.

                // Keep track of important engine ptrs we need.
                if (engine is PricingEngine)                            // using simple "if"s allows one engine to play multiple roles.
                {
                    PricingEngines.Add((PricingEngine)engine);          //m_PricingEngine = (StrategyEngines.PricingEngine)engine;
                }
                if (engine is TradeEngine)
                {
                    m_OrderEngine = (TradeEngine)engine;
                }
                if (engine is ZGraphEngine)
                {
                    m_GraphEngine = (ZGraphEngine)engine;
                }
                if (engine is FauxQuote)
                {
                    m_QuoteEngine = (FauxQuote)engine;
                }
                id++;
            }//next engine id

            // Create missing basic engines
            if (m_OrderEngine == null)
            {
                m_OrderEngine = new TradeEngine();
                TryAddEngine(m_OrderEngine, myHub);
                m_OrderEngine.SetupInitialize(StrategyHub, this, -1);// Tell Engine his new Hub, and owner, and his new id# (which is already set in TryAddEngine()).
            }
            if (m_GraphEngine == null)
            {
                m_GraphEngine = new ZGraphEngine();
                TryAddEngine(m_GraphEngine, myHub);
                m_GraphEngine.SetupInitialize(StrategyHub, this, -1);
            }
            if (m_QuoteEngine == null)
            {
                QuoteEngine quoteEngine = new QuoteEngine();
                m_QuoteEngine = quoteEngine;
                TryAddEngine(quoteEngine, myHub);
                quoteEngine.SetupInitialize(StrategyHub, this, -1);
            }

            // Exit
            m_IsInitializeComplete = true;                               // Must be last line in this method.
        }//SetupInitialize()
Esempio n. 7
0
        static void Main(string[] args)
        {
            try {
                var service = new QuoteEngine();
                var output  = service.GetQuote(args);

                Console.WriteLine(output);
            }
            catch (ValidationException vex) {
                Console.WriteLine(vex.Message);
            }
            catch (Exception ex) {
                Console.WriteLine($"We encounter an error while trying to get your quote: {ex.Message}");
            }
        }
Esempio n. 8
0
        public PortfolioViewModel(String filePath, String service = "Google")
        {
            try
            {
                //create portfolio object from xml file path
                _portfolio = DataAccess.Factory.PortfolioFactory.Instance.GetPortfolio(filePath);
            }
            catch (Exception e)
            {
                throw e;
            }

            //Create a QuoteEngine that will manage communication and tracking of web service quotes
            _engine = new QuoteEngine(_portfolio.GetSymbols(), service);

            //initialize binding sources for ViewModel
            intitializePortfolioBindingSource();
            initializeEqutiyBindingSource();

            //bubble up events when quotes change
            _engine.QuoteChanged     += new QuoteChangedEventHandler(OnQuoteChanged);
            _engine.InternetBlackout += new HttpBlackoutEventHandler(OnInternetBlackout);
        }
 public decimal QuoteMeHappy(Customer c)
 {
     return(QuoteEngine.GetQuotingEngine(c).QuoteMeHappy(c));
 }