private decimal Calculate(decimal[] values, bool isPrice)
        {
            var value = OnCalculate(values);

            if (isPrice)
            {
                var step = BasketSecurity.PriceStep;

                if (step != null)
                {
                    value = BasketSecurity.ShrinkPrice(value);
                }
            }
            else
            {
                var step = BasketSecurity.VolumeStep;

                if (step != null)
                {
                    value = MathHelper.Round(value, step.Value, step.Value.GetCachedDecimals());
                }
            }

            return(value);
        }
Esempio n. 2
0
            public BasketSecurityMarketDepthChangedRule(BasketSecurity security, IMarketDataProvider provider)
                : base(security, provider)
            {
                Name = LocalizedStrings.Str1050 + " " + security;
#pragma warning disable CS0618 // Type or member is obsolete
                Provider.MarketDepthChanged += OnMarketDepthChanged;
#pragma warning restore CS0618 // Type or member is obsolete
            }
        /// <summary>
        /// Initializes a new instance of the <see cref="BasketSecurityBaseProcessor{TSecurity}"/>.
        /// </summary>
        /// <param name="basketSecurity">Instruments basket.</param>
        protected BasketSecurityBaseProcessor(TSecurity basketSecurity)
        {
            BasketSecurity = basketSecurity ?? throw new ArgumentNullException(nameof(basketSecurity));

            BasketLegs = BasketSecurity.InnerSecurityIds.ToArray();
            SecurityId = BasketSecurity.ToSecurityId();

            if (BasketLegs.IsEmpty())
            {
                throw new ArgumentException(LocalizedStrings.SecurityDoNotContainsLegs.Put(basketSecurity.Id), nameof(basketSecurity));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// To create a rule for the event of order book change by instruments basket.
 /// </summary>
 /// <param name="security">Instruments basket to be traced for the event of order books change by internal instruments.</param>
 /// <param name="provider">The market data provider.</param>
 /// <returns>Rule.</returns>
 public static MarketRule <Security, MarketDepth> WhenMarketDepthChanged(this BasketSecurity security, IMarketDataProvider provider)
 {
     return(new BasketSecurityMarketDepthChangedRule(security, provider));
 }