public IndicatorController(
     IObjectTypeService objectTypeService
     , IIndicatorService indicatorService
     , IRatioService ratioService
     , IScoreService scoreService
     , IRoleAccessService roleAccessService
     , IUserRoleService userRoleService
     )
 {
     _indicatorService  = indicatorService;
     _ratioService      = ratioService;
     _scoreService      = scoreService;
     _objectTypeService = objectTypeService;
     _roleAccessService = roleAccessService;
     _userRoleService   = userRoleService;
 }
Exemple #2
0
        public override TradingSignalType Analysis(IEnumerable <Candle> candles, IIndicatorService indicatorService)
        {
            var result     = new List <TradingSignalType>();
            var lastCandle = candles.Last();
            var _macd      = indicatorService.Macd(candles, 12, 26, 9);

            var difLast = _macd.DIF.Last();
            var demLast = _macd.DEM.Last();
            var oscLast = _macd.OSC.Last();


            var _rsi = indicatorService.Rsi(candles, 14);

            var last = _rsi.Last();



            if (/*(decimal)oscLast > 0 &&*/ last < 40)
            {
                return(TradingSignalType.Buy);
            }
            else if (/*(decimal)oscLast < 0 &&*/ last > 65)
            {
                return(TradingSignalType.Sell);
            }
            else
            {
                return(TradingSignalType.Hold);
            }



            /*for (int i = 0; i < candles.Count(); i++)
             * {
             *  if (_rsi[i] > 70 && (_macd.Value[i] - _macd.Signal[i]) < 0)
             *      result.Add(TradingSignalType.Sell);
             *  else if (_rsi[i] < 30 && (_macd.Value[i] - _macd.Signal[i]) > 0)
             *      result.Add(TradingSignalType.Buy);
             *  else
             *      result.Add(TradingSignalType.Hold);
             * }
             *
             * return result.Last();*/
        }
 public ReplacementService(ContentDbContext contentDbContext,
                           StatisticsDbContext statisticsDbContext,
                           IFilterService filterService,
                           IIndicatorService indicatorService,
                           ILocationService locationService,
                           IFootnoteRepository footnoteRepository,
                           IReleaseService releaseService,
                           ITimePeriodService timePeriodService,
                           IPersistenceHelper <ContentDbContext> contentPersistenceHelper,
                           IUserService userService)
 {
     _contentDbContext         = contentDbContext;
     _statisticsDbContext      = statisticsDbContext;
     _filterService            = filterService;
     _indicatorService         = indicatorService;
     _locationService          = locationService;
     _footnoteRepository       = footnoteRepository;
     _releaseService           = releaseService;
     _timePeriodService        = timePeriodService;
     _contentPersistenceHelper = contentPersistenceHelper;
     _userService = userService;
 }
