示例#1
0
        public async Task <List <Candle> > GetCandles(string symbolName, PublicEnum.EnPeriod enPeriod = PublicEnum.EnPeriod.M30)
        {
            var period  = enPeriod.ToString() == "Month" ? "1M" : enPeriod.ToString();
            var request = new RestRequest("api/2/public/candles/{symbol}");

            request.AddParameter("symbol", symbolName, ParameterType.UrlSegment);
            request.AddParameter("period", period, ParameterType.UrlSegment);
            return(await _hitBtcRestApi.Execute(request, false));
        }
示例#2
0
        public async Task <SocketSubscribe> UnsubscribeCandles(string symbol, PublicEnum.EnPeriod enPeriod = PublicEnum.EnPeriod.M30, int id = 123)
        {
            var period  = enPeriod.ToString() == "Month" ? "1M" : enPeriod.ToString();
            var request =
                string.Format(
                    "{{ \"method\": \"unsubscribeCandles\", \"params\": {{ \"symbol\": \"{0}\" , \"period\": \"{1}\"}}, \"id\": {2} }}",
                    symbol, period, id);

            return(await _hitBtcSocketApi.Execute(request, false));
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="enPeriod"></param>
        /// <param name="data"></param>
        public async void NotificationUpdateCandles(string symbol, PublicEnum.EnPeriod enPeriod, List <Candle> data)
        {
            string dataParameters = data.Aggregate(string.Empty,
                                                   (current, parameter) =>
                                                   current +
                                                   string.Format(
                                                       " {{\"timestamp\":\"{0}\",\"open\":\"{1}\",\"close\":\"{2}\",\"min\":\"{3}\",\"max\":\"{4}\",\"volume\":\"{5}\",\"volumeQuote\":\"{6}\"}},",
                                                       parameter.Timestamp, parameter.Open, parameter.Close, parameter.Min, parameter.Max,
                                                       parameter.Volume, parameter.VolumeQuote));

            dataParameters = dataParameters.TrimEnd(',');
            var period  = enPeriod.ToString() == "Month" ? "1M" : enPeriod.ToString();
            var request =
                string.Format(
                    "{{\"jsonrpc\":\"2.0\",\"method\":\"updateCandles\",\"params\":{{\"data\":[{0}],\"symbol\":\"{1}\",\"period\":\"{2}\"}}}}",
                    dataParameters, symbol, period);
            await _hitBtcSocketApi.Execute(request);
        }