Esempio n. 1
0
 public DateTime AddInterval(DateTime dateTime, TimeIntervalSize intervalSize, int multiplier)
 {
   DateTime dateTime1;
   switch (intervalSize)
   {
     case TimeIntervalSize.year10:
       dateTime1 = dateTime.AddYears(10 * multiplier);
       break;
     case TimeIntervalSize.year20:
       dateTime1 = dateTime.AddYears(20 * multiplier);
       break;
     case TimeIntervalSize.year4:
       dateTime1 = dateTime.AddYears(4 * multiplier);
       break;
     case TimeIntervalSize.year5:
       dateTime1 = dateTime.AddYears(5 * multiplier);
       break;
     case TimeIntervalSize.year1:
       dateTime1 = dateTime.AddYears(multiplier);
       break;
     case TimeIntervalSize.year2:
       dateTime1 = dateTime.AddYears(2 * multiplier);
       break;
     case TimeIntervalSize.year3:
       dateTime1 = dateTime.AddYears(3 * multiplier);
       break;
     case TimeIntervalSize.month4:
       dateTime1 = dateTime.AddMonths(4 * multiplier);
       break;
     case TimeIntervalSize.month6:
       dateTime1 = dateTime.AddMonths(6 * multiplier);
       break;
     case TimeIntervalSize.month9:
       dateTime1 = dateTime.AddMonths(9 * multiplier);
       break;
     case TimeIntervalSize.month1:
       dateTime1 = dateTime.AddMonths(multiplier);
       break;
     case TimeIntervalSize.month2:
       dateTime1 = dateTime.AddMonths(2 * multiplier);
       break;
     case TimeIntervalSize.month3:
       dateTime1 = dateTime.AddMonths(3 * multiplier);
       break;
     default:
       dateTime1 = dateTime.AddTicks((long) intervalSize * (long) multiplier);
       break;
   }
   return dateTime1;
 }
Esempio n. 2
0
        public void PrepareTester()
        {
            bool             flag             = (bool)this.sampleStrategy.GetType().GetField("ReportEnabled", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField).GetValue((object)this.sampleStrategy);
            TimeIntervalSize timeIntervalSize = (TimeIntervalSize)this.sampleStrategy.GetType().GetField("TestingPeriod", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField).GetValue((object)this.sampleStrategy);

            this.tester = new LiveTester(this.sq_Portfolio);
            this.tester.TimeInterval = timeIntervalSize;
            this.tester.DisableComponents();
            if (!flag)
            {
                this.tester.AllowRoundTrips = false;
            }
            else
            {
                this.tester.Disconnect();
                this.tester.Connect();
                this.tester.Reset();
                this.tester.FollowChanges   = true;
                this.tester.AllowRoundTrips = true;
                this.AddTesterComponents();
            }
        }
Esempio n. 3
0
        public DateTime AddInterval(DateTime dateTime, TimeIntervalSize intervalSize, int multiplier)
        {
            DateTime dateTime1;

            switch (intervalSize)
            {
            case TimeIntervalSize.year10:
                dateTime1 = dateTime.AddYears(10 * multiplier);
                break;

            case TimeIntervalSize.year20:
                dateTime1 = dateTime.AddYears(20 * multiplier);
                break;

            case TimeIntervalSize.year4:
                dateTime1 = dateTime.AddYears(4 * multiplier);
                break;

            case TimeIntervalSize.year5:
                dateTime1 = dateTime.AddYears(5 * multiplier);
                break;

            case TimeIntervalSize.year1:
                dateTime1 = dateTime.AddYears(multiplier);
                break;

            case TimeIntervalSize.year2:
                dateTime1 = dateTime.AddYears(2 * multiplier);
                break;

            case TimeIntervalSize.year3:
                dateTime1 = dateTime.AddYears(3 * multiplier);
                break;

            case TimeIntervalSize.month4:
                dateTime1 = dateTime.AddMonths(4 * multiplier);
                break;

            case TimeIntervalSize.month6:
                dateTime1 = dateTime.AddMonths(6 * multiplier);
                break;

            case TimeIntervalSize.month9:
                dateTime1 = dateTime.AddMonths(9 * multiplier);
                break;

            case TimeIntervalSize.month1:
                dateTime1 = dateTime.AddMonths(multiplier);
                break;

            case TimeIntervalSize.month2:
                dateTime1 = dateTime.AddMonths(2 * multiplier);
                break;

            case TimeIntervalSize.month3:
                dateTime1 = dateTime.AddMonths(3 * multiplier);
                break;

            default:
                dateTime1 = dateTime.AddTicks((long)intervalSize * (long)multiplier);
                break;
            }
            return(dateTime1);
        }