Exemple #4
0
 public EducationalClassesController(
     IEducationalClassService educationalClassService
     , IEducationalGroupService educationalGroupService
     , ITermService termService
     , IProfessorScoreService professorScoreService
     , IScoreService scoreService
     , IRoleAccessService roleAccessService
     , IUserRoleService userRoleService
     , IProfessorService professorService
     , IIndicatorService indicatorService
     )
 {
     _educationalClassService = educationalClassService;
     _educationalGroupService = educationalGroupService;
     _termService             = termService;
     _professorScoreService   = professorScoreService;
     _scoreService            = scoreService;
     _roleAccessService       = roleAccessService;
     _userRoleService         = userRoleService;
     _professorService        = professorService;
     _indicatorService        = indicatorService;
 }
 public EducationalGroupController(
     IEducationalGroupService educationalGroupService
     , ITermService termService
     , IIndicatorService indicatorService
     , IEducationalGroupScoreService educationalGroupScoreService
     , IScoreService scoreService
     , ICollegeService collegeService
     , IRoleAccessService roleAccessService
     , IUserRoleService userRoleService
     , ILogService logService
     )
 {
     _educationalGroupService      = educationalGroupService;
     _termService                  = termService;
     _indicatorService             = indicatorService;
     _educationalGroupScoreService = educationalGroupScoreService;
     _scoreService                 = scoreService;
     _collegeService               = collegeService;
     _reportService                = new DapperService(educationalGroupService);
     _roleAccessService            = roleAccessService;
     _userRoleService              = userRoleService;
     _logService = logService;
 }
 public ResultSubjectMetaService(IBoundaryLevelService boundaryLevelService,
                                 IFilterItemService filterItemService,
                                 IFootnoteRepository footnoteRepository,
                                 IGeoJsonService geoJsonService,
                                 IIndicatorService indicatorService,
                                 ILocationService locationService,
                                 IPersistenceHelper <StatisticsDbContext> persistenceHelper,
                                 ITimePeriodService timePeriodService,
                                 IUserService userService,
                                 ISubjectService subjectService,
                                 ILogger <ResultSubjectMetaService> logger,
                                 IMapper mapper) : base(boundaryLevelService, filterItemService, geoJsonService)
 {
     _boundaryLevelService = boundaryLevelService;
     _footnoteRepository   = footnoteRepository;
     _indicatorService     = indicatorService;
     _locationService      = locationService;
     _persistenceHelper    = persistenceHelper;
     _timePeriodService    = timePeriodService;
     _userService          = userService;
     _subjectService       = subjectService;
     _logger = logger;
     _mapper = mapper;
 }
 public IndicatorController(IIndicatorService indicatorService, ICalculationTypeService calculationTypeService)
 {
     this._indicatorService       = indicatorService;
     this._calculationTypeService = calculationTypeService;
 }
 public IndicatorsApiController(IIndicatorService indicatorService)
 {
     _indicatorService = indicatorService;
 }
        public static void RunAll(
            ITermService termService,
            IMappingService mappingService,
            ICollegeService collegeService,
            IEducationalGroupService educationalGroupService,
            IProfessorService professorService,
            IEducationalClassService educationalClassService,
            IStudentEducationalClassService studentEducationalClassService,
            IProfessorScoreService professorScoreService,
            IIndicatorService indicatorService,
            IMappingTypeService mappingTypeService,
            IUniversityLevelMappingService universityLevelMappingService,
            IEducationalGroupScoreService educationalGroupScoreService,
            ILogService logService,
            ILogTypeService logTypeService,
            IUserService userService,
            string termCode)
        {
            //The order of the execution on the commands is important


            var user = userService.Get(x => x.Username.ToLower() == "Sync".ToLower());

            if (string.IsNullOrEmpty(termCode))
            {
                termCode = ClientHelper.GetScalarValue <string>(StaticValue.CurrentTerm);
            }



            //TermSync.SyncAddOrUpdateTerms(termService, logService, logTypeService, userService, user);
            //MappingSync.Run(mappingService, logService, logTypeService, userService, user);
            //CollegeSync.Run(collegeService, logService, logTypeService, userService, user);
            //ProfessorSync.SyncAddOrUpdateProfessor(professorService, logService, logTypeService, userService, user, termCode);
            //EducationalGroupSync.SyncAddOrUpdateEducationalGroup(educationalGroupService, logService, logTypeService, userService, user, termCode);
            EducationalClassSync.Run(educationalClassService, logService, logTypeService, userService, user, termCode);
            StudentEducationalClassSync.Run(studentEducationalClassService, logService, logTypeService, userService, user, termCode);

            ProfessorSync.SyncProfessorRemoveScore(professorService, logService, logTypeService, userService, user, termCode);

            ProfessorSync.SyncProfessorAddScore(professorService, professorScoreService, indicatorService, termService,
                                                mappingService, mappingTypeService, educationalClassService, universityLevelMappingService,
                                                logService, logTypeService, userService, user, termCode);

            EducationalGroupSync.SyncEducationalGroupRemoveScore(educationalGroupService
                                                                 , logService, logTypeService, userService, user, termCode);

            EducationalGroupSync.SyncEducationalGroupAddScore(educationalGroupService, educationalGroupScoreService,
                                                              indicatorService, termService, professorService, professorScoreService, educationalClassService
                                                              , logService, logTypeService, userService, user, termCode);


            var groupManagerScores     = indicatorService.Get(w => w.CountOfType == ("g" + (int)IndicatorGroupName.ضریب_مدیر_گروه) && w.IsActive == true).Scores.Select(s => s.Id).ToList();
            var groupmanagerGroupScore = educationalGroupScoreService.GetMany(g => groupManagerScores.Contains(g.Score.Id) && g.Term.TermCode == termCode)
                                         .Select(s => s.EducationalGroup.EducationalGroupCode);
            var groupManagerReCalculateList = educationalGroupService
                                              .GetMany(w => !groupmanagerGroupScore.Contains(w.EducationalGroupCode) && w.Term.TermCode == termCode && w.IsActive == true).ToList();

            if (groupManagerReCalculateList.Count() > 0)
            {
                var professores = ClientHelper.GetValue <ProfessorSyncModel>(StaticValue.ProfessorRelativeAddress + $"/{termCode}");
                var reCalcProfs = professores.Where(w => groupManagerReCalculateList.Where(ww => ww.GroupManger != null).Select(s => s.GroupManger.ProfessorCode).Contains(w.ProfessoreCode)).ToList();
                foreach (var item in reCalcProfs)
                {
                    ProfessorSync.SyncGroupManagerProfessorScores(professorService, professorScoreService, indicatorService, termService, mappingService, mappingTypeService
                                                                  , educationalClassService, universityLevelMappingService, item, logService, logTypeService, userService, user, educationalGroupService);
                }

                var groups       = ClientHelper.GetValue <GroupSyncModel>(StaticValue.GroupRelativeAddress + $"/{termCode}");
                var reCalcGroups = groups.Where(w => groupManagerReCalculateList.Where(ww => ww.GroupManger != null).Select(s => s.EducationalGroupCode).Contains(w.EducationalGroupCode)).ToList();
                foreach (var item in reCalcGroups)
                {
                    EducationalGroupSync.SyncGroupManagerEducationalGroupScores(educationalGroupService, educationalGroupScoreService, indicatorService, termService
                                                                                , professorService, professorScoreService, item, educationalClassService, logService, logTypeService, userService, user);
                }
            }
        }
 public IndicatorController(IIndicatorService indicatorService)
 {
     this._indicatorService = indicatorService;
 }
