Esempio n. 1
0
        /// <summary>selllimit
        /// <para>Place a sell limit order in a specific market.</para>
        /// <para>Required : market - Market name (ex: SYM-MKT)</para>
        /// <para>Required : quantity - Amount to purchase</para>
        /// <para>Required : rate - Rate at which to place the order</para>
        /// <para>Optional : none</para>
        /// </summary>
        public static CCEXBuySellMessage setSell(string symbol, string market, Decimal quantity, Decimal rate)
        {
            try
            {
                string requestUrl = "https://c-cex.com/t/api.html?a=selllimit&apikey=" + Api.key +
                                    "&market=" + symbol + "-" + market +
                                    "&quantity=" + quantity +
                                    "&rate=" + rate +
                                    "&nonce=" + ExchangeManager.GetNonce();

                var    jsonObject = JObject.Parse(GetApiRequest(requestUrl));
                string success    = jsonObject["success"].ToString().ToLower();

                if (success == "true")
                {
                    return(jsonObject["result"].ToObject <CCEXBuySellMessage>());
                }
                else
                {
                    LogManager.AddLogMessage(Name, "setSell", "sucess IS FALSE : message=" + jsonObject["message"], LogManager.LogMessageType.DEBUG);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "setSell", ex.Message, LogManager.LogMessageType.EXCEPTION);
                return(null);
            }
        }
