コード例 #1
0
ファイル: BrokerAdapter.cs プロジェクト: myblock001/RinJani
 public BrokerBalance GetBalance()
 {
     try
     {
         Log.Debug("Hpx GetBalance Begin");
         var    path = "/api/v2/getAccountInfo?";
         string body = "method=getAccountInfo&accesskey=" + _config.Key;
         path += body;
         var req = BuildRequest(path, "GET", body);
         RestUtil.LogRestRequest(req);
         var response = _restClient.Execute(req);
         if (response == null || response.StatusCode == 0)
         {
             Log.Debug($"Hpx GetBalance response is null or failed ...");
             return(null);
         }
         JObject j = JObject.Parse(response.Content);
         j = JObject.Parse(j["data"].ToString());
         j = JObject.Parse(j["balance"].ToString());
         BrokerBalance bb = new BrokerBalance();
         bb.Broker = Broker;
         bb.Leg1   = decimal.Parse(j[_config.Leg1.ToUpper()].ToString());
         bb.Leg2   = decimal.Parse(j[_config.Leg2.ToUpper()].ToString());
         Log.Debug("Hpx GetBalance End");
         return(bb);
     }
     catch (Exception ex)
     {
         Log.Debug("Hpx GetBalance Exception:" + ex.Message);
         return(null);
     }
 }
コード例 #2
0
ファイル: BrokerAdapter.cs プロジェクト: myblock001/RinJani
 public BrokerBalance GetBalance()
 {
     try
     {
         Log.Debug($"Zb GetBalance Start ...");
         var    path = "/api/getAccountInfo?";
         string body = "accesskey=" + _config.Key + "&method=getAccountInfo";
         path += body;
         var req = BuildRequest(path, "GET", body);
         RestUtil.LogRestRequest(req);
         SetBaseUrl("trade");
         var response = _restClient.Execute(req);
         if (response == null || response.StatusCode == 0)
         {
             Log.Debug($"Zb GetBalance response is null or failed ...");
             return(null);
         }
         JObject j = JObject.Parse(response.Content);
         j = JObject.Parse(j["result"].ToString());
         JArray  jar   = JArray.Parse(j["coins"].ToString());
         JObject jleg1 = null;
         JObject jleg2 = null;
         foreach (JObject jj in jar)
         {
             if (jj["enName"].ToString().ToUpper() == _config.Leg1.ToUpper())
             {
                 jleg1 = jj;
             }
             if (jj["enName"].ToString().ToUpper() == _config.Leg2.ToUpper())
             {
                 jleg2 = jj;
             }
             if (jleg1 != null && jleg2 != null)
             {
                 break;
             }
         }
         BrokerBalance bb = new BrokerBalance();
         bb.Broker = Broker;
         bb.Leg1   = decimal.Parse(jleg1["available"].ToString());
         bb.Leg2   = decimal.Parse(jleg2["available"].ToString());
         Log.Debug($"Zb GetBalance End ...");
         return(bb);
     }
     catch (Exception ex)
     {
         Log.Debug($"Zb GetBalance response is null or failed ...{ex.Message}");
         return(null);
     }
 }