Exemple #11
0
 public IndicatorGroupController(IIndicatorGroupService indicatorGroupService, IIndicatorService indicatorService)
 {
     this._indicatorGroupService = indicatorGroupService;
     this._indicatorService      = indicatorService;
 }
Exemple #12
0
        public void CandleUpdated(IEnumerable <Candle> candles, CandlePeriod candlePeriod, ITimeService timeService, IIndicatorService indicatorService, string strategyId = null)
        {
            if (timeService == null)
            {
                throw new TrendAnalysisDomainException("Time service is not provided when operating on trace.");
            }

            if (indicatorService == null)
            {
                throw new TrendAnalysisDomainException("Indicator service is not provided when operating on trace.");
            }

            if (this.TraceStatus.Id != TraceStatus.Started.Id)
            {
                throw new TrendAnalysisDomainException("Updating candles can only happened before closed and after started.");
            }

            if (this.DateStarted == null)
            {
                throw new TrendAnalysisDomainException(nameof(this.DateStarted));
            }



            var signalUpdated = false;

            if (strategyId != null)
            {
                var strategy = this._tradeStrategies.Where(s => s.StrategyId == strategyId).SingleOrDefault();
                if (strategy == null)
                {
                    throw new TrendAnalysisDomainException("Strategy to update not found");
                }

                if (!this.HasCompleteCandlesBetween(
                        candles,
                        candlePeriod,
                        this.CalculateCandleStartDateWithWarmUp(candlePeriod, strategy.WarmUp),
                        timeService.GetCurrentDateTime()
                        ))
                {
                    throw new TrendAnalysisDomainException("The candles data provided are not completed, each candles from started date to current date must be provided.");
                }

                var orignalSignal = strategy.TradeSignal;

                strategy.Analysis(candles, indicatorService);

                if (strategy.TradeSignal.GetSignalType().Id != orignalSignal.TradingSignalType.Id)
                {
                    signalUpdated = true;
                }
            }
            else
            {
                var matchedStrategies = this._tradeStrategies.Where(s => s.GetIdealPeriod().Id == candlePeriod.Id);
                foreach (var strategy in matchedStrategies)
                {
                    if (!this.HasCompleteCandlesBetween(
                            candles,
                            candlePeriod,
                            this.CalculateCandleStartDateWithWarmUp(candlePeriod, strategy.WarmUp),
                            timeService.GetCurrentDateTime()
                            ))
                    {
                        throw new TrendAnalysisDomainException("The candles data provided are not completed, each candles from started date to current date must be provided.");
                    }

                    var orignalSignal = strategy.TradeSignal;

                    strategy.Analysis(candles, indicatorService);

                    if (strategy.TradeSignal.GetSignalType().Id != orignalSignal.TradingSignalType.Id)
                    {
                        signalUpdated = true;
                    }
                }
            }


            if (signalUpdated == true)
            {
                this.AddDomainEvent(
                    new TradeSignalUpdatedDomainEvent(this, candles, timeService)
                    );
            }

            //var currentCandleTime=
        }