Esempio n. 4
0
 public DateTime SubtractInterval(DateTime dateTime, TimeIntervalSize intervalSize)
 {
     return(this.AddInterval(dateTime, intervalSize, -1));
 }
Esempio n. 5
0
 public DateTime AddInterval(DateTime dateTime, TimeIntervalSize intervalSize)
 {
     return(this.AddInterval(dateTime, intervalSize, 1));
 }
Esempio n. 6
0
 public ReturnForPeriod(string name, SeriesTesterItem parentSeriesItem, TimeIntervalSize intervalSize, TimeIntervalSize periodLength)
     :      base(name, parentSeriesItem, parentSeriesItem.Series.Title)
 {
     this.intervalSize = intervalSize;
     this.periodLength = periodLength;
 }
Esempio n. 7
0
		public DateTime AddInterval(DateTime dateTime, TimeIntervalSize intervalSize)
		{
			DateTime dateTime1;
			switch (intervalSize)
			{
				case TimeIntervalSize.year5:
					dateTime1 = dateTime.AddYears(5);
					break;
				case TimeIntervalSize.year10:
					dateTime1 = dateTime.AddYears(10);
					break;
				case TimeIntervalSize.year20:
					dateTime1 = dateTime.AddYears(20);
					break;
				case TimeIntervalSize.year2:
					dateTime1 = dateTime.AddYears(2);
					break;
				case TimeIntervalSize.year3:
					dateTime1 = dateTime.AddYears(3);
					break;
				case TimeIntervalSize.year4:
					dateTime1 = dateTime.AddYears(4);
					break;
				case TimeIntervalSize.month4:
					dateTime1 = dateTime.AddMonths(4);
					break;
				case TimeIntervalSize.month6:
					dateTime1 = dateTime.AddMonths(6);
					break;
				case TimeIntervalSize.year1:
					dateTime1 = dateTime.AddYears(1);
					break;
				case TimeIntervalSize.month1:
					dateTime1 = dateTime.AddMonths(1);
					break;
				case TimeIntervalSize.month2:
					dateTime1 = dateTime.AddMonths(2);
					break;
				case TimeIntervalSize.month3:
					dateTime1 = dateTime.AddMonths(3);
					break;
				default:
					dateTime1 = dateTime.AddTicks((long)intervalSize);
					break;
			}
			return dateTime1;
		}
