示例#1
0
        //[TestMethod]
        public void test_deals()
        {
            FinancialInstrument instr    = controller.get_instrument("SPFB_LKOH_140101_140331.txt");
            TradingStrategy     strategy = controller.get_strategy("Test5").Originator;

            ForecastingModule forecastingModule = new ForecastingModule(strategy, instr);
            ForecastResult    result            = forecastingModule.run();

            int      numDeal = 5;
            TypeDeal expType = TypeDeal.Sell;
            DateTime expDateOpen = new DateTime(14, 2, 12, 12, 35, 0);
            DateTime expDateClose = new DateTime(14, 2, 12, 12, 36, 0);
            double   expOpenPrice = 20430, expClosePrice = 20438;

            TradeDeal tradeDeal = result.get_deal(numDeal);

            double actOpenPrice  = tradeDeal.OpeningPrice;
            double actClosePrice = tradeDeal.ClosingPrice;

            Assert.AreEqual(
                true,
                tradeDeal.Opening == false &&
                tradeDeal.Type == expType &&
                actOpenPrice == expOpenPrice
                //&& tradeDeal.DateTimeOpen.Equals(expDateOpen)
                //&& tradeDeal.DateTimeClose == expDateClose
                && actClosePrice == expClosePrice
                );
        }
示例#2
0
        public void test_run()
        {
            FinancialInstrument instr    = controller.get_instrument("SPFB.Si_090101_091231.txt");
            TradingStrategy     strategy = controller.get_strategy("Test5").Originator;

            strategy.subscribe_analyzer(new AnalyzerDirection());

            ForecastingModule forecastingModule = new ForecastingModule(strategy, instr);
            ForecastResult    result            = forecastingModule.run();

            //result.print();
            double profitExepted = -3419;

            int      numDeal = 5;
            TypeDeal expType = TypeDeal.Buy;
            DateTime expDateOpen = new DateTime(2009, 5, 13, 10, 49, 0);
            DateTime expDateClose = new DateTime(2009, 5, 13, 10, 53, 0);
            double   expOpenPrice = 32110, expClosePrice = 32094;

            TradeDeal tradeDeal = result.get_deal(numDeal);

            double   actOpenPrice     = tradeDeal.OpeningPrice;
            double   actClosePrice    = tradeDeal.ClosingPrice;
            DateTime actDateTimeOpen  = tradeDeal.DateTimeOpen;
            DateTime actDateTimeClose = tradeDeal.DateTimeClose;


            Assert.AreEqual(true,
                            profitExepted == result.CurProfit &&
                            tradeDeal.Opening == false &&
                            tradeDeal.Type == expType &&
                            actOpenPrice == expOpenPrice &&
                            actClosePrice == expClosePrice &&
                            actDateTimeOpen == expDateOpen &&
                            actDateTimeClose == expDateClose);
        }