Esempio n. 2
0
        public static async Task <TradeSatoshiBalance> GetBalance(string Currency)
        {
            TradeSatoshiBalance balance = new TradeSatoshiBalance();

            using (HttpClient client = new HttpClient())
            {
                try
                {
                    string uri = "https://tradesatoshi.com/api/private/getbalance";
                    //string nonce = Guid.NewGuid().ToString();
                    string  nonce       = ExchangeManager.GetNonce();
                    JObject post_params = new JObject();
                    post_params.Add("Currency", Currency);
                    string signature = GetSignature(uri, nonce, JsonConvert.SerializeObject(post_params)).Result;
                    //string authenticationString = "Basic " + GlobalSettings.API_Key + ":" + signature + ":" + nonce;
                    string authenticationString = Api.key + ":" + signature + ":" + nonce;
                    //string authenticationString = "Basic " + Api.key + ":" + signature + ":" + nonce;
                    client.DefaultRequestHeaders.Add("Authentication", authenticationString);
                    string result = await client.PostAsync(uri, new StringContent(JsonConvert.SerializeObject(post_params), Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync();

                    LogManager.AddLogMessage(Name, "GetBalance", "result=" + result, LogManager.LogMessageType.CONSOLE);
                    //return JsonConvert.DeserializeObject<GetBalanceReturn>(await client.PostAsync(uri, new StringContent(JsonConvert.SerializeObject(post_params), Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync());
                }
                catch (Exception ex)
                {
                    LogManager.AddLogMessage(Name, "GetBalance", ex.Message, LogManager.LogMessageType.EXCEPTION);
                    //throw e;
                };
            }
            return(balance);
        }
Esempio n. 3
0
        /// <summary>cancel
        /// <para>Cancel a buy or sell order.</para>
        /// <para>Required : uuid - uuid of buy or sell order</para>
        /// <para>Optional : none</para>
        /// </summary>
        public static CCEXBuySellMessage setCancel(string uuid)
        {
            try
            {
                string requestUrl = "https://c-cex.com/t/api.html?a=cancel&apikey=" + Api.key +
                                    "&uuid=" + uuid +
                                    "&nonce=" + ExchangeManager.GetNonce();

                var    jsonObject = JObject.Parse(GetApiRequest(requestUrl));
                string success    = jsonObject["success"].ToString().ToLower();

                if (success == "true")
                {
                    return(jsonObject["result"].ToObject <CCEXBuySellMessage>());
                }
                else
                {
                    LogManager.AddLogMessage(Name, "setSell", "sucess IS FALSE : message=" + jsonObject["message"], LogManager.LogMessageType.DEBUG);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "setSell", ex.Message, LogManager.LogMessageType.EXCEPTION);
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>mytrades
        /// <para>Retrieve detailed trading history.</para>
        /// <para>Required : marketid - name (ex: SYM-MKT)</para>
        /// <para>Optional : limit</para>
        /// </summary>
        public static List <CCEXTrade> getTradeList(string symbol, string market)
        {
            List <CCEXTrade> list = new List <CCEXTrade>();

            try
            {
                string requestUrl = Api_privateUrl + "mytrades" +
                                    "&apikey=" + Api.key +
                                    "&marketid=" + symbol.ToLower() + "-" + market.ToLower() +
                                    "&nonce=" + ExchangeManager.GetNonce();

                var    jsonObject = JObject.Parse(GetApiRequest(requestUrl));
                string success    = jsonObject["success"].ToString().ToLower();

                if (success == "true")
                {
                    list = jsonObject["result"].ToObject <List <CCEXTrade> >();
                }
                else
                {
                    LogManager.AddLogMessage(Name, "getTradeList", "sucess IS FALSE : message=" + jsonObject["message"], LogManager.LogMessageType.DEBUG);
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "getTradeList", ex.Message, LogManager.LogMessageType.EXCEPTION);
            }
            return(list);
        }
Esempio n. 5
0
        /// <summary>getorder
        /// <para>Retrieve a single order by uuid.</para>
        /// <para>Required : uuid - uuid of the buy or sell order</para>
        /// <para>Optional : none</para>
        /// </summary>
        public static CCEXOrder getOrder(string uuid)
        {
            try
            {
                string requestUrl = Api_privateUrl + "getorder" +
                                    "&apikey=" + Api.key +
                                    "&uuid=" + uuid +
                                    "&nonce=" + ExchangeManager.GetNonce();

                var    jsonObject = JObject.Parse(GetApiRequest(requestUrl));
                string success    = jsonObject["success"].ToString().ToLower();

                if (success == "true")
                {
                    return(jsonObject["result"].ToObject <CCEXOrder>());
                }
                else
                {
                    LogManager.AddLogMessage(Name, "getOrder", "successs IS FALSE : message=" + jsonObject["message"], LogManager.LogMessageType.DEBUG);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "getOrder", ex.Message, LogManager.LogMessageType.EXCEPTION);
                return(null);
            }
        }
Esempio n. 6
0
        /// <summary>getopenorders
        /// <para>Get all orders that you currently have opened. A specific market can be requested.</para>
        /// <para>Required : none</para>
        /// <para>Optional : market - Market name (ex: MKT-SYM)</para>
        /// </summary>
        public static List <CCEXOrder> getOpenOrdersList(string market = "", string symbol = "")
        {
            List <CCEXOrder> list = new List <CCEXOrder>();

            try
            {
                string requestUrl = Api_privateUrl + "getopenorders" +
                                    "&apikey=" + Api.key +
                                    "&nonce=" + ExchangeManager.GetNonce();

                if (market.Length > 0 && symbol.Length > 0)
                {
                    requestUrl += "&market=" + market + "-" + symbol;
                }
                string result = GetApiRequest(requestUrl);
                //LogManager.AddLogMessage(Name, "getOpenOrdersList", result, LogManager.LogMessageType.DEBUG);
                var    jsonObject = JObject.Parse(result);
                string success    = jsonObject["success"].ToString().ToLower();

                if (success == "true")
                {
                    list = jsonObject["result"].ToObject <List <CCEXOrder> >();
                }
                else
                {
                    LogManager.AddLogMessage(Name, "getOpenOrdersList", "successs IS FALSE : message=" + jsonObject["message"], LogManager.LogMessageType.DEBUG);
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "getOpenOrdersList", ex.Message, LogManager.LogMessageType.EXCEPTION);
            }
            return(list);
        }
Esempio n. 7
0
        /// <summary>getbalances
        /// <para>Retrieve all balances from your account.</para>
        /// <para>Required : none</para>
        /// <para>Optional : none</para>
        /// </summary>
        public static List <CCEXBalance> getBalanceList()
        {
            List <CCEXBalance> list           = new List <CCEXBalance>();
            string             responseString = string.Empty;

            try
            {
                string requestUrl = Api_privateUrl + "getbalances" +
                                    "&apikey=" + Api.key +
                                    "&nonce=" + ExchangeManager.GetNonce();
                responseString = GetApiRequest(requestUrl);
                var    jsonObject = JObject.Parse(responseString);
                string success    = jsonObject["success"].ToString().ToLower();

                if (success == "true")
                {
                    list = jsonObject["result"].ToObject <List <CCEXBalance> >();
                    UpdateStatus(true, "Updated Balances");
                }
                else
                {
                    LogManager.AddLogMessage(Name, "getBalanceList", "sucess IS FALSE : message=" + jsonObject["message"], LogManager.LogMessageType.DEBUG);
                    UpdateStatus(true, jsonObject["message"].ToString());
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "getBalances", ex.Message, LogManager.LogMessageType.EXCEPTION);
                UpdateStatus(false, responseString);
            }
            return(list);
        }
Esempio n. 8
0
        // ------------------------
        /// <summary>/accounts/<account-id>
        /// <para>Information for a single account. Use this endpoint when you know the account_id.</para>
        /// <para>Required : account-id</para>
        /// <para>Optional : none</para>
        /// </summary>
        public async static Task <GDAXAccount> getAccount(string account_id)
        {
            try
            {
                string ts     = ExchangeManager.GetNonce();
                string method = "/accounts/" + account_id;
                string sig    = GetSignature(ts, "GET", method, string.Empty);
                using (var acclient = new HttpClient())
                {
                    acclient.BaseAddress = new Uri("https://api.gdax.com");
                    acclient.DefaultRequestHeaders.Accept.Clear();
                    acclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    acclient.DefaultRequestHeaders.Add("CB-ACCESS-KEY", Api.key);
                    acclient.DefaultRequestHeaders.Add("CB-ACCESS-SIGN", sig);
                    acclient.DefaultRequestHeaders.Add("CB-ACCESS-TIMESTAMP", ts);
                    acclient.DefaultRequestHeaders.Add("CB-ACCESS-PASSPHRASE", Api.passphrase);
                    acclient.DefaultRequestHeaders.Add("User-Agent", "Win32");
                    HttpResponseMessage response = acclient.GetAsync(method).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        String result = await response.Content.ReadAsStringAsync();

                        var jsonObject = JObject.Parse(result);
                        return(jsonObject.ToObject <GDAXAccount>());
                    }
                    else
                    {
                        LogManager.AddLogMessage(Name, "getAccountList", "response.IsSuccess is FALSE : NO DATA : response.Content=" + response.Content, LogManager.LogMessageType.DEBUG);
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "getAccountList", ex.Message, LogManager.LogMessageType.EXCEPTION);
                return(null);
            }
        }
Esempio n. 9
0
        public static async Task <List <TradeSatoshiBalance> > GetTSBalances()
        {
            List <TradeSatoshiBalance> list = new List <TradeSatoshiBalance>();

            using (HttpClient client = new HttpClient())
            {
                try
                {
                    string uri = "https://tradesatoshi.com/api/private/getbalances";
                    //string nonce = Guid.NewGuid().ToString();
                    string nonce                = ExchangeManager.GetNonce();
                    string signature            = GetSignature(uri, nonce).Result;
                    string authenticationString = "Basic " + Api.key + ":" + signature + ":" + nonce;
                    client.DefaultRequestHeaders.Add("Authentication", authenticationString);
                    string result = await client.PostAsync(uri, null).Result.Content.ReadAsStringAsync();

                    LogManager.AddLogMessage(Name, "GetBalances", "result=" + result, LogManager.LogMessageType.OTHER);
                    //return JsonConvert.DeserializeObject<GetBalancesReturn>(result);
                    //return JsonConvert.DeserializeObject<GetBalancesReturn>(result);
                }
                catch (Exception e) { throw e; };
            }
            return(list);
        }
Esempio n. 10
0
        // GetBalance
        public static async Task <List <TradeSatoshiBalance> > getBalanceList()
        {
            List <TradeSatoshiBalance> list = new List <TradeSatoshiBalance>();

            using (HttpClient client = new HttpClient())
            {
                try
                {
                    string uri = "https://tradesatoshi.com/api/private/getbalances";
                    //string nonce = Guid.NewGuid().ToString();
                    string nonce = ExchangeManager.GetNonce();
                    LogManager.AddLogMessage(Name, "1:getBalanceList", uri + " | " + nonce, LogManager.LogMessageType.DEBUG);

                    /*
                     * if (Api != null)
                     * {
                     *  LogManager.AddLogMessage(Name, "API", "Api=" + Api.key + " | " + Api.secret, LogManager.LogMessageType.OTHER);
                     * }
                     * else
                     * {
                     *  LogManager.AddLogMessage(Name, "API", "IS NULL", LogManager.LogMessageType.DEBUG);
                     * }
                     */


                    /*
                     * string signature = GetSignatureString(uri, nonce);
                     * LogManager.AddLogMessage(Name, "2:getBalanceList", signature, LogManager.LogMessageType.DEBUG);
                     *
                     *
                     *
                     * string authenticationString = "Basic " + Api.key + ":" + signature + ":" + nonce;
                     * LogManager.AddLogMessage(Name, "getBalanceList", authenticationString, LogManager.LogMessageType.DEBUG);
                     * client.DefaultRequestHeaders.Add("Authentication", authenticationString);
                     */



                    string result = await client.PostAsync(uri, null).Result.Content.ReadAsStringAsync();

                    LogManager.AddLogMessage(Name, "getBalanceList", result, LogManager.LogMessageType.DEBUG);
                    //return JsonConvert.DeserializeObject<GetBalancesReturn>(result);
                }
                catch (Exception ex)
                {
                    LogManager.AddLogMessage(Name, "EX:getBalanceList", ex.Message, LogManager.LogMessageType.EXCEPTION);
                    //UpdateStatus(false, responseString);
                    //throw e;
                };
            }

            /*
             * string responseString = string.Empty;
             * try
             * {
             *
             *
             *
             *  string requestUrl = "https://tradesatoshi.com/api/private/getbalances?apikey=" + Api.key + "&nonce=" + ExchangeManager.GetNonce();
             *  var url = new Uri(requestUrl);
             *  var webreq = WebRequest.Create(url);
             *  var signature = getHMAC(Api.secret, requestUrl);
             *  webreq.Headers.Add("apisign", signature);
             *  var webresp = webreq.GetResponse();
             *  var stream = webresp.GetResponseStream();
             *  var strRead = new StreamReader(stream);
             *  //String result = strRead.ReadToEnd();
             *  responseString = strRead.ReadToEnd();
             *  LogManager.AddLogMessage(Name, "getBalanceList", "result=" + responseString);
             *
             *  var jsonObject = JObject.Parse(responseString);
             *  string success = jsonObject["success"].ToString().ToLower();
             *
             *  if (success == "true")
             *  {
             *      list = jsonObject["result"].ToObject<List<BittrexBalance>>();
             *      UpdateStatus(true, "Updated Balances");
             *  }
             *
             *  else
             *  {
             *      LogManager.AddLogMessage(Name, "getBalanceList", "success FALSE : " + jsonObject["message"], LogManager.LogMessageType.EXCHANGE);
             *      UpdateStatus(true, jsonObject["message"].ToString());
             *  }
             *
             * }
             * catch (Exception ex)
             * {
             *  LogManager.AddLogMessage(Name, "getBalanceList", ex.Message, LogManager.LogMessageType.EXCEPTION);
             *  UpdateStatus(false, responseString);
             * }
             */
            return(list);
        }