source

ETH/B와 같은 모든 시장 쌍 목록을 검색하는 방법바이낸스 API를 사용하는 TC?

manycodes 2023. 3. 17. 21:44
반응형

ETH/B와 같은 모든 시장 쌍 목록을 검색하는 방법바이낸스 API를 사용하는 TC?

저는 바이낸스 익스체인지의 시장쌍을 선택해야 하는 암호거래 관련 프로젝트를 진행하고 있으며, 쌍 선택에 따라 현재 가격, 24시간 가격변동, 24시간 볼륨, 최근 10번의 거래 이력 등 다양한 결과를 보여줘야 합니다.Binance Rest API Docs(https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md)를 검색했는데 마켓 페어 목록을 검색할 수 있는 엔드포인트를 찾을 수 없습니다.제가 모르는 문서가 있나요?

감사해요.

찾고 있는 것은/exchangeInfo퍼블릭 엔드 포인트

자세한 것은, https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md 를 참조해 주세요.

정보를 교환하다

GET /api/v1/exchangeInfo

현행 거래소 거래 규칙 및 기호 정보

결과로 초래된symbols모든 코인 쌍의 배열:

...
"symbols": [{
"symbol": "ETHBTC",
"status": "TRADING",
"baseAsset": "ETH",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"orderTypes": [
  // These are defined in the `ENUM definitions` section under `Order types (orderTypes)`.
  // All orderTypes are optional.
],
"icebergAllowed": false,
"filters": [
  // There are defined in the `Filters` section.
  // All filters are optional.
]
}]
...

새로운 개발자를 위해 코인 리스트를 덤프하여 여기에 배치하는 것이 더 쉬울 것 같습니다.

["BTC","LTC","ETH","NEO","BNB","QTUM","EOS","SNT","BNT","GAS","BCC","USDT","HSR","OAX","DNT","MCO","ICN","ZRX","OMG","WTC","YOYO","LRC","TRX","SNGLS","STRAT","BQX","FUN","KNC","CDT","XVG","IOTA","SNM","LINK","CVC","TNT","REP","MDA","MTL","SALT","NULS","SUB","STX","MTH","ADX","ETC","ENG","ZEC","AST","GNT","DGD","BAT","DASH","POWR","BTG","REQ","XMR","EVX","VIB","ENJ","VEN","ARK","XRP","MOD","STORJ","KMD","RCN","EDO","DATA","DLT","MANA","PPT","RDN","GXS","AMB","ARN","BCPT","CND","GVT","POE","BTS","FUEL","XZC","QSP","LSK","BCD","TNB","ADA","LEND","XLM","CMT","WAVES","WABI","GTO","ICX","OST","ELF","AION","WINGS","BRD","NEBL","NAV","VIBE","LUN","TRIG","APPC","CHAT","RLC","INS","PIVX","IOST","STEEM","NANO","AE","VIA","BLZ","SYS","RPX","NCASH","POA","ONT","ZIL","STORM","XEM","WAN","WPR","QLC","GRS","CLOAK","LOOM","BCN","TUSD","ZEN","SKY","THETA","IOTX","QKC","AGI","NXS","SC","NPXS","KEY","NAS","MFT","DENT","IQ","ARDR","HOT","VET","DOCK","POLY","VTHO","ONG","PHX","HC","GO","PAX","RVN","DCR","USDC","MITH","BCHABC","BCHSV","REN","BTT","USDS","FET","TFUEL","CELR","MATIC","ATOM","PHB","ONE","FTM","BTCB","USDSB","CHZ","COS","ALGO","ERD","DOGE","BGBP","DUSK","ANKR","WIN","TUSDB","COCOS","PERL","TOMO","BUSD","BAND","BEAM","HBAR","XTZ","NGN","DGB","NKN","GBP","EUR","KAVA","RUB","UAH","ARPA","TRY","CTXC","AERGO","BCH","TROY","BRL","VITE","FTT","AUD","OGN","DREP","BULL","BEAR","ETHBULL","ETHBEAR","XRPBULL","XRPBEAR","EOSBULL","EOSBEAR","TCT","WRX","LTO","ZAR","MBL","COTI","BKRW","BNBBULL","BNBBEAR","HIVE","STPT","SOL","IDRT","CTSI","CHR","BTCUP","BTCDOWN","HNT","JST","FIO","BIDR","STMX","MDT","PNT","COMP","IRIS","MKR","SXP","SNX","DAI","ETHUP","ETHDOWN","ADAUP","ADADOWN","LINKUP","LINKDOWN","DOT","RUNE","BNBUP","BNBDOWN","XTZUP","XTZDOWN","AVA","BAL","YFI","SRM","ANT","CRV","SAND","OCEAN","NMR","LUNA","IDEX","RSR","PAXG","WNXM","TRB","EGLD","BZRX","WBTC","KSM","SUSHI","YFII","DIA","BEL","UMA","EOSUP","TRXUP","EOSDOWN","TRXDOWN","XRPUP","XRPDOWN","DOTUP","DOTDOWN","NBS","WING","SWRV","LTCUP","LTCDOWN","CREAM","UNI","OXT","SUN","AVAX","BURGER","BAKE","FLM","SCRT","XVS","CAKE","SPARTA","UNIUP","UNIDOWN","ALPHA","ORN","UTK","NEAR","VIDT","AAVE","FIL","SXPUP","SXPDOWN","INJ","FILDOWN","FILUP","YFIUP","YFIDOWN","CTK","EASY","AUDIO","BCHUP","BCHDOWN","BOT","AXS","AKRO","HARD","KP3R","RENBTC","SLP","STRAX","UNFI","CVP","BCHA","FOR","FRONT","ROSE","HEGIC","AAVEUP","AAVEDOWN","PROM","BETH","SKL","GLM","SUSD","COVER","GHST","SUSHIUP","SUSHIDOWN","XLMUP","XLMDOWN","DF","JUV","PSG","BVND","GRT","CELO","TWT","REEF","OG","ATM","ASR","1INCH","RIF","BTCST","TRU","DEXE","CKB","FIRO","LIT","PROS","VAI","SFP","FXS","DODO","AUCTION","UFT","ACM","PHA","TVK","BADGER","FIS","OM","POND","ALICE","DEGO","BIFI","LINA"]

위해서python"binance api trade pairs"를 검색한 후 여기에 도달한 사용자:

from binance.client import Client

api_key = "xxx"
api_secret = "xxx"

client = Client(api_key, api_secret)
exchange_info = client.get_exchange_info()
for s in exchange_info['symbols']:
    print(s['symbol'])

ETHBTC
LTCBTC
BNBBTC
NEOBTC
QTUMETH
EOSETH
SNTETH
BNTETH
...

원하는 견적 자산을 사용하여 "견적" 변수를 변경하기만 하면 됩니다.스크립트를 실행하면 모든 기본 자산을 포함하는 "allTargets" 파일이 생성됩니다.

var request = require('request');
var fs = require('fs')
var quote="USDT"
var options = {
  'method': 'GET',
  'url': 'https://api.binance.com/api/v1/exchangeInfo',
  'headers': {
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  //console.log(JSON.parse(response.body));
  var symbols = JSON.parse(response.body).symbols
  var justUSDTpairs = symbols.map((x)=>{
    if(x.quoteAsset.includes(quote)){
      return x.baseAsset
    }
  }).filter((x)=>{if(x){return x}})
  fs.writeFileSync('allTargets',JSON.stringify(justUSDTpairs))
}); 

이 공개 API가 도움이 될 것 같습니다.

https://api3.binance.com/api/v3/ticker/price

위의 Emad에서 제공한 코드를 업데이트하고 싶습니다.

from binance.client import Client
import pandas as pd

api_key = 'Your Api Key'
api_secret = 'Your Secret Key'

client = Client(api_key, api_secret)
symbols = client.get_exchange_info()
df = pd.DataFrame(symbols['symbols'])

li = []

for index, data in df.iterrows():
    if data['isMarginTradingAllowed'] == True:
        li.append(data['symbol'])

fdf = pd.DataFrame(li)
fdf.to_excel('Margin Trading Pairs.xlsx', index=False)

Binance의 공식 바이낸스 커넥터를 사용하는 경우:

from binance.spot import Spot as Client

client = Client()
exchange_info = client.exchange_info()
usdt = set()
for s in exchange_info['symbols']:
    if s['symbol'].endswith('USDT'):
        usdt.add(s['symbol'])
print(usdt)
print(len(usdt))

모든 고유한 Base/USDT 쌍을 포함하는 세트를 제공합니다.

Pedro Lobito의 답변은 python-binance에 대한 것입니다.사용자의 90%는 python-binance에 대한 것입니다.그러나 나머지 사용자는 python-binance와 같이 설치되기 때문에 혼란스러울 수 있습니다.binance이름이 충돌하여 함께 설치할 수 없습니다.

모든 정보를 한 번에 얻을 수DataFrame을 사용하여 python에서pandas python-binance:

from binance.client import Client
import pandas as pd

api_key = ''
api_secret = ''

client = Client(api_key, api_secret)
symbols = client.get_exchange_info()
i = 0
df = pd.DataFrame(columns=symbols[0].keys())
for sym in symbols:
    for key in sym.keys():
        df.at[i, key] = sym[key]
    i = i + 1


df
         symbol  ...     permissions
0        ETHBTC  ...  [SPOT, MARGIN]
1        LTCBTC  ...  [SPOT, MARGIN]
2        BNBBTC  ...  [SPOT, MARGIN]
3        NEOBTC  ...  [SPOT, MARGIN]
4       QTUMETH  ...          [SPOT]
         ...  ...             ...
1710  CHESSBUSD  ...          [SPOT]
1711  CHESSUSDT  ...          [SPOT]
1712     FTMAUD  ...          [SPOT]
1713     FTMBRL  ...          [SPOT]
1714   SCRTBUSD  ...          [SPOT]
[1715 rows x 17 columns]

그런 다음 필요한 경우 Excel에 저장할 수 있습니다.

df.to_excel('binance.xlsx')
from binance.client import Client
import pandas as pd

client = Client('api_key', 'api_secret')

pairs = pd.DataFrame.from_dict(client.get_all_tickers())['symbol'].to_list()

pairs_sorted = pd.DataFrame.from_dict(client.get_all_tickers()).sort_values(by=['symbol'], ascending=True)['symbol'].to_list()
int symbol_toplam = jsonx[6].Size();

//for(int i = jsonx.Size()-1; i>=0; i--){

for (int y=0;y<=symbol_toplam;y++) {

//for(int t = 0;t<=0;t++) {

// symbols 6 

if ( jsonx[6][y][0].ToStr() != "" ) {

if ( jsonx[6][y][0].ToStr() == symbol_coin ) {

Print("Min Lot:",jsonx[6][y][0].ToStr(),"=",jsonx[6][y][21][1][3].ToStr());
min_lot=jsonx[6][y][21][1][3].ToDbl();
import _     from 'lodash'
import fsp   from 'fs/promises'

const get_coins = (symbols) => {
    const coins = []
    symbols.forEach(symbol=>{
        coins.push(symbol.baseAsset)
        coins.push(symbol.quoteAsset)
    })
    return _.uniq(coins)
}

fetch("https://api.binance.com/api/v3/exchangeInfo")
    .then(response=>response.json())
    .then(json=> get_coins(json.symbols))
    .then(coins=>fsp.writeFile('coins.txt',  JSON.stringify(coins)))

@http://gist.github.com/Milimeter/2cea803b4fd87dae5e0741c2018359de의 요지를 작성했습니다.

상위 100개 기호는 아니지만 다음 기호에서 반환된 모든 기호 조합입니다.

GET /api/v1/exchangeInfo

필요한 모든 사람을 위해 암호와 같은 쌍의 목록을 작성했습니다.USDT, EUR, BTC, ETH 여기: 바이낸스 거래목록

언급URL : https://stackoverflow.com/questions/55549499/how-to-retrieve-a-list-of-all-market-pairs-like-eth-btc-using-binance-api

반응형