基于ccxt查询币安币本位合约ticker

以前都说是 ticker,但通过币安API并没有找到ticker的API,找到深度信息,那就取深度信息好了。

path : 

GET /dapi/v1/depth

参数:

名称 类型 是否必需 描述
symbol STRING YES 交易对
limit INT NO 默认 500; 可选值:[5, 10, 20, 50, 100, 500, 1000]

代码: 

info = grid.dapiPublicGetDepth({"symbol":'GALAUSD_PERP'}) # 获取深度信息, 成功!
logging.info(info) 

结果:  

2022-05-08 Sunday 18:20:53 - INFO - {'lastUpdateId': '437121537138', 'E': '1652005253738', 'T': '1652005253730', 'symbol': 'GALAUSD_PERP', 'pair': 'GALAUSD', 'bids': [['0.13513', '25'], ['0.13512', '314'], ['0.13511', '23'], ['0.13510', '898'], ['0.13508', '481'], ['0.13507', '243'], ['0.13506', '934'], ['0.13505', '27'], ['0.13504', '282'], ['0.13503', '568'], ['0.13502', '243'], ['0.13501', '590'], ['0.13500', '639'], ['0.13499', '300'], ['0.13498', '880'], ['0.13497', '1000'], ['0.13496', '195'], ['0.13495', '321'], ['0.13494', '274'], ['0.13493', '1001'], ['0.13492', '90'], ['0.13491', '263'], ['0.13488', '641'], ['0.13484', '820'], ['0.13483', '1121'], ['0.13482', '1500'], ['0.13481', '321'], ['0.13480', '30'], ['0.13475', '83'], ['0.13474', '142'], ['0.13470', '70'], ['0.13468', '92'], ['0.13467', '1'], ['0.13466', '319'], ['0.13465', '300'], ['0.13456', '150'], ['0.13451', '5988'], ['0.13450', '368'], ['0.13448', '64'], ['0.13444', '740'], ['0.13435', '39'], ['0.13434', '186'], ['0.13430', '3750'], ['0.13421', '33'], ['0.13420', '301'], ['0.13416', '6'], ['0.13415', '315'], ['0.13413', '80'], ['0.13412', '69'], ['0.13411', '265'], ['0.13408', '70'], ['0.13404', '740'], ['0.13398', '91'], ['0.13396', '80'], ['0.13395', '463'], ['0.13391', '231'], ['0.13389', '300'], ['0.13380', '15'], ['0.13378', '80'], ['0.13376', '2247'], ['0.13356', '1'], ['0.13353', '66'], ['0.13334', '5'], ['0.13333', '123'], ['0.13330', '6'], ['0.13325', '740'], ['0.13323', '1724'], ['0.13302', '1'], ['0.13300', '248'], ['0.13279', '26'], ['0.13269', '1'], ['0.13265', '2'], ['0.13263', '66'], ['0.13255', '758'], ['0.13250', '52'], ['0.13232', '61'], ['0.13220', '124'], ['0.13200', '137'], ['0.13181', '70'], ['0.13175', '1'], ['0.13169', '26'], ['0.13161', '185'], ['0.13150', '73'], ['0.13146', '59'], ['0.13120', '2'], ['0.13112', '503'], ['0.13110', '57'], ['0.13104', '2'], ['0.13100', '443'], ['0.13095', '29'], ['0.13068', '57'], ['0.13050', '10'], ['0.13048', '185'], ['0.13041', '41'], ['0.13040', '26'], ['0.13036', '61'], ['0.13033', '22'], ['0.13031', '7'], ['0.13025', '4'], ['0.13020', '4'], ['0.13013', '28'], ['0.13001', '59'], ['0.13000', '247'], ['0.12999', '3'], ['0.12974', '45'], ['0.12950', '54'], ['0.12938', '46'], ['0.12936', '9'], ['0.12901', '55'], ['0.12900', '1415'], ['0.12898', '5'], ['0.12889', '5'], ['0.12860', '50'], ['0.12857', '25'], ['0.12850', '90'], ['0.12839', '2'], ['0.12830', '127'], ['0.12820', '10'], ['0.12811', '62'], ['0.12800', '50'], ['0.12793', '184'], ['0.12780', '65'], ['0.12777', '1'], ['0.12750', '37'], ['0.12719', '30'], ['0.12700', '5'], ['0.12690', '9'], ['0.12688', '74'], ['0.12677', '187'], ['0.12674', '12'], ['0.12668', '25'], ['0.12666', '2'], ['0.12655', '55'], ['0.12630', '66'], ['0.12600', '89'], ['0.12580', '8'], ['0.12568', '68'], ['0.12550', '24'], ['0.12545', '74'], ['0.12516', '55'], ['0.12500', '93'], ['0.12495', '73'], ['0.12462', '41'], ['0.12460', '24'], ['0.12438', '64'], ['0.12400', '1'], ['0.12333', '2'], ['0.12330', '9500'], ['0.12321', '30'], ['0.12300', '80'], ['0.12280', '28'], ['0.12255', '10'], ['0.12234', '36'], ['0.12222', '7'], ['0.12200', '74'], ['0.12100', '152'], ['0.12084', '1'], ['0.12050', '198'], ['0.12023', '10'], ['0.12020', '15'], ['0.12017', '60'], ['0.12003', '24'], ['0.12000', '1792'], ['0.11999', '2'], ['0.11990', '9'], ['0.11965', '5'], ['0.11940', '5'], ['0.11912', '21'], ['0.11900', '121'], ['0.11888', '1'], ['0.11860', '30'], ['0.11834', '3'], ['0.11800', '1'], ['0.11793', '25'], ['0.11789', '70'], ['0.11777', '1'], ['0.11773', '2'], ['0.11760', '18'], ['0.11700', '3'], ['0.11680', '2'], ['0.11666', '2'], ['0.11650', '1'], ['0.11600', '7'], ['0.11561', '10'], ['0.11560', '42'], ['0.11555', '1'], ['0.11550', '17'], ['0.11500', '209'], ['0.11475', '15'], ['0.11472', '1'], ['0.11444', '1'], ['0.11400', '7'], ['0.11389', '183'], ['0.11333', '1'], ['0.11280', '30'], ['0.11211', '30'], ['0.11200', '19'], ['0.11111', '1'], ['0.11050', '5'], ['0.11000', '110'], ['0.10999', '1'], ['0.10952', '1'], ['0.10950', '102'], ['0.10775', '129'], ['0.10602', '1'], ['0.10510', '9'], ['0.10500', '1'], ['0.10470', '20'], ['0.10378', '747'], ['0.10280', '33'], ['0.10261', '2'], ['0.10200', '24'], ['0.10100', '20'], ['0.10001', '30'], ['0.10000', '265'], ['0.09984', '28939'], ['0.09888', '2'], ['0.09850', '6'], ['0.09824', '15'], ['0.09600', '4'], ['0.09500', '43'], ['0.09400', '3'], ['0.09000', '75'], ['0.08600', '11'], ['0.08500', '5'], ['0.08455', '33'], ['0.08320', '2'], ['0.08000', '530'], ['0.07680', '19'], ['0.07587', '2'], ['0.07505', '23005'], ['0.07500', '134'], ['0.06964', '10'], ['0.06600', '18'], ['0.06000', '6'], ['0.05663', '15'], ['0.05587', '2'], ['0.05000', '1'], ['0.02130', '10'], ['0.01742', '1'], ['0.00774', '1'], ['0.00274', '1'], ['0.00270', '500'], ['0.00130', '500'], ['0.00041', '98'], ['0.00031', '100'], ['0.00021', '100'], ['0.00011', '100'], ['0.00001', '100']], 'asks': [['0.13514', '224'], ['0.13517', '80'], ['0.13518', '25'], ['0.13521', '306'], ['0.13522', '190'], ['0.13523', '43'], ['0.13524', '357'], ['0.13525', '641'], ['0.13526', '227'], ['0.13528', '219'], ['0.13529', '707'], ['0.13530', '14'], ['0.13531', '400'], ['0.13535', '250'], ['0.13536', '241'], ['0.13538', '15'], ['0.13539', '297'], ['0.13540', '1000'], ['0.13542', '496'], ['0.13543', '23'], ['0.13544', '152'], ['0.13545', '585'], ['0.13546', '557'], ['0.13547', '480'], ['0.13548', '825'], ['0.13549', '15'], ['0.13551', '168'], ['0.13552', '508'], ['0.13554', '888'], ['0.13555', '31'], ['0.13556', '195'], ['0.13559', '258'], ['0.13560', '1649'], ['0.13562', '76'], ['0.13563', '15'], ['0.13564', '20'], ['0.13565', '822'], ['0.13566', '15'], ['0.13567', '23'], ['0.13568', '300'], ['0.13570', '15'], ['0.13571', '84'], ['0.13572', '1450'], ['0.13574', '18'], ['0.13577', '277'], ['0.13578', '57'], ['0.13579', '17'], ['0.13580', '1969'], ['0.13584', '79'], ['0.13585', '322'], ['0.13590', '81'], ['0.13591', '81'], ['0.13592', '69'], ['0.13593', '740'], ['0.13598', '80'], ['0.13604', '181'], ['0.13605', '157'], ['0.13608', '26'], ['0.13611', '506'], ['0.13615', '6070'], ['0.13632', '762'], ['0.13640', '158'], ['0.13643', '270'], ['0.13644', '300'], ['0.13645', '73'], ['0.13648', '3699'], ['0.13653', '99'], ['0.13655', '58'], ['0.13662', '67'], ['0.13664', '182'], ['0.13666', '377'], ['0.13668', '162'], ['0.13671', '406'], ['0.13672', '315'], ['0.13673', '2278'], ['0.13675', '64'], ['0.13678', '100'], ['0.13679', '71'], ['0.13680', '16'], ['0.13687', '1'], ['0.13691', '36'], ['0.13693', '11'], ['0.13700', '5'], ['0.13704', '124'], ['0.13710', '740'], ['0.13720', '6'], ['0.13723', '68'], ['0.13724', '40'], ['0.13725', '66'], ['0.13727', '1'], ['0.13745', '6'], ['0.13753', '64'], ['0.13754', '15'], ['0.13755', '68'], ['0.13792', '765'], ['0.13794', '1'], ['0.13800', '27'], ['0.13806', '26'], ['0.13830', '1'], ['0.13832', '6'], ['0.13834', '43'], ['0.13860', '1'], ['0.13861', '53'], ['0.13867', '200'], ['0.13890', '69'], ['0.13891', '189'], ['0.13900', '23'], ['0.13923', '189'], ['0.13939', '35'], ['0.13959', '69'], ['0.13969', '23'], ['0.13974', '54'], ['0.14000', '383'], ['0.14003', '73'], ['0.14044', '63'], ['0.14095', '52'], ['0.14100', '17'], ['0.14108', '189'], ['0.14124', '33'], ['0.14147', '50'], ['0.14173', '39'], ['0.14200', '24'], ['0.14205', '53'], ['0.14229', '66'], ['0.14254', '40'], ['0.14282', '35'], ['0.14300', '604'], ['0.14311', '51'], ['0.14333', '60'], ['0.14358', '7'], ['0.14380', '192'], ['0.14399', '15'], ['0.14400', '4'], ['0.14500', '24'], ['0.14517', '14'], ['0.14600', '31'], ['0.14610', '6'], ['0.14666', '1'], ['0.14741', '50'], ['0.14777', '29'], ['0.14800', '10'], ['0.14816', '1'], ['0.14999', '1'], ['0.15000', '20'], ['0.15111', '1'], ['0.15150', '15'], ['0.15200', '18'], ['0.15433', '18996'], ['0.15440', '4'], ['0.15521', '6'], ['0.15551', '50'], ['0.15555', '2'], ['0.15777', '1'], ['0.15850', '50'], ['0.15999', '80'], ['0.16000', '60'], ['0.16105', '26968'], ['0.16160', '527'], ['0.16200', '4'], ['0.16222', '16'], ['0.16300', '1173'], ['0.16333', '1'], ['0.16400', '100'], ['0.16499', '1'], ['0.16500', '34'], ['0.16569', '80'], ['0.16600', '1'], ['0.16666', '1'], ['0.16700', '21'], ['0.16800', '6'], ['0.16900', '1'], ['0.16999', '1'], ['0.17000', '21'], ['0.17170', '527'], ['0.17206', '13'], ['0.17300', '25'], ['0.17333', '1'], ['0.17380', '20'], ['0.17450', '16'], ['0.17666', '1'], ['0.17999', '2'], ['0.18141', '34699'], ['0.18180', '527'], ['0.18500', '726'], ['0.18539', '2'], ['0.18639', '2'], ['0.19000', '34'], ['0.19100', '40'], ['0.19308', '141'], ['0.19591', '18'], ['0.20300', '290'], ['0.20340', '40'], ['0.20566', '1'], ['0.20600', '5'], ['0.21000', '3'], ['0.21050', '1'], ['0.21200', '1'], ['0.21600', '260'], ['0.21800', '4'], ['0.21963', '125'], ['0.22000', '2298'], ['0.22200', '4'], ['0.22300', '49'], ['0.22600', '1'], ['0.22836', '5'], ['0.23000', '6'], ['0.23250', '2'], ['0.23500', '1'], ['0.23800', '1'], ['0.24000', '4492'], ['0.24011', '1'], ['0.24443', '400'], ['0.24600', '1'], ['0.25000', '109'], ['0.25600', '1'], ['0.26260', '3'], ['0.26700', '1'], ['0.27000', '21'], ['0.28000', '9'], ['0.28197', '6'], ['0.28300', '1'], ['0.28555', '5'], ['0.28777', '5'], ['0.28800', '144'], ['0.28888', '19733'], ['0.29000', '3'], ['0.29090', '5'], ['0.29200', '2'], ['0.29222', '5'], ['0.29400', '1'], ['0.29444', '5'], ['0.29500', '1856'], ['0.29600', '1'], ['0.29800', '7'], ['0.29888', '5'], ['0.29900', '2990'], ['0.30000', '10'], ['0.30200', '1'], ['0.30400', '1'], ['0.30600', '1'], ['0.30800', '1'], ['0.31000', '17'], ['0.31200', '1'], ['0.31400', '1'], ['0.31600', '1'], ['0.31700', '1'], ['0.31800', '1'], ['0.32000', '1'], ['0.32300', '1'], ['0.32500', '1'], ['0.32750', '1'], ['0.32980', '1'], ['0.33000', '21'], ['0.33054', '25'], ['0.33222', '1'], ['0.33300', '16'], ['0.33450', '1'], ['0.33475', '2'], ['0.33500', '467'], ['0.33750', '2'], ['0.33990', '2'], ['0.34250', '2'], ['0.34500', '2'], ['0.34700', '18'], ['0.34750', '2'], ['0.34990', '2'], ['0.35250', '2'], ['0.35300', '1'], ['0.35550', '25'], ['0.35555', '2'], ['0.35794', '1'], ['0.35888', '2'], ['0.35894', '1'], ['0.35994', '1'], ['0.36000', '1'], ['0.36094', '1'], ['0.36100', '1'], ['0.36111', '2'], ['0.36194', '1'], ['0.36200', '1'], ['0.36294', '1'], ['0.36300', '1'], ['0.36333', '2'], ['0.36394', '1'], ['0.36400', '1'], ['0.36490', '5'], ['0.36494', '1'], ['0.36500', '1'], ['0.36555', '2'], ['0.36594', '1'], ['0.36600', '1'], ['0.36694', '1'], ['0.36700', '1'], ['0.36800', '1'], ['0.36888', '2'], ['0.36900', '1'], ['0.37000', '1'], ['0.37100', '1'], ['0.37200', '1'], ['0.37300', '1'], ['0.37400', '1'], ['0.37444', '2'], ['0.37500', '1'], ['0.37600', '1'], ['0.37700', '1'], ['0.37777', '2'], ['0.37800', '2'], ['0.37900', '1'], ['0.38000', '1'], ['0.38100', '1'], ['0.38200', '1'], ['0.38222', '2'], ['0.38300', '1'], ['0.38400', '2'], ['0.38500', '1'], ['0.38555', '2'], ['0.38600', '1'], ['0.38700', '1'], ['0.38800', '1'], ['0.38888', '2'], ['0.38900', '1'], ['0.39000', '1'], ['0.39111', '2'], ['0.39444', '2'], ['0.39500', '3'], ['0.39770', '2'], ['0.39777', '2'], ['0.39800', '9'], ['0.39900', '1'], ['0.39999', '2'], ['0.40000', '4'], ['0.40500', '1'], ['0.40555', '2'], ['0.40850', '2'], ['0.40900', '1'], ['0.41000', '1'], ['0.41222', '2'], ['0.41500', '1'], ['0.41750', '2'], ['0.42000', '1'], ['0.42111', '2'], ['0.42500', '1'], ['0.42777', '2'], ['0.42900', '1'], ['0.43222', '2'], ['0.43500', '1'], ['0.43555', '2'], ['0.43700', '6'], ['0.43888', '2'], ['0.43900', '1'], ['0.44000', '2'], ['0.44111', '2'], ['0.44444', '5'], ['0.44500', '1'], ['0.44888', '2'], ['0.44900', '1'], ['0.45000', '2'], ['0.45222', '2'], ['0.45555', '2'], ['0.45888', '2'], ['0.46222', '2'], ['0.46777', '2'], ['0.46899', '2'], ['0.47222', '2'], ['0.47400', '5'], ['0.47555', '2'], ['0.47850', '2'], ['0.48111', '2'], ['0.48444', '2'], ['0.48880', '2'], ['0.49000', '1'], ['0.49222', '2'], ['0.49444', '2'], ['0.49666', '2'], ['0.49888', '2'], ['0.52000', '1'], ['0.58000', '1'], ['0.61000', '7'], ['0.68000', '1'], ['0.78000', '352'], ['0.80000', '1'], ['1.50000', '62'], ['5.00000', '2226']]}

这样就可以拿到买一价和卖一价。

买一价:0.13513

卖一价:0.13514

logging.info('买一价为:'+info['bids'][0][0])
logging.info('卖一价为:'+info['asks'][0][0])

# 结果:
2022-05-08 Sunday 18:20:53 - INFO - 买一价为:0.13513
2022-05-08 Sunday 18:20:53 - INFO - 卖一价为:0.13514

你可能感兴趣的:(量化交易)