Esempio n. 8
0
		public DateTime GetIntervalEnd(DateTime dateTime, TimeIntervalSize intervalSize)
		{
			DateTime dateTime1;
			switch (intervalSize)
			{
				case TimeIntervalSize.year5:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1 + (4 - dateTime.Year % 5));
					break;
				case TimeIntervalSize.year10:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1 + (9 - dateTime.Year % 10));
					break;
				case TimeIntervalSize.year20:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1 + (19 - dateTime.Year % 20));
					break;
				case TimeIntervalSize.year3:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1 + (2 - dateTime.Year % 3));
					break;
				case TimeIntervalSize.year4:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1 + (3 - dateTime.Year % 4));
					break;
				case TimeIntervalSize.year1:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1);
					break;
				case TimeIntervalSize.year2:
					dateTime1 = new DateTime(dateTime.Year, 1, 1).AddYears(1 + (1 - dateTime.Year % 2));
					break;
				case TimeIntervalSize.month4:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1 + (12 - dateTime.Month) % 4);
					break;
				case TimeIntervalSize.month6:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1 + (12 - dateTime.Month) % 6);
					break;
				case TimeIntervalSize.month1:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1);
					break;
				case TimeIntervalSize.month2:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1 + dateTime.Month % 2);
					break;
				case TimeIntervalSize.month3:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1 + (12 - dateTime.Month) % 3);
					break;
				case TimeIntervalSize.week1:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays(8.0 - (double)dateTime.DayOfWeek);
					break;
				case TimeIntervalSize.week2:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays(8.0 - (double)dateTime.DayOfWeek + (double)(7 * (1 - (int)Math.Floor(new TimeSpan(dateTime.AddDays(8.0 - (double)dateTime.DayOfWeek).Ticks).TotalDays) / 7 % 2)));
					break;
				case TimeIntervalSize.day3:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays((double)(1 + (2 - (int)new TimeSpan(dateTime.Ticks).TotalDays % 3)));
					break;
				case TimeIntervalSize.day5:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays((double)(1 + (4 - (int)new TimeSpan(dateTime.Ticks).TotalDays % 5)));
					break;
				case TimeIntervalSize.day1:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays(1.0);
					break;
				case TimeIntervalSize.day2:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day).AddDays((double)(1 + (int)new TimeSpan(dateTime.Ticks).TotalDays % 2));
					break;
				case TimeIntervalSize.hour4:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0).AddHours((double)(1 + (3 - (int)new TimeSpan(dateTime.Ticks).TotalHours % 4)));
					break;
				case TimeIntervalSize.hour6:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0).AddHours((double)(1 + (5 - (int)new TimeSpan(dateTime.Ticks).TotalHours % 6)));
					break;
				case TimeIntervalSize.hour12:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0).AddHours((double)(1 + (11 - (int)new TimeSpan(dateTime.Ticks).TotalHours % 12)));
					break;
				case TimeIntervalSize.hour2:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0).AddHours((double)(1 + (1 - (int)new TimeSpan(dateTime.Ticks).TotalHours % 2)));
					break;
				case TimeIntervalSize.hour3:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0).AddHours((double)(1 + (2 - (int)new TimeSpan(dateTime.Ticks).TotalHours % 3)));
					break;
				case TimeIntervalSize.min30:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0).AddMinutes((double)(1 + (29 - (int)new TimeSpan(dateTime.Ticks).TotalMinutes % 30)));
					break;
				case TimeIntervalSize.hour1:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0).AddHours(1.0);
					break;
				case TimeIntervalSize.min15:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0).AddMinutes((double)(1 + (14 - (int)new TimeSpan(dateTime.Ticks).TotalMinutes % 15)));
					break;
				case TimeIntervalSize.min20:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0).AddMinutes((double)(1 + (19 - (int)new TimeSpan(dateTime.Ticks).TotalMinutes % 20)));
					break;
				case TimeIntervalSize.min1:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0).AddMinutes(1.0);
					break;
				case TimeIntervalSize.min5:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0).AddMinutes((double)(1 + (4 - (int)new TimeSpan(dateTime.Ticks).TotalMinutes % 5)));
					break;
				case TimeIntervalSize.min10:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0).AddMinutes((double)(1 + (9 - (int)new TimeSpan(dateTime.Ticks).TotalMinutes % 10)));
					break;
				case TimeIntervalSize.sec20:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second).AddSeconds((double)(1 + (19 - (int)new TimeSpan(dateTime.Ticks).TotalSeconds % 20)));
					break;
				case TimeIntervalSize.sec30:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second).AddSeconds((double)(1 + (29 - (int)new TimeSpan(dateTime.Ticks).TotalSeconds % 30)));
					break;
				case TimeIntervalSize.sec5:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second).AddSeconds((double)(1 + (4 - (int)new TimeSpan(dateTime.Ticks).TotalSeconds % 5)));
					break;
				case TimeIntervalSize.sec10:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second).AddSeconds((double)(1 + (9 - (int)new TimeSpan(dateTime.Ticks).TotalSeconds % 10)));
					break;
				case TimeIntervalSize.sec1:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second).AddSeconds(1.0);
					break;
				case TimeIntervalSize.sec2:
					dateTime1 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second).AddSeconds((double)(1 + (1 - (int)new TimeSpan(dateTime.Ticks).TotalSeconds % 2)));
					break;
				default:
					dateTime1 = dateTime.AddTicks((long)intervalSize);
					break;
			}
			return dateTime1.AddTicks(-1L);
		}
Esempio n. 9
0
		private void ALwyG0kIYg(TimeIntervalSize obj0, TimeIntervalSize obj1)
		{
//      SimpleSeriesItem simpleSeriesItem = this.components[s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5598)] as SimpleSeriesItem;
//      PercentageOfProfitableForPeriod profitableForPeriod;
//      if (this.components.Contains(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5614) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5682) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5700)))
//      {
//        profitableForPeriod = this.components[s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5706) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5774) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5792)] as PercentageOfProfitableForPeriod;
//      }
//      else
//      {
//        profitableForPeriod = new PercentageOfProfitableForPeriod(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5798) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5866) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5884), (SeriesTesterItem) simpleSeriesItem, obj0, obj1);
//        this.AddComponent((TesterItem) profitableForPeriod);
//      }
//      this.AddComponent((TesterItem) new Average(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5890) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5944) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5988), (SeriesTesterItem) profitableForPeriod));
//      ReturnForPeriod returnForPeriod;
//      if (this.components.Contains(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(5994) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6030) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6048)))
//      {
//        returnForPeriod = this.components[s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6054) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6090) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6108)] as ReturnForPeriod;
//      }
//      else
//      {
//        returnForPeriod = new ReturnForPeriod(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6114) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6150) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6168), (SeriesTesterItem) simpleSeriesItem, obj0, obj1);
//        this.AddComponent((TesterItem) returnForPeriod);
//      }
//      this.AddComponent((TesterItem) new Average(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6174) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6228) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6270), (SeriesTesterItem) returnForPeriod));
//      this.AddComponent((TesterItem) new Median(s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6276) + ((object) obj1).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6328) + ((object) obj0).ToString() + s3j2vikrJi2pVH1Xpv.aMieSmUS9G(6370), (SeriesTesterItem) returnForPeriod));
		}
Esempio n. 10
0
		private void Init()
		{
			this.tempPortfolio = new Portfolio();
			this.tempPortfolio.Performance.Enabled = false;
			this.timeInterval = TimeIntervalSize.day1;
			this.wealthSeries = new DoubleSeries();
			this.drawdownSeries = new DoubleSeries();
			this.percentDrawdownSeries = new DoubleSeries();
			this.costSeries = new DoubleSeries();
			this.pnLSeries = new DoubleSeries();
			this.returnSeries = new DoubleSeries();
			this.allocationSeries = new DoubleSeries();
			this.allocationLongSeries = new DoubleSeries();
			this.allocationShortSeries = new DoubleSeries();
			this.roundTripList = new RoundTripList(this);
			this.longRoundTripList = new RoundTripList(this);
			this.shortRoundTripList = new RoundTripList(this);
			this.isRoundTripsOnly = this.allowRoundTrips;
			this.pnLSeries.Title = "Test PnL Series";
			this.wealthSeries.Title = "Test Wealth Series";
			this.drawdownSeries.Title = "Test Drawdown Series";
			this.percentDrawdownSeries.Title = "Test Percent Drawdown Series";
			this.costSeries.Title = "Test Cost Series";
			this.returnSeries.Title = "Test Return Series";
			this.pnLSeries.Name = "Test PnL Series";
			this.wealthSeries.Name = "Test Wealth Series";
			this.drawdownSeries.Name =  "Test Drawdown Series";
			this.percentDrawdownSeries.Name = "Test Percent Drawdown Series";
			this.costSeries.Name = "Test Cost Series";
			this.returnSeries.Name = "Test Return Series";
			this.components = new TesterItemList();
			this.components.ComponentListChanged += new EventHandler(this.GvwyC63XLV);
			this.InitialWealth = -1.0;
			this.riskFreeRate = 0.0;
			this.businessDaysOnly = true;
			this.totalCost = 0.0;
			SimpleSeriesItem simpleSeriesItem1 = new SimpleSeriesItem("", this.wealthSeries);
			SimpleSeriesItem simpleSeriesItem2 = new SimpleSeriesItem("", this.drawdownSeries);
			SimpleSeriesItem simpleSeriesItem3 = new SimpleSeriesItem("", this.percentDrawdownSeries);
			SimpleSeriesItem simpleSeriesItem4 = new SimpleSeriesItem("", this.costSeries);
			SimpleSeriesItem simpleSeriesItem5 = new SimpleSeriesItem("", this.pnLSeries);
			SimpleSeriesItem simpleSeriesItem6 = new SimpleSeriesItem("", this.returnSeries);
			this.AddComponent(simpleSeriesItem1);
			this.AddComponent(simpleSeriesItem2);
			this.AddComponent(simpleSeriesItem3);
			this.AddComponent(simpleSeriesItem4);
			this.AddComponent(simpleSeriesItem5);
			this.AddComponent(simpleSeriesItem6);
			this.iLayprxSnG();
		}
Esempio n. 11
0
 public DateTime SubtractInterval(DateTime dateTime, TimeIntervalSize intervalSize)
 {
   return this.AddInterval(dateTime, intervalSize, -1);
 }
Esempio n. 12
0
 public DateTime AddInterval(DateTime dateTime, TimeIntervalSize intervalSize)
 {
   return this.AddInterval(dateTime, intervalSize, 1);
 }
Esempio n. 13
0
    public ReturnForPeriod(string name, SeriesTesterItem parentSeriesItem, TimeIntervalSize intervalSize, TimeIntervalSize periodLength)
			:      base(name, parentSeriesItem,  parentSeriesItem.Series.Title)
		 {
    this.intervalSize = intervalSize;
      this.periodLength = periodLength;
    }