Rest API connection to the Binance API

MQL4 Esperti

Lavoro terminato

Tempo di esecuzione 3 minuti
Feedback del dipendente
Great customer with great ideas + well understanding about job and technical specifications like a developer.
Feedback del cliente
Very fast and honest developer!!

Specifiche

I have created skeleton EA, which goal is to open order and check the balance though Binance.com REST API, but it doesnt work. There are two layers of problems. First is described in this forum topic:

https://www.mql5.com/en/forum/253049

Apply to this job only if you know how to solve that. The Webrequest doesn't seem to properly connect to most binance api addresses. The only one that reports anything other than 404 is address for opening orders.

1. The EA needs to successfully connect to the REST API and open a waiting order (amount 1.0 ETH, price 0.001, pair ETHBTC). It needs to display result as Alert() and store it in string variable.

2. The EA must read "account" properly and display it's result as an Alert() and store it in string variable.


Currently the EA reports authorization error 401 result1 = {"code":-2014,"msg":"API-key format invalid."} for ORDER function and 404 not found error for ACCOUNT function. (404 also for any other function than order)

Documentation to Binance REST API:

https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md


Here is my skeleton EA, that needs to be corrected:

#property copyright "Copyright 2017,Grzegorz Korycki"
#property version   "1.00"
#property strict

#include <MQLMySQL.mqh>
#include <SHA256.mqh>

string api_key     = "erased1";
string api_secret  = "erased2";


int private_api_timeout = 2000;
int last_api_call =0;
string result1 = "";
int first_run = 1;

double API_Balance(string symbol_temp) {
   bool failed = false;

   Alert("executing API Balance");
   bool value_returned = false;
   char secret_char[];
   string data2 = "";
   
   int timestamp = (int)TimeGMT();
   string for_encode = "timestamp="+(string)timestamp;
   
   char output_char[];
   string output; 

   SHA256 hash256;
   string hash = hash256.hmac(for_encode,api_secret);

   output = hash;
   
   Alert("output = "+output);
   string uri = "https://api.binance.com/api/v3/account";

   string body = for_encode+"&signature="+output;
   char body_char[];
   StringToCharArray(body, body_char, 0, WHOLE_ARRAY, CP_UTF8);
   ArrayResize(body_char, ArraySize(body_char)-1);

   ResetLastError();
   char result_char[]; string result_headers;
   string headers = "Sign: "+output+"\r\nKey: "+api_key;
   headers = "X-MBX-APIKEY: "+api_key;
   Alert("headers = "+headers);
   int res=WebRequest("POST",uri,"",headers,5000,body_char,ArraySize(body_char),result_char, result_headers);
   Alert("Executing URL:"+uri);
   result1 = CharArrayToString(result_char,0,WHOLE_ARRAY);

   if(res!=200)
   {
      Alert("Authorization error #"+(string)res+", LastError="+(string)GetLastError());
      Alert("result1 = "+ result1);
      failed = true;
      return -1;
   } else {
      Alert("balance loaded !");
      Alert("result1 = "+ result1);
      return 1;
   }
}

bool API_Open_Trade(int trade_direction, string pair_name, double trade_size, double price_temp, ) {
   bool failed = false;

   Alert("executing API Open Trade");
   bool value_returned = false;
   char secret_char[];
   string data2 = "";
   
   int timestamp = (int)TimeGMT();
   string for_encode = "symbol=ETHBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.002&recvWindow=5000&timestamp="+(string)timestamp;
   
   char output_char[];
   string output; 

   SHA256 hash256;
   string hash = hash256.hmac(for_encode,api_secret);

   output = hash;
   
   Alert("output = "+output);
   string uri = "https://api.binance.com/api/v3/order/test";
   string body = for_encode+"&signature="+output;

   char body_char[];
   StringToCharArray(body, body_char, 0, WHOLE_ARRAY, CP_UTF8);
   ArrayResize(body_char, ArraySize(body_char)-1);

   ResetLastError();
   char result_char[]; string result_headers;
   string headers = "Sign: "+output+"\r\nKey: "+api_key;
   headers = "X-MBX-APIKEY: "+api_key;
   Alert("headers = "+headers);
   int res=WebRequest("POST",uri,"",headers,5000,body_char,ArraySize(body_char),result_char, result_headers);
   Alert("Executing URL:"+uri);
   result1 = CharArrayToString(result_char,0,WHOLE_ARRAY);

   if(res!=200)
   {
      Alert("Authorization error #"+(string)res+", LastError="+(string)GetLastError());
      Alert("result1 = "+ result1);
      failed = true;
      return -1;
   } else {
      Alert("balance loaded !");
      Alert("result1 = "+ result1);
      return 1;
   }
}

int OnInit()
  {
   API_Open_Trade(1,"ETHBTC", 1, 0.001);
   API_Balance("ETH");
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {

  }

Please contact me if you are interested. I will provide you with API keys and SHA256 function. https://api.binance.com needs to be added to allowed addresses in MT4.

Again - apply only if you know how to solve the problem mentioned in the Forum topic - you test the issue in your MT4 in less than a minute.

If solution uses external files, they must allow for usage of HTTP proxy.

Con risposta

1
Sviluppatore 1
Valutazioni
(336)
Progetti
620
38%
Arbitraggio
39
23% / 64%
In ritardo
93
15%
Gratuito
2
Sviluppatore 2
Valutazioni
(19)
Progetti
19
11%
Arbitraggio
21
5% / 86%
In ritardo
3
16%
In elaborazione
3
Sviluppatore 3
Valutazioni
(69)
Progetti
93
34%
Arbitraggio
10
40% / 30%
In ritardo
5
5%
Gratuito
Ordini simili
Here is the Idea: I want a Semi Auto Trade Panel Manager EA that only activates when I press the BUY or SELL or BUY LIMIT or SELL LIMIT then the EA will do the rest : that includes the BUY STOP 0r SELL STOP and the hedging calculations according to below diagram. So overall , my only intervention is entering the lot size , hedge zone distance and TP ratio or entering the price for buy limit/sell limit then pressing
Hi, I'm looking for a martingale MT4 EA that performs a lot of trading volume per day. If you have the robot, you'll need to send me the demo so I can backtest it. Thank you very much
Hello potential Freelancers I’m very new to trading so please bear with me as I try to explain what ‘m looking for. I'm currently getting signals ( XAUUSD )sent to me and I’m looking to find a person who can look at the data either watch account live, or I send the trade history. The bot my provider is using makes 100’s of trades a day and does very well on average. I’m also looking to have the following features
Hi guys I would like to k ow if someone has experience with machine learning models? I would like to train a model to identify if there is a range market or trendy market based on several parameters like EMA and ATR for example. If we use for example a 20 and 50 EMA and we measure the distance between both lines the algo should oearn if the trend is strong or weak. If it‘s steong it keeps trending and if it‘s weak
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA
we want to build a dashboard ea that would display on another chart key metrics : i will foward screeshot of what i want to dashboard to look like : the function i would need to get display are the following: 1. classified past performance ea by magic number ( with classic : total trade , total profit , return/dd , max dd (base on history) , ) 2. equity chart of performance if we click on a magic number we should
the task will be actually quiet simple , i need an active develloper to devellope out of 3 updates an ea STEP 1 (this job): make a classical pair trading ea , that can calculate correlation between assets and trade when the correlation diverge above a specified % the develloper that will postulate for the job will need : 1- to be ok to do the full project this job and the update following 2- very low arbitration , i
Hello, I want to create an EA that can be able to take and optimise trade bids using the trend tracker concept I have developed. The tracker will monitor the 2 lines in the below pictures and then start to activate bids once they cross each other and then be able to manage all bids afterwards towards the direction of the market by opening and closing them intermittently and profitably until the position at the other
Hi man, How are u? I have an EA and I need to check few aspects of the code, if It works fine? I am looking for an expert coder, who can understand mt4 language and help us to solve this out. This job will hardly take about 3-4 hours max for an experienced coder, when explained detail. Also, I would like to give this to someone, who can understand and speak English well. Also, the coder should be able to come via
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA. THREE TYPES OF ENTRIES 1: AGGRESSIVE 2: DIVERGENCE 3

Informazioni sul progetto

Budget
30+ USD
IVA (23%): 6.9 USD
Totale: 36.9 USD
Per lo sviluppatore
27 USD
Scadenze
da 1 a 3 giorno(i)