Ejemplo n.º 1
0
        public IEnumerable <Trendline> GetVisibleTrendlines(int assetId, int timeframeId)
        {
            _repository = new EFTrendlineRepository();
            var dtos = _repository.GetVisibleTrendlines(assetId, timeframeId);

            return(GetTrendlines(assetId, timeframeId, dtos));
        }
Ejemplo n.º 2
0
        public void GetTrendlineRepository_alwaysReturnsSingletonInstance()
        {
            ITrendlineRepository repository  = RepositoryFactory.GetTrendlineRepository();
            ITrendlineRepository repository2 = RepositoryFactory.GetTrendlineRepository();

            Assert.AreSame(repository, repository2);
        }
Ejemplo n.º 3
0
        public Trendline GetTrendlineById(int id)
        {
            _repository = new EFTrendlineRepository();
            var dto = _repository.GetTrendlineById(id);

            return(Trendline.FromDto(dto));
        }
Ejemplo n.º 4
0
 static RepositoryFactory()
 {
     marketRepository     = new EFMarketRepository();
     currencyRepository   = new EFCurrencyRepository();
     assetRepository      = new EFAssetRepository();
     timeframeRepository  = new EFTimeframeRepository();
     quotationRepository  = new EFQuotationRepository();
     priceRepository      = new EFPriceRepository();
     simulationRepository = new EFSimulationRepository();
     analysisRepository   = new EFAnalysisRepository();
     trendlineRepository  = new EFTrendlineRepository();
 }
Ejemplo n.º 5
0
        private Dictionary <int, ExtremumGroup> GetExtremumGroupsMap(int assetId, int timeframeId)
        {
            _repository = new EFTrendlineRepository();
            Dictionary <int, ExtremumGroup> map = new Dictionary <int, ExtremumGroup>();

            foreach (var dto in _repository.GetExtremumGroups(assetId, timeframeId))
            {
                var eg = ExtremumGroup.FromDto(dto);
                map.Add(eg.ExtremumGroupId, eg);
            }
            return(map);
        }
Ejemplo n.º 6
0
        private Dictionary <int, TrendBreak> GetTrendBreaksMap(int assetId, int timeframeId)
        {
            _repository = new EFTrendlineRepository();
            IEnumerable <TrendBreakDto> dtos = _repository.GetTrendBreaks();

            Dictionary <int, TrendBreak> trendBreaksMap = new Dictionary <int, TrendBreak>();

            foreach (var dto in dtos)
            {
                var trendBreak = TrendBreak.FromDto(dto);
                trendBreaksMap.Add(trendBreak.TrendBreakId, trendBreak);
            }
            return(trendBreaksMap);
        }
Ejemplo n.º 7
0
        private IEnumerable <TrendRange> GetTrendRanges(int assetId, int timeframeId)
        {
            _repository = new EFTrendlineRepository();
            IEnumerable <TrendRangeDto>  dtos        = _repository.GetTrendRanges();
            IEnumerable <TrendRange>     trendRanges = dtos.Select(tr => TrendRange.FromDto(tr));
            Dictionary <int, TrendHit>   trendHits   = GetTrendHitsMap(assetId, timeframeId);
            Dictionary <int, TrendBreak> trendBreaks = GetTrendBreaksMap(assetId, timeframeId);
            List <TrendRange>            result      = new List <TrendRange>();

            foreach (var trendRange in trendRanges)
            {
                TrendHit   th;
                TrendBreak tb;

                if (trendRange.BaseIsHit == 1)
                {
                    trendHits.TryGetValue(trendRange.BaseId, out th);
                    trendRange.StartDelimiter = th;
                }
                else
                {
                    trendBreaks.TryGetValue(trendRange.BaseId, out tb);
                    trendRange.StartDelimiter = tb;
                }


                if (trendRange.CounterIsHit == 1)
                {
                    trendHits.TryGetValue(trendRange.CounterId, out th);
                    trendRange.EndDelimiter = th;
                }
                else
                {
                    trendBreaks.TryGetValue(trendRange.CounterId, out tb);
                    trendRange.EndDelimiter = tb;
                }

                result.Add(trendRange);
            }

            return(result);
        }
Ejemplo n.º 8
0
        private Dictionary <int, TrendHit> GetTrendHitsMap(int assetId, int timeframeId)
        {
            _repository = new EFTrendlineRepository();
            IEnumerable <TrendHitDto>  dtos         = _repository.GetTrendHits();
            IEnumerable <TrendHit>     trendHits    = dtos.Select(th => TrendHit.FromDto(th));
            Dictionary <int, TrendHit> trendHitsMap = new Dictionary <int, TrendHit>();

            Dictionary <int, ExtremumGroup> extremumGroupsMap = GetExtremumGroupsMap(assetId, timeframeId);

            foreach (var trendHit in trendHits)
            {
                ExtremumGroup eg = null;
                extremumGroupsMap.TryGetValue(trendHit.ExtremumGroupId, out eg);
                if (eg != null)
                {
                    trendHit.ExtremumGroup = eg;
                }
                trendHitsMap.Add(trendHit.TrendHitId, trendHit);
            }

            return(trendHitsMap);
        }
Ejemplo n.º 9
0
 static RepositoryFactory()
 {
     quotationRepository = new EFQuotationRepository();
     trendlineRepository = new EFTrendlineRepository();
 }
Ejemplo n.º 10
0
 public IEnumerable <ExtremumGroup> GetExtremumGroups(int assetId, int timeframeId)
 {
     _repository = new EFTrendlineRepository();
     return(_repository.GetExtremumGroups(assetId, timeframeId).Select(dto => ExtremumGroup.FromDto(dto)));
 }