コード例 #1
0
ファイル: BrokerAdapter.cs プロジェクト: myblock001/RinJani
 public IList <Quote> FetchQuotes()
 {
     try
     {
         Log.Debug($"Getting depth from {_config.Broker}...");
         var path = $"data/v1/depth?market={_config.Leg1.ToLower()}_{_config.Leg2.ToLower()}&size=50";
         var req  = RestUtil.CreateJsonRestRequest(path);
         SetBaseUrl("quote");
         var response = _restClient.Execute(req);
         if (response.ErrorException != null)
         {
             throw response.ErrorException;
         }
         Log.Debug($"Received depth from {_config.Broker}.");
         Depth depth = new Depth()
         {
             quotesJson = response.Content, tickerJson = FetchTicker()
         };
         var quotes = depth.ToQuotes();
         return(quotes ?? new List <Quote>());
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message);
         Log.Debug(ex);
         return(new List <Quote>());
     }
 }
コード例 #2
0
ファイル: BrokerAdapter.cs プロジェクト: myblock001/RinJani
        public string FetchTicker()
        {
            Log.Debug($"Getting ticker from {_config.Broker}...");
            var path = $"data/v1/ticker?market={_config.Leg1.ToLower()}_{_config.Leg2.ToLower()}";
            var req  = RestUtil.CreateJsonRestRequest(path);

            SetBaseUrl("quote");
            var response = _restClient.Execute(req);

            return(response.Content);
        }
コード例 #3
0
ファイル: BrokerAdapter.cs プロジェクト: tkikuchi2000/rinjani
        private RestRequest BuildRequest(string path, string method = "GET", string body = "")
        {
            var nonce   = Util.Nonce;
            var message = nonce + method + path + body;
            var sign    = Util.GenerateNewHmac(_config.Secret, message);
            var req     = RestUtil.CreateJsonRestRequest(path);

            req.Method = Util.ParseEnum <Method>(method);
            req.AddParameter("application/json", body, ParameterType.RequestBody);
            req.AddHeader("ACCESS-KEY", _config.Key);
            req.AddHeader("ACCESS-TIMESTAMP", nonce);
            req.AddHeader("ACCESS-SIGN", sign);
            return(req);
        }
コード例 #4
0
ファイル: BrokerAdapter.cs プロジェクト: myblock001/RinJani
        private RestRequest BuildRequest(string path, string method = "GET", string body = "")
        {
            if (!string.IsNullOrEmpty(body))
            {
                string secretkey = _config.Secret;
                secretkey = Util.digest(secretkey);
                String   sign      = Util.hmacSign(body, secretkey);
                DateTime timeStamp = new DateTime(1970, 1, 1);
                //得到1970年的时间戳
                long stamp = (DateTime.UtcNow.Ticks - timeStamp.Ticks) / 10000;
                path += "&sign=" + sign + "&reqTime=" + stamp;
            }
            var req = RestUtil.CreateJsonRestRequest(path);

            req.Method = Util.ParseEnum <Method>(method);
            return(req);
        }
コード例 #5
0
        private RestRequest BuildRequest(string path, string method = "GET", string body = "")
        {
            var nonce   = Util.Nonce;
            var url     = ApiRoot + path;
            var message = nonce + url + body;
            var sign    = Util.GenerateNewHmac(_config.Secret, message);
            var req     = RestUtil.CreateJsonRestRequest(path, false);

            req.Method = Util.ParseEnum <Method>(method);
            if (body != "")
            {
                req.AddParameter("application/x-www-form-urlencoded", body, ParameterType.RequestBody);
            }
            req.AddHeader("ACCESS-KEY", _config.Key);
            req.AddHeader("ACCESS-NONCE", nonce);
            req.AddHeader("ACCESS-SIGNATURE", sign);
            return(req);
        }
コード例 #6
0
        private RestRequest BuildRequest(string path, string method = "GET", string body = "")
        {
            var nonce   = Util.Nonce;
            var payload = new Dictionary <string, object>
            {
                { "path", path },
                { "nonce", nonce },
                { "token_id", _config.Key }
            };
            var sign = Util.JwtHs256Encode(payload, _config.Secret);
            var req  = RestUtil.CreateJsonRestRequest(path);

            req.Method = Util.ParseEnum <Method>(method);
            if (body != "")
            {
                req.AddParameter("application/json", body, ParameterType.RequestBody);
            }
            req.AddHeader("X-Quoine-API-Version", "2");
            req.AddHeader("X-Quoine-Auth", sign);
            return(req);
        }
コード例 #7
0
        public IList <Quote> FetchQuotes()
        {
            try
            {
                Log.Debug($"Getting depth from {_config.Broker}...");
                var path     = "/products/5/price_levels";
                var req      = RestUtil.CreateJsonRestRequest(path);
                var response = _restClient.Execute <Depth>(req);
                if (response.ErrorException != null)
                {
                    throw response.ErrorException;
                }

                Log.Debug($"Received depth from {_config.Broker}.");
                var quotes = response.Data.ToQuotes();
                return(quotes ?? new List <Quote>());
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Log.Debug(ex);
                return(new List <Quote>());
            }
        }