Exemple #1
0
        /// <summary>
        /// обновился список бумаг
        /// </summary>
        void _clientBitStamp_UpdatePairs(SecurityResponce pairs)
        {
            if (_securities == null)
            {
                _securities = new List <Security>();
            }

            foreach (var sec in pairs.symbols)
            {
                Security security = new Security();
                security.Name      = sec.symbol;
                security.NameFull  = sec.symbol;
                security.NameClass = sec.quoteAsset;
                // sec.filters[1] - минимальный объем равный цена * объем
                security.Lot            = Convert.ToDecimal(sec.filters[1].stepSize.Replace(".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture);
                security.PriceStep      = Convert.ToDecimal(sec.filters[0].tickSize.Replace(".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture);
                security.PriceLimitLow  = Convert.ToDecimal(sec.filters[0].minPrice.Replace(".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture);
                security.PriceLimitHigh = Convert.ToDecimal(sec.filters[0].maxPrice.Replace(".", CultureInfo.InvariantCulture.NumberFormat.NumberDecimalSeparator), CultureInfo.InvariantCulture);

                if (security.PriceStep < 1)
                {
                    security.Decimals = Convert.ToString(security.PriceStep).Split(',')[1].Split('1')[0].Length + 1;
                }
                else
                {
                    security.Decimals = 0;
                }

                security.State = SecurityStateType.Activ;

                _securities.Add(security);
            }

            _securitiesToSend.Enqueue(_securities);
        }
Exemple #2
0
        /// <summary>
        /// взять бумаги
        /// </summary>
        public SecurityResponce GetSecurities()
        {
            lock (_lock)
            {
                try
                {
                    var res = CreateQuery(Method.GET, "api/v1/exchangeInfo", null, false);

                    SecurityResponce secResp = JsonConvert.DeserializeAnonymousType(res, new SecurityResponce());

                    if (UpdatePairs != null)
                    {
                        UpdatePairs(secResp);
                    }

                    return(secResp);
                }
                catch (Exception ex)
                {
                    if (LogMessageEvent != null)
                    {
                        LogMessageEvent(ex.ToString(), LogMessageType.Error);
                    }

                    return(null);
                }
            }
        }
        void _client_UpdatePairs(SecurityResponce pairs)
        {
            if (_securities == null)
            {
                _securities = new List <Security>();
            }

            foreach (var sec in pairs.symbols)
            {
                Security security = new Security();
                security.Name         = sec.symbol;
                security.NameFull     = sec.symbol;
                security.NameClass    = sec.quoteAsset;
                security.NameId       = sec.symbol + sec.quoteAsset;
                security.SecurityType = SecurityType.CurrencyPair;
                // sec.filters[1] - минимальный объем равный цена * объем
                security.Lot           = 1;
                security.PriceStep     = sec.filters[0].tickSize.ToDecimal();
                security.PriceStepCost = security.PriceStep;

                security.PriceLimitLow  = sec.filters[0].minPrice.ToDecimal();
                security.PriceLimitHigh = sec.filters[0].maxPrice.ToDecimal();


                if (security.PriceStep < 1)
                {
                    string prStep = security.PriceStep.ToString(CultureInfo.InvariantCulture);
                    security.Decimals = Convert.ToString(prStep).Split('.')[1].Split('1')[0].Length + 1;
                }
                else
                {
                    security.Decimals = 0;
                }

                if (sec.filters.Count > 1 &&
                    sec.filters[2] != null &&
                    sec.filters[2].minQty != null)
                {
                    decimal minQty = sec.filters[2].minQty.ToDecimal();
                    security.MinTradeAmount = minQty;
                    string qtyInStr = minQty.ToStringWithNoEndZero().Replace(",", ".");
                    if (qtyInStr.Split('.').Length > 1)
                    {
                        security.DecimalsVolume = qtyInStr.Split('.')[1].Length;
                    }
                }

                security.State = SecurityStateType.Activ;
                _securities.Add(security);
            }

            if (SecurityEvent != null)
            {
                SecurityEvent(_securities);
            }
        }
Exemple #4
0
        void _client_UpdatePairs(SecurityResponce pairs)
        {
            if (_securities == null)
            {
                _securities = new List <Security>();
            }

            foreach (var sec in pairs.symbols)
            {
                Security security = new Security();
                security.Name         = sec.symbol;
                security.NameFull     = sec.symbol;
                security.NameClass    = sec.quoteAsset;
                security.NameId       = sec.symbol + sec.quoteAsset;
                security.SecurityType = SecurityType.Futures;
                // sec.filters[1] - минимальный объем равный цена * объем
                security.Lot           = 1;
                security.PriceStep     = sec.filters[0].tickSize.ToDecimal();
                security.PriceStepCost = security.PriceStep;

                security.PriceLimitLow  = sec.filters[0].minPrice.ToDecimal();
                security.PriceLimitHigh = sec.filters[0].maxPrice.ToDecimal();

                if (security.PriceStep < 1)
                {
                    string prStep = security.PriceStep.ToString(CultureInfo.InvariantCulture);
                    security.Decimals = Convert.ToString(prStep).Split('.')[1].Split('1')[0].Length + 1;
                }
                else
                {
                    security.Decimals = 0;
                }

                security.State = SecurityStateType.Activ;
                _securities.Add(security);
            }

            if (SecurityEvent != null)
            {
                SecurityEvent(_securities);
            }
        }
        void _client_UpdatePairs(SecurityResponce pairs)
        {
            if (_securities == null)
            {
                _securities = new List <Security>();
            }

            foreach (var sec in pairs.symbols)
            {
                Security security = new Security();
                security.Name          = sec.symbol;
                security.NameFull      = sec.symbol;
                security.NameClass     = sec.quoteAsset;
                security.NameId        = sec.symbol + sec.quoteAsset;
                security.SecurityType  = SecurityType.Futures;
                security.Lot           = sec.filters[1].minQty.ToDecimal();
                security.PriceStep     = sec.filters[0].tickSize.ToDecimal();
                security.PriceStepCost = security.PriceStep;

                security.PriceLimitLow  = sec.filters[0].minPrice.ToDecimal();
                security.PriceLimitHigh = sec.filters[0].maxPrice.ToDecimal();

                if (security.PriceStep < 1)
                {
                    string prStep = security.PriceStep.ToString(CultureInfo.InvariantCulture);
                    security.Decimals = Convert.ToString(prStep).Split('.')[1].Split('1')[0].Length + 1;
                }
                else
                {
                    security.Decimals = 0;
                }

                if (sec.filters.Count > 1 &&
                    sec.filters[2] != null &&
                    sec.filters[2].minQty != null)
                {
                    decimal minQty   = sec.filters[2].minQty.ToDecimal();
                    string  qtyInStr = minQty.ToStringWithNoEndZero().Replace(",", ".");
                    if (qtyInStr.Split('.').Length > 1)
                    {
                        security.DecimalsVolume = qtyInStr.Split('.')[1].Length;
                    }
                }

                security.State = SecurityStateType.Activ;
                _securities.Add(security);
            }

            List <Security> secNonPerp = new List <Security>();

            for (int i = 0; i < _securities.Count; i++)
            {
                string[] str = _securities[i].Name.Split('_');

                if (str.Length > 1 &&
                    str[1] != "PERP")
                {
                    secNonPerp.Add(_securities[i]);
                }
            }

            List <Security> securitiesHistorical = CreateHistoricalSecurities(secNonPerp);

            _securities.AddRange(securitiesHistorical);

            if (SecurityEvent != null)
            {
                SecurityEvent(_securities);
            }
        }