Binance Library
- ライブラリ
- Hadil Mutaqin SE
- バージョン: 1.80
- アップデート済み: 2 2月 2022
- アクティベーション: 5
The library is used to develop automatic trading on Binance Spot Market from MT5 platform.
- Support all order types: Limit, Market, Stop-Limit and Stop-Market.
- Support margin trading.
- Automatically display the chart on the screen.
Usage:
- Open MQL5 demo account
- Move BinanceLib.ex5 from folder \MQL5\Scripts\Market to MQL5\Libraries
- Download Header file and EA sample https://www.mql5.com/en/code/download/34972_260999.zip
- Copy Binance.mqh header file to folder \MQL5\Include
- Copy BinanceEA-Sample.mq5 to folder \MQL5\Experts
- Attach BinanceEA-Sample to the chart
Example how to call Binance Library from EA
#include <Binance.mqh> string Symbol = "BTCUSDT"; // Symbol name string HistoryData = "1W"; // History data: 1W = 1 week, 1M = 1 month, 3M = 3 months, 6M = 6 months, 1Y = 1 year, MAX = maximum available data string ApiKey = ""; // Binance api key string SecretKey = ""; // Binance secret key Binance binance; int OnInit() { binance.init(Symbol,HistoryData,ApiKey,SecretKey); binance.showChart(); /* double balanceBTC = binance.balance("BTC"); //--Check BTC balance--// double balanceUSDT = binance.balance("USDT"); //--Check USDT balance--// //--Place buy market order BTCUSDT quantity 0.001 BTC at market price--// binance.orderBuyMarket("BTCUSDT" // symbol name ,0.001); // order quantity //--Place buy limit order BTCUSDT quantity 0.001 BTC at limit price 15500 USDT--// binance.orderBuyLimit("BTCUSDT" // symbol name ,0.001 // order quantity ,15500 // limit price ,"GTC"); // time in force: GTC, IOC, FOK, default GTC //--Place sell market order BTCUSDT quantity 0.001 BTC at market price--// binance.orderSellMarket("BTCUSDT" // symbol name ,0.001); // order quantity //--Place sell limit order BTCUSDT quantity 0.001 BTC at limit price 25500 USDT--// binance.orderSellLimit("BTCUSDT" // symbol name ,0.001 // order quantity ,25500 // limit price ,"GTC"); // time in force: GTC, IOC, FOK, default GTC //--Get exchange info--// ExchangeInfo info; binance.getExchangeInfo(Symbol(),info); Print("quantityDigit: ",info.quantityDigit); Print("priceDigit: ", info.priceDigit); Print("minNotional: ", info.minNotional); Print("minQty: ", info.minQty); Print("maxQty: ", info.maxQty); Print("stepSize: ", info.stepSize); //--Get orderBook data--// OrderBook orderBook[]; binance.getOrderBook(Symbol(),orderBook); for(int i = 0; i < ArraySize(orderBook); i++) { Print("AskPrice[",i,"] = ",orderBook[i].askPrice); Print("AskQty[",i,"] = ",orderBook[i].askQty); Print("BidPrice[",i,"] = ",orderBook[i].bidPrice); Print("BidQty[",i,"] = ",orderBook[i].bidQty); } //--Get open orders--// OpenOrders openOrders[]; binance.getOpenOrders(Symbol(),openOrders); for(int i = 0; i < ArraySize(openOrders); i++) { long orderId = openOrders[i].orderId; string symbol = openOrders[i].symbol; string side = openOrders[i].side; string type = openOrders[i].type; string status = openOrders[i].status; string timeInForce = openOrders[i].timeInForce; double price = openOrders[i].price; double stopPrice = openOrders[i].stopPrice; double origQty = openOrders[i].origQty; double executedQty = openOrders[i].executedQty; ulong time = openOrders[i].time; } //--Get trade history--// TradeHistory tradeHistory[]; binance.getTradeHistory(Symbol(),tradeHistory); for(int i = ArraySize(tradeHistory)-1; i >= 0; i--) { long orderId = tradeHistory[i].orderId; string symbol = tradeHistory[i].symbol; double price = tradeHistory[i].price; double qty = tradeHistory[i].qty; double quoteQty = tradeHistory[i].quoteQty; double commission = tradeHistory[i].commission; string commissionAsset = tradeHistory[i].commissionAsset; ulong time = tradeHistory[i].time; bool isBuyer = tradeHistory[i].isBuyer; bool isMaker = tradeHistory[i].isMaker; } */ return 0; } void OnTimer() { binance.getTickData(); } void OnDeinit(const int reason) { binance.deinit(); } void OnTick() { }
The best Binance library. I do recommend it to everyone.