Exemple #1
0
        public static HttpResponseMessage VenderMercado(string apiKey, string apiSecret, string symbol, decimal quantidade, string OrdemId)
        {
            var url           = "https://api.binance.com/api/v3/order?";
            var timestamp     = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            var querystring   = "symbol=" + symbol.ToUpper() + "&side=SELL&type=MARKET&quantity=" + quantidade.ToString() + "&recvWindow=60000&timestamp=" + timestamp + "&newClientOrderId=" + OrdemId;
            var hmacsignature = BinanceHelper.getSignature(querystring, apiSecret);

            using (HttpClient _HttpClient = new HttpClient())
            {
                _HttpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", apiKey);
                var resultado = _HttpClient.PostAsync(url + querystring + "&signature=" + hmacsignature, null).Result;
                return(resultado);
            }
        }
Exemple #2
0
        public static HttpResponseMessage CancelarOco(string apiKey, string apiSecret, string symbol, string orderListId)
        {
            var url           = "https://api.binance.com/api/v3/orderList?";
            var timestamp     = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            var querystring   = "symbol=" + symbol.ToUpper() + "&recvWindow=60000&timestamp=" + timestamp + "&listClientOrderId=" + orderListId;
            var hmacsignature = BinanceHelper.getSignature(querystring, apiSecret);

            using (HttpClient _HttpClient = new HttpClient())
            {
                _HttpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", apiKey);
                var resultado = _HttpClient.DeleteAsync(url + querystring + "&signature=" + hmacsignature).Result;
                return(resultado);
            }
        }
Exemple #3
0
        public static HttpResponseMessage SendOrdemEntrada(string apiKey, string apiSecret, string OrderType, string symbol, decimal quantidade, decimal Priece, decimal LimitPriece, string OrdemId)
        {
            var url           = "https://api.binance.com/api/v3/order?";
            var timestamp     = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            var querystring   = "symbol=" + symbol.ToUpper() + "&side=BUY&type=" + OrderType + "&quantity=" + quantidade.ToString() + "&recvWindow=60000&timestamp=" + timestamp + "&newClientOrderId=" + OrdemId + "&newOrderRespType=RESULT&timeInForce=FOK&price=" + LimitPriece.ToString() + "&stopPrice=" + Priece.ToString();
            var hmacsignature = BinanceHelper.getSignature(querystring, apiSecret);

            using (HttpClient _HttpClient = new HttpClient())
            {
                _HttpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", apiKey);
                var resultado = _HttpClient.PostAsync(url + querystring + "&signature=" + hmacsignature, null).Result;
                return(resultado);
            }
        }
Exemple #4
0
        public static HttpResponseMessage GetAccountInformation(string apiKey, string apiSecret)
        {
            var url           = "https://api.binance.com/api/v3/account?";
            var timestamp     = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            var querystring   = "timestamp=" + timestamp;
            var hmacsignature = BinanceHelper.getSignature(querystring, apiSecret);

            using (HttpClient _HttpClient = new HttpClient())
            {
                _HttpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", apiKey);
                var resultado = _HttpClient.GetAsync(url + querystring + "&signature=" + hmacsignature).Result;
                return(resultado);
            }
        }
Exemple #5
0
        public static HttpResponseMessage SendSaidaOco(string apiKey, string apiSecret, string symbol, decimal quantidade, decimal Gain, decimal Loss, decimal LimitLoss, string LimitOrdemId, string StopOrderID)
        {
            var url           = "https://api.binance.com/api/v3/order/oco?";
            var timestamp     = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            var querystring   = "symbol=" + symbol.ToUpper() + "&side=SELL&quantity=" + quantidade.ToString() + "&stopClientOrderId=" + StopOrderID + "&limitClientOrderId=" + LimitOrdemId + "&recvWindow=60000&timestamp=" + timestamp + "&stopLimitTimeInForce=GTC&price=" + Gain.ToString() + "&stopPrice=" + Loss.ToString() + "&stopLimitPrice=" + LimitLoss.ToString();
            var hmacsignature = BinanceHelper.getSignature(querystring, apiSecret);

            using (HttpClient _HttpClient = new HttpClient())
            {
                _HttpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", apiKey);
                var resultado = _HttpClient.PostAsync(url + querystring + "&signature=" + hmacsignature, null).Result;
                return(resultado);
            }
        }
Exemple #6
0
        public static HttpResponseMessage GetListenKey(string apiKey, string apiSecret)
        {
            var url       = "https://api.binance.com/api/v3/userDataStream";
            var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            //var timestamp = GetServerTime();
            var param         = "recvWindow=60000&timestamp=" + timestamp;
            var hmacsignature = BinanceHelper.getSignature(param, apiSecret);

            using (HttpClient _HttpClient = new HttpClient())
            {
                _HttpClient.DefaultRequestHeaders.Add("X-MBX-APIKEY", apiKey);
                var resultado = _HttpClient.PostAsync(url, null).Result;
                return(resultado);
            }
        }