示例#1
0
        /// <summary>
        /// find price accuracy for security
        /// найти точность цены для бумаги
        /// </summary>
        private void SetPriceStepInSecurity(Security security)
        {
            BitfinexTickerTradeInfo info = _client.GetTradeInfo(security.Name);

            // find the longest string / находим самую длинную строку

            string maxLengthStr = info.ask;

            if (info.bid.Length > maxLengthStr.Length)
            {
                maxLengthStr = info.bid;
            }

            if (info.high.Length > maxLengthStr.Length)
            {
                maxLengthStr = info.high;
            }

            if (info.low.Length > maxLengthStr.Length)
            {
                maxLengthStr = info.low;
            }

            maxLengthStr = maxLengthStr.Replace('.', ',');

            decimal step     = 1;
            int     decimals = 0;

            if (maxLengthStr.Split(',').Length > 1)
            {
                decimals = maxLengthStr.Split(',')[1].Length;

                for (int i = 0; i < decimals; i++)
                {
                    step *= 0.1m;
                }
            }

            security.Decimals      = decimals;
            security.PriceStep     = step;
            security.PriceStepCost = step;
            Thread.Sleep(3300);
        }