示例#1
0
        public static void RunBackTest(object[,] tradeBlotter, DateTime fromDate, DateTime toDate)
        {
            var backTest = new BackTest(fromDate, toDate);

            // get trades
            LoadOMSTrades(tradeBlotter, backTest.PF);

            // runbacktest
            foreach (DateTime day in DynamicData.TCs["LON"].EachBusDay(fromDate, toDate))
            { backTest.PF.PricePortfolio(day); }

            // process results
        }
 public static delBackTrader SelectTrader(BackTest backTest)
 {
     // @@@ single trades / american options / multicast delegates?
     delBackTrader trader;
     switch (backTest.OptionHedgeType)
     {
         case 0:
             trader = PerfectMonthlyHedge;
             break;
         case 1:
             trader = BestGranularityHedge; // @@@ add min clip size as well - how to split? first finish backtrader, then think about the code structure;
             break;
         //case 2:
             // @@@ same cases for single option ID's [result will differ from portfolio as we 13k + 13k will end up selling 2*50k on portfolio basis - so only good for single trade perfomance, not portfolio]
           //  break;
         default:
             throw new NotImplementedException("trader = ?which OptionHedgeType?");
     }
     return trader;
 }
        public static void RunDates(BackTest backTest)
        {
            delBackTrader trader = SelectTrader(backTest);

            SortedDictionary<DateTime, TradeSet> allTrades = backTest._tradeCollection._tradeSets;
            List<DateTime> marktDates = allTrades.Keys.OrderBy(k => k).ToList();
            TradeSet CurrentSet;

            for (int i = 0; i < marktDates.Count; i++)
            {
                CurrentSet = allTrades[marktDates[i]];
                ExcerciseGasOptions(CurrentSet);
                CurrentSet.PriceSet();
                if (i < marktDates.Count - 1) allTrades[marktDates[i + 1]] = trader(CurrentSet); // no new trades at the end of the last day;
            }

            /* ExecTrader(TradeSet, delBackTrader, delSignal, delFilter)
             *
             * delSignal shoudl return 'product ID', maturity, ACTION (buy/sell), volume, price, etc.
             *
             * delSignal is based on a product, while delBackTrader can work on a special group like OptionID, hence more analysis than a simple signal would provide
             * @@@@
             * add ELE later (i.e. bullets in general)
             * load WE/BoM curves
             * how to measure hedge effenciency
             * provide different vol hedging (i.e. normal, atm log, skewed log)
             * BackTrader.PerfectMonthlyHedge); // @@@ delegate here? better
             */
        }
示例#4
0
 public static void CreateBackTest(string name, DateTime fromDate, DateTime toDate)
 {
     if (BackTestContainer == null) BackTestContainer = new Dictionary<string, BackTest>();
     BackTestContainer[name] = new BackTest(name, fromDate, toDate);
 }
示例#5
0
 public static void WriteBTToSerial(string name, BackTest bt)
 {
     string filePath = System.IO.Path.Combine(Settings.Instance.FilePath.BackTestFolder, "BackTest_" + name + ".data"); //Settings.Instance.FilePath.BackTestFile);
     SerializationHandler.WriteSerialization(filePath, bt);
 }