Esempio n. 1
0
        private async Task <BetRateCalculator> GetBetRateCalculator(BetRateAlgorithm betRateAlgorithm)
        {
            var           factory       = new BetRateCalculatorFactory(betRateAlgorithm.LocusRage);
            AlgorithmType algorithmType = await this._repositoryAlgorithmType.Get(betRateAlgorithm.AlgorithmTypeId);

            return(factory.Create(algorithmType.Name));
        }
Esempio n. 2
0
        private async Task <BetRateCalculatorDateTime> GetBetRateCalculator(BetRateAlgorithm betRateAlgorithm, Event @event)
        {
            var           factory       = new BetRateCalculatorFactory(betRateAlgorithm.LocusRage);
            AlgorithmType algorithmType = await this._repositoryAlgorithmType.Get(betRateAlgorithm.AlgorithmTypeId);

            return(factory.CreateDateTime(algorithmType.Name, @event.StartDate, @event.EndDate));
        }
Esempio n. 3
0
        public async Task <byte[]> CalculateBetConditionChartData(BetRateAlgorithm betRateAlgorithm)
        {
            ICalculator <double, double> calculator = await this.GetBetRateCalculator(betRateAlgorithm);

            byte[] data = Enumerable.Range(0, 100)
                          .Select(p => (byte)(calculator.Calculate(p / 100.0) * byte.MaxValue))
                          .ToArray();

            return(data);
        }
Esempio n. 4
0
        public async Task <BetRateAlgorithm> CreateEventBetRateAlgorithm(Account account, AlgorithmType algorithmType, double startRate, double endRate, double locusRage)
        {
            using (this._scopeableFactory.Create())
            {
                var betRateAlgorithm = new BetRateAlgorithm
                {
                    AccountId       = account.Id,
                    AlgorithmTypeId = algorithmType.Id,
                    StartRate       = startRate,
                    EndRate         = endRate,
                    LocusRage       = locusRage
                };

                await this._repositoryBetRateAlgorithm.Add(betRateAlgorithm);

                return(betRateAlgorithm);
            }
        }
Esempio n. 5
0
        public async Task <EventBetCondition> CreateEventBetCondition(Account account, CurrencyType currencyType, BetRateAlgorithm betRateAlgorithm, DateTime closeDate)
        {
            using (this._scopeableFactory.Create())
            {
                var eventBetCondition = new EventBetCondition
                {
                    AccountId               = account.Id,
                    CloseDate               = closeDate,
                    CurrencyTypeId          = currencyType.Id,
                    EventBetRateAlgorithmId = betRateAlgorithm.Id,
                };

                await this._repositoryEventBetCondition.Add(eventBetCondition);

                return(eventBetCondition);
            }
        }