Getting All Isolated Margin Symbols in PHP:
$api_key = "*****";
$secret = "*****";
$opt = [
"http" => [
"method" => "GET",
"header" => "User-Agent: Mozilla/4.0 (compatible; PHP Binance API)\r\nX-MBX-APIKEY: {$api_key}\r\n"
]
];
$context = stream_context_create($opt);
$params['timestamp'] = number_format(microtime(true)*1000,0,'.','');
$query = http_build_query($params, '', '&');
$signature = hash_hmac('sha256', $query, $secret);
$endpoint = "https://api.binance.com/sapi/v1/margin/isolated/allPairs?{$query}&signature={$signature}";
$res = file_get_contents($endpoint, false, $context);
echo $res;
the response is:
[
{
"symbol": "ADABTC",
"base": "ADA",
"quote": "BTC",
"isMarginTrade": true,
"isBuyAllowed": true,
"isSellAllowed": true
},
{
"symbol": "ADABUSD",
"base": "ADA",
"quote": "BUSD",
"isMarginTrade": true,
"isBuyAllowed": true,
"isSellAllowed": true
},
...
]
Getting real-time trades in JavaScript:
const WebSocket = require('ws');
const ws = new WebSocket("wss://stream.binance.com:9443/stream");
ws.on('open', async () =>
{
const msg =
{
method: "SUBSCRIBE",
params: ["xrpusdt@trade", "ltcusdt@trade"],
id: 1
};
ws.send(JSON.stringify(msg));
});
ws.on('message', async message =>
{
console.log(message);
});
or alternatively
const WebSocket = require('ws');
const ws = new WebSocket("wss://stream.binance.com:9443/stream?streams=btcusdt@trade/ethusdt@trade");
ws.on('message', async message =>
{
console.log(message);
});
the response is:
{"result":null,"id":1}
{"stream":"xrpusdt@trade","data":{"e":"trade","E":1602256866029,"s":"XRPUSDT","t":73837901,"p":"0.25108000","q":"7383.00000000","b":926377010,"a":926377004,"T":1602256866027,"m":false,"M":true}}
...
Exchange information query in a browser: https://api.binance.com/api/v3/exchangeInfo
{
"timezone": "UTC",
"serverTime": 1602329180305,
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200
},
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 100
},
{
"rateLimitType": "ORDERS",
"interval": "DAY",
"intervalNum": 1,
"limit": 200000
}
],
"exchangeFilters": [],
"symbols": [
{
"symbol": "ETHBTC",
"status": "TRADING",
"baseAsset": "ETH",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"quoteAssetPrecision": 8,
"baseCommissionPrecision": 8,
"quoteCommissionPrecision": 8,
"orderTypes": [ "LIMIT", "LIMIT_MAKER", "MARKET", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT" ],
"icebergAllowed": true,
"ocoAllowed": true,
"quoteOrderQtyMarketAllowed": true,
"isSpotTradingAllowed": true,
"isMarginTradingAllowed": true,
"filters": [
{
"filterType": "PRICE_FILTER",
"minPrice": "0.00000100",
"maxPrice": "100000.00000000",
"tickSize": "0.00000100"
},
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "5",
"multiplierDown": "0.2",
"avgPriceMins": 5
},
{
"filterType": "LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
},
{
"filterType": "MIN_NOTIONAL",
"minNotional": "0.00010000",
"applyToMarket": true,
"avgPriceMins": 5
},
{
"filterType": "ICEBERG_PARTS",
"limit": 10
},
{
"filterType": "MARKET_LOT_SIZE",
"minQty": "0.00000000",
"maxQty": "7479.60184990",
"stepSize": "0.00000000"
},
{
"filterType": "MAX_NUM_ORDERS",
"maxNumOrders": 200
},
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"maxNumAlgoOrders": 5
}
],
"permissions": [ "SPOT", "MARGIN" ]
},
...
6/18/2021 I got a strange notification:
