Beispiel #1
0
        public void ChangeShareCurrentPrice(long companyId, double changeRate, SharePriceChangingType changingType)
        {
            var shares = GetByCompanyId(companyId);

            foreach (Share share in shares)
            {
                share.PriceChangingTrand = changingType;
                double diff = share.CurrentPrice * changeRate;
                switch (changingType)
                {
                case SharePriceChangingType.Fixed:
                    continue;

                case SharePriceChangingType.Increasing:
                    share.CurrentPrice += diff;
                    break;

                case SharePriceChangingType.Decreasing:
                    share.CurrentPrice -= diff;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(changingType));
                }
            }
            Save(shares);
        }
Beispiel #2
0
        private void ChangeSharePriceIfWantTo(long companyId, SharePriceChangingType sharePriceChangingType)
        {
            ICollection <Share> mineShares = GetMineShares(companyId);
            double changeRate;

            if (!MakeRandomDecision() && mineShares.Any())
            {
                // Если нет хочет/может повысить цену на акции
                sharePriceChangingType = SharePriceChangingType.Fixed;
                changeRate             = 0;
            }
            else
            {
                changeRate = MiscUtils.GetRandomNumber(MaxIncreaseDecreaseRate, MinIncreaseDecreaseRate);
            }
            Injector.Get <IShareStorage>().ChangeShareCurrentPrice(companyId, changeRate, sharePriceChangingType);
        }