Example #1
0
		private void Init(string name, Portfolio portfolio, bool reportEnabled, List<Parameter> parameters)
		{
			this.Name = name;
			this.Portfolio = portfolio;
			this.Performance = new Performance(portfolio);
			this.ReportEnabled = reportEnabled;
			this.Parameters = new ParameterSet(parameters);
		}
Example #2
0
		private void Init(string name, Portfolio portfolio, DateTime startDate, DateTime stopDate, double cash, bool reportEnabled, List<Project> projects)
		{
			this.Name = name;
			this.Portfolio = portfolio;
			this.Performance = new Performance(portfolio);
			this.StartDate = startDate;
			this.StopDate = stopDate;
			this.Cash = cash;
			this.ReportEnabled = reportEnabled;
			this.Projects = new ProjectList(projects);
		}
Example #3
0
		private static void AddPortfolio(SmartQuant.Instruments.Portfolio sq_portfolio)
		{
			Portfolio portfolio = new Portfolio(sq_portfolio);
			Map.OQ_SQ_Portfolio[portfolio] = sq_portfolio;
			Map.SQ_OQ_Portfolio[sq_portfolio] = portfolio;
		}
Example #4
0
		internal Performance(Portfolio portfolio)
		{
			this.portfolio = portfolio;
			this.equitySeries = new TimeSeries(portfolio.portfolio.Performance.EquitySeries);
			this.coreEquitySeries = new TimeSeries(portfolio.portfolio.Performance.CoreEquitySeries);
			this.pnLSeries = new TimeSeries(portfolio.portfolio.Performance.PnLSeries);
			this.drawdownSeries = new TimeSeries(portfolio.portfolio.Performance.DrawdownSeries);
			this.drawdownPercentSeries = new TimeSeries(portfolio.portfolio.Performance.DrawdownPercentSeries);
		}
Example #5
0
 public void Online(bool resetState)
 {
     this.active = true;
     if (resetState)
     {
         this.strategies.Clear();
         this.stops.Clear();
         this.activeStops.Clear();
         Map.Instruments[this.strategyName] = new List <string>();
     }
     if (!this.enabled)
     {
         return;
     }
     if (resetState)
     {
         string code = (string)this.sampleStrategy.GetType().GetField("Currency", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField).GetValue((object)this.sampleStrategy);
         if (CurrencyManager.Currencies.Contains(code))
         {
             this.Portfolio.Account.Currency = CurrencyManager.Currencies[code];
         }
         List <string> list   = new List <string>();
         MethodInfo    method = typeof(Strategy).GetMethod("Init", BindingFlags.Instance | BindingFlags.NonPublic);
         FieldInfo     field1 = typeof(Strategy).GetField("startDate", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
         FieldInfo     field2 = typeof(Strategy).GetField("stopDate", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
         FieldInfo     field3 = typeof(Strategy).GetField("cash", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
         foreach (FreeQuant.Instruments.Instrument key in this.instruments)
         {
             Strategy strategy = Activator.CreateInstance(this.sampleStrategy.GetType()) as Strategy;
             this.SetProxyProperties((object)strategy, (object)this.sampleStrategy);
             method.Invoke((object)strategy, new object[6]
             {
                 (object)this.sq_Portfolio,
                 (object)this.sq_MetaPortfolio,
                 (object)key,
                 (object)this.dataRequests,
                 (object)this.strategyName,
                 (object)this.strategyLogManager
             });
             field1.SetValue((object)strategy, (object)this.startDate);
             field2.SetValue((object)strategy, (object)this.stopDate);
             field3.SetValue((object)strategy, (object)this.cash);
             this.strategies.Add(key, strategy);
             list.Add(key.Symbol);
         }
         Map.Instruments[this.strategyName] = list;
         foreach (Strategy strategy in this.strategies.Values)
         {
             strategy.OnStrategyStart();
         }
     }
     else
     {
         OpenQuant.API.Portfolio portfolio = Map.FQ_OQ_Portfolio[(object)this.sq_Portfolio] as OpenQuant.API.Portfolio;
         foreach (object obj in this.strategies.Values)
         {
             typeof(Strategy).GetField("portfolio", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField).SetValue(obj, (object)portfolio);
         }
     }
     this.Connect();
 }