/// <summary> /// Throws MsgException when feature is not available in memebrs country /// </summary> public bool CreditVideo(Video video = null) { FeatureManager Manager = new FeatureManager(base.User, GeolocatedFeatureType.Video); if (!Manager.IsAllowed) { throw new MsgException(U4000.GEONOTAVAILABLE.Replace("%p%", AppSettings.PointsName)); } //Anti-Fraud bool IsEligibleForCredit = true; int reward = Manager.Reward; //Max daily limit if (User.PointsCreditedTodayForVideo + reward > AppSettings.SearchAndVideo.MaxPointsDailyForVideo) { IsEligibleForCredit = false; } if (IsEligibleForCredit) { base.CreditPoints(reward, Note, BalanceLogType.GPTVideo); base.CreditReferersPoints(reward, Note, BalanceLogType.GPTVideo); User.PointsCreditedTodayForVideo += reward; } User.TotalVideosWatched++; User.SaveSearchAndVideo(); //General statistics StatisticsManager.Add(StatisticsType.VideosWatched, 1); return(IsEligibleForCredit); }
public static void Change(this StatisticsManager manager, int type, PortfolioStatisticsItem statisticsItem) { var i = (ICustomStatisticsType)statisticsItem; i.SetStatisticsType(type); manager.Add(statisticsItem); }
private static void ApplyToStats(int points) { AppSettings.Points.Reload(); //Points generated stats AppSettings.Points.TotalExchanged += points; AppSettings.Points.Save(); StatisticsManager.Add(StatisticsType.PointsExchanged, points); }
public static void AddStatisticsItem(this StatisticsManager manager, PortfolioStatisticsItem statisticsItem) { var i = (ICustomStatisticsType)statisticsItem; if (i != null) { var max = 0; foreach (var item in manager.Statistics) { if (item.GetType() == statisticsItem.GetType()) { return; } max = Math.Max(max, item.Type); } i.SetStatisticsType(max + 1); } manager.Add(statisticsItem); }
/// <summary> /// Throws MsgException when feature is not available in memebrs country /// </summary> public bool CreditSearch() { FeatureManager Manager = new FeatureManager(base.User, GeolocatedFeatureType.Search); if (!Manager.IsAllowed) { throw new MsgException(U4000.GEONOTAVAILABLE.Replace("%p%", AppSettings.PointsName)); } //Anti-Fraud bool IsEligibleForCredit = true; int reward = Manager.Reward; //Max daily limit if (User.PointsCreditedTodayForSearch + reward > AppSettings.SearchAndVideo.MaxPointsDailyForSearch) { IsEligibleForCredit = false; } //Security timer if (User.LastCreditedSearch.AddSeconds(AppSettings.SearchAndVideo.SearchCreditingBlockedInMinutes) > DateTime.Now) { IsEligibleForCredit = false; } if (IsEligibleForCredit) { base.CreditPoints(reward, Note, BalanceLogType.GPTSearch); User.LastCreditedSearch = DateTime.Now; User.PointsCreditedTodayForSearch += reward; } User.TotalSearchesDone++; User.SaveSearchAndVideo(); //General statistics StatisticsManager.Add(StatisticsType.SearchesMade, 1); return(IsEligibleForCredit); }
public override void Run() { StatisticsManager.Add(new DailyNumOfLossTrades()); StatisticsManager.Add(new DailyNumOfWinTrades()); StatisticsManager.Add(new DailyConsecutiveLossTrades()); Instrument instrument1 = InstrumentManager.Instruments["IF999"]; Instrument instrument2 = InstrumentManager.Instruments["IC999"]; // Create SMA Crossover strategy //DualThrust_RangeBreak_Strategy strategy = new DualThrust_RangeBreak_Strategy(framework, "DualThrust & RangeBreak"); //RBreaker_Strategy strategy = new RBreaker_Strategy(framework, "RBreaker"); //DynamicBreakOut2 strategy = new DynamicBreakOut2(framework, "DynamicBreakOut2"); DoubleMA_Crossover strategy = new DoubleMA_Crossover(framework, "DoubleMA Crossover"); strategy.MaxBarSize = MaxBarSize; // Add instruments strategy.AddInstrument(instrument1); strategy.AddInstrument(instrument2); // Set simulation interval DataSimulator.DateTime1 = new DateTime(2015, 04, 16); //DataSimulator.DateTime2 = new DateTime(2013, 12, 16, 9, 36, 0); DataSimulator.DateTime2 = new DateTime(2016, 11, 02); // Add 1 minute bars BarFactory.Add(instrument1, SmartQuant.BarType.Time, barSize); BarFactory.Add(instrument2, SmartQuant.BarType.Time, barSize); BarFactory.Add(instrument1, SmartQuant.BarType.Time, MaxBarSize); BarFactory.Add(instrument2, SmartQuant.BarType.Time, MaxBarSize); this.strategy = strategy; // Run the strategy StartStrategy(); }
public override void Run() { StatisticsManager.Add(new DailyNumOfLossTrades()); StatisticsManager.Add(new DailyNumOfWinTrades()); StatisticsManager.Add(new DailyConsecutiveLossTrades()); Instrument instrument1 = InstrumentManager.Instruments["IF999"]; Instrument instrument2 = InstrumentManager.Instruments["IC999"]; // Create SMA Crossover strategy //DualThrust_RangeBreak_Strategy strategy = new DualThrust_RangeBreak_Strategy(framework, "DualThrust & RangeBreak"); //RBreaker_Strategy strategy = new RBreaker_Strategy(framework, "RBreaker"); //DynamicBreakOut2 strategy = new DynamicBreakOut2(framework, "DynamicBreakOut2"); DoubleMA_Crossover strategy = new DoubleMA_Crossover(framework, "DoubleMA Crossover"); strategy.MaxBarSize = MaxBarSize; // Add instruments strategy.AddInstrument(instrument1); //strategy.AddInstrument(instrument2); // Set simulation interval DataSimulator.DateTime1 = new DateTime(2015, 04, 16); //DataSimulator.DateTime2 = new DateTime(2013, 12, 16, 9, 36, 0); DataSimulator.DateTime2 = new DateTime(2016, 11, 02); // Add 1 minute bars BarFactory.Add(instrument1, SmartQuant.BarType.Time, barSize); //BarFactory.Add(instrument2, SmartQuant.BarType.Time, barSize); BarFactory.Add(instrument1, SmartQuant.BarType.Time, MaxBarSize); //BarFactory.Add(instrument2, SmartQuant.BarType.Time, MaxBarSize); this.strategy = strategy; Provider quantRouter = framework.ProviderManager.GetProvider(99) as Provider; if (quantRouter.Status == ProviderStatus.Disconnected) { quantRouter.Connect(); } while (!quantRouter.IsConnected) { Thread.Sleep(1000); } if (framework.StrategyManager.Mode == StrategyMode.Paper) { // Set QuantRouter as data provider. strategy.DataProvider = quantRouter as IDataProvider; } else if (framework.StrategyManager.Mode == StrategyMode.Live) { // Set QuantRouter as data and execution provider. strategy.DataProvider = quantRouter as IDataProvider; strategy.ExecutionProvider = quantRouter as IExecutionProvider; } // Run the strategy StartStrategy(); }