Loading [MathJax]/jax/input/TeX/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >我找不到期货订单的历史数据

我找不到期货订单的历史数据
EN

Stack Overflow用户
提问于 2022-04-29 22:11:01
回答 1查看 1.4K关注 0票数 0

我试图使用API获取二进制期货订单历史数据。因此,我从二进制查询数据,得到了回答:“您的历史期货订单数据申请已获批准,请按照我们的Github指导使用您的白色帐户API密钥访问”,我已经设置了API如下。

我对Enable符号白名单做了如下修改:

下一步,我遵循了Github指南:https://github.com/binance/binance-public-data/tree/master/Futures_Order_Book_Download

它具有以下示例代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
"""
This example python script shows how to download the Historical Future Order Book level 2 Data via API.
The data download API is part of the Binance API (https://binance-docs.github.io/apidocs/spot/en/#general-api-information).
For how to use it, you may find info there with more examples, especially SIGNED Endpoint security as in https://binance-docs.github.io/apidocs/spot/en/#signed-trade-user_data-and-margin-endpoint-security
Before executing this file, please note:
    - The API account needs to have a Futures account to access Futures data.
    - The API key has been whitelisted to access the data.
    - Read the comments section in this file to know where you should specify your request values.
"""

# Install the following required packages
import requests
import time
import hashlib
import hmac
from urllib.parse import urlencode

S_URL_V1 = "https://api.binance.com/sapi/v1"

# Specify the api_key and secret_key with your API Key and secret_key
api_key = "your_api_key"
secret_key = "your_secret_key "

# Specify the four input parameters below:
symbol = "ADAUSDT"  # specify the symbol name
startTime = 1635561504914  # specify the starttime
endTime = 1635561604914  # specify the endtime
dataType = "T_DEPTH"  # specify the dataType to be downloaded


# Function to generate the signature
def _sign(params={}):
    data = params.copy()
    ts = str(int(1000 * time.time()))
    data.update({"timestamp": ts})
    h = urlencode(data)
    h = h.replace("%40", "@")

    b = bytearray()
    b.extend(secret_key.encode())

    signature = hmac.new(b, msg=h.encode("utf-8"), digestmod=hashlib.sha256).hexdigest()
    sig = {"signature": signature}

    return data, sig


# Function to generate the download ID
def post(path, params={}):
    sign = _sign(params)
    query = urlencode(sign[0]) + "&" + urlencode(sign[1])
    url = "%s?%s" % (path, query)
    header = {"X-MBX-APIKEY": api_key}
    resultPostFunction = requests.post(url, headers=header, timeout=30, verify=True)
    return resultPostFunction


# Function to generate the download link
def get(path, params):
    sign = _sign(params)
    query = urlencode(sign[0]) + "&" + urlencode(sign[1])
    url = "%s?%s" % (path, query)
    header = {"X-MBX-APIKEY": api_key}
    resultGetFunction = requests.get(url, headers=header, timeout=30, verify=True)
    return resultGetFunction


"""
Beginning of the execution.
The final output will be:
- A link to download the specific data you requested with the specific parameters.
Sample output will be like the following: {'expirationTime': 1635825806, 'link': 'https://bin-prod-user-rebate-bucket.s3.amazonaws.com/future-data-download/XXX'
Copy the link to the browser and download the data. The link would expire after the expirationTime (usually 24 hours).
- A message reminding you to re-run the code and download the data hours later.
Sample output will be like the following: {'link': 'Link is preparing; please request later. Notice: when date range is very large (across months), we may need hours to generate.'}
"""

timestamp = str(
    int(1000 * time.time())
)  # current timestamp which serves as an input for the params variable
paramsToObtainDownloadID = {
    "symbol": symbol,
    "startTime": startTime,
    "endTime": endTime,
    "dataType": dataType,
    "timestamp": timestamp,
}

# Calls the "post" function to obtain the download ID for the specified symbol, dataType and time range combination
path = "%s/futuresHistDataId" % S_URL_V1
resultDownloadID = post(path, paramsToObtainDownloadID)
print(resultDownloadID)
downloadID = resultDownloadID.json()["id"]
print(downloadID)  # prints the download ID, example: {'id': 324225}


# Calls the "get" function to obtain the download link for the specified symbol, dataType and time range combination
paramsToObtainDownloadLink = {"downloadId": downloadID, "timestamp": timestamp}
pathToObtainDownloadLink = "%s/downloadLink" % S_URL_V1
resultToBeDownloaded = get(pathToObtainDownloadLink, paramsToObtainDownloadLink)
print(resultToBeDownloaded)
print(resultToBeDownloaded.json())

我已经修改了api_keysecret_key到我自己的密钥,这是我得到的结果。

你能告诉我我在哪里犯的错误吗?提前谢谢你的回答。

EN

回答 1

Stack Overflow用户

发布于 2022-08-19 03:59:09

看看https://www.binance.com/en-NG/landing/data

期货订单数据只能在宾斯期货上获得。它要求期货帐户首先是白名单,并只能通过API下载。Orderbook快照(S_Depth):自2020年1月起,仅在BTC/USDT符号上。勾选级订单簿(T_Depth):自2020年1月起,在所有符号上

页面上写着你应该申请Binance表格,以便在期货部分中白名单:https://docs.google.com/forms/d/e/1FAIpQLSexCgyvZEMI1pw1Xj6gwKtfQTYUbH5HrUQ0gwgPZtM9FaM2Hw/viewform

第二,你对期货感兴趣,而不是对现货感兴趣,所以网址应该是api.binance.com/fapi,而不是api.binance.com/sapi

订单的第三件事- API端点是GET /fapi/v1/depth

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72066143

复制
相关文章
指针和引用的区别是什么
注意,C++ 标准并没有明确要求编译器该如何实现引用,但是基本上所有编译器在底层处理上都会把引用当作指针来处理。比如下面是一个引用,
ClearSeve
2022/02/10
3860
ElementRef & TemplateRef & ViewContainerRef
今天在做ng项目,看着前人的代码有 viewChild() 等关键字。新手有点疑惑,索性查查资料总结一下和ng相关的几个和DOM相关的几个概念
用户2436820
2018/09/05
1.2K0
微服务架构下的服务发布和引用方案
服务提供者如何发布一个服务? 服务消费者如何引用这个服务? 具体来说,就是这个服务的接口名是什么? 调用这个服务需要传递哪些参数? 接口的返回值是什么类型?
JavaEdge
2021/02/23
4820
微服务架构下的服务发布和引用方案
js如何引用同级元素
https://coder.itclan.cn/fontend/js/17-yinyong-tongji-elem/
itclanCoder
2023/02/26
7.9K0
js如何引用同级元素
DOM节点和元素之间的区别是什么?
文档对象模型(DOM)是将 HTML 或 XML 文档视为树结构的接口,其中每个节点(node)都是文档的对象。DOM 还提供了一组用于查询树、修改结构和样式的方法。
疯狂的技术宅
2021/01/28
2.4K0
Angular 动态创建组件
上面代码中,我们定义了一个简单的 AlertComponent 组件,该组件有一个输入属性 type ,用于让用户自定义提示的类型,此外还包含了一个输出属性 output,用于向外部组件输出信息。我们的自定义组件最终是一个实际的 DOM 元素,因此如果我们需要在页面中插入该元素,我们就需要考虑在哪里放置该元素。
阿宝哥
2019/11/05
3.7K0
软引用和弱引用的区别_强引用软引用弱引用虚引用的区别
第一次GC的时候,软引用没有被回收,是因为这时候内存资源充足。第二次由于分配了较大的内存,导致GC,这时候由于内存资源紧张,软引用被回收了,也就是虽然User对象有一个软引用在引用着它,但User对象在此条件下也会被GC回收。所以软引用的对象在一定条件下可被回收,故软引用对象不会导致内存溢出。
全栈程序员站长
2022/10/04
1.2K0
Dubbo——服务引用
上一篇我们分析了服务发布的原理,可以看到默认是创建了一个Netty server,并通过Invoker调用服务,同样,在客户端也会创建一个Inovker对象,下面就一起来看看这个引用创建过程。
夜勿语
2020/09/07
4350
python序列元素引用容易出错的地方
  python序列分列表和元组,不同之处在于元组的元素不能修改。元组使用小括号,列表使用方括号。元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可。举个简单的例子,a1是一个元组,a2是一个列表
ytkah
2022/03/14
4340
2. 源码分析---SOFARPC客户端服务引用
这里返回的consumerBootstrap和用的启动器和协议有关,如果用的是bolt那么返回的就是BoltConsumerBootstrap实例。
luozhiyun
2019/09/10
5270
Angular DOM 抽象概述
为了能够支持跨平台,Angular 通过抽象层封装了不同平台的差异,统一了 API 接口。如定义了抽象类 Renderer2 、抽象类 RootRenderer 等。此外还定义了以下引用类型:ElementRef、TemplateRef、ViewRef 、ComponentRef 和 ViewContainerRef 等。
阿宝哥
2019/11/05
3.6K0
Dubbo的服务引用过程
上篇文章我们已经了解了 Dubbo 服务暴露全过程,这篇文章我就带着大家再来看看 Dubbo 服务引入全流程,这篇服务引入写完下一篇就要来个全链路打通了,看看大家看完会不会有种任督二脉都被打通的感觉。
用户1263954
2022/04/07
2130
Dubbo的服务引用过程
Angular2 之 结构型指令几个概念
两种用法。(* 与 template) 控制宿主元素的模板。 在哪里去显示,viewcontain 怎么注入,属性的set语法的使用,是便捷的监听属性值变化的途径。
贺贺V5
2018/08/21
3K0
Angular2 之 结构型指令几个概念
HTML的行元素和块元素
本博客所有文章如无特别注明均为原创。作者:十月梦想 ,复制或转载请以超链接形式注明转自 十月梦想博客 。 原文地址《HTML的行元素和块元素》
十月梦想
2018/08/29
3.3K0
07-2 引用
二、引用(控制扩展) 现在我们已经知道,shell 有多种方式可以进行扩展,现在我们来学习如何控制扩展。 echo this is a test echo The tota is $100.0
见贤思齊
2020/08/05
7070
【DUBBO】 服务引用RegistryDirectory
实现了FactoryBean接口,所以在获取实例的时候,实际上是调用getObject方法返回实例。这里面的get方法继承自ReferenceConfig类
spilledyear
2018/12/24
8350
PHP的引用计数是什么意思?
在PHP的数据结构中,引用计数就是指每一个变量,除了保存了它们的类型和值之外,还额外保存了两个内容,一个是当前这个变量是否被引用,另一个是引用的次数。为什么要多保存这样两个内容呢?当然是为了垃圾回收(GC)。也就是说,当引用次数为0的时候,这个变量就没有再被使用了,就可以通过 GC 来进行回收,释放占用的内存资源。任何程序都不能无限制的一直占用着内存资源,过大的内存占用往往会带来一个严重的问题,那就是内存泄露,而 GC 就是PHP底层自动帮我们完成了内存的销毁,而不用像 C 一样必须去手动地 free 。
硬核项目经理
2020/07/14
2.2K0
OpenCV中检测ChArUco的角点(2)
ArUCo标记板是非常有用的,因为他们的快速检测和多功能性。然而,ArUco标记的一个问题是,即使在应用亚像素细化后,其角点位置的精度也不太高。相反,棋盘图案的角点可以更精确地细化,因为每个角点被两个黑色正方形包围。然而,寻找棋盘图案并不像寻找aruco棋盘那样通用:它必须是完全可见的,并且不允许遮挡。
点云PCL博主
2022/02/10
2.9K0
OpenCV中检测ChArUco的角点(2)
nodejs的引用和导出
正如我们想的那样,nodejs每次只能运行一个js脚本,所以如果想运行多个js脚本可以采用引用(require)的方式
是小张啊喂
2021/08/10
7320
【说站】javascript引用类型是什么
1、引用类型有Object:Array、Function、Date、RegExp等。
很酷的站长
2022/11/23
4520

相似问题

TemplateRef和ViewContainerRef是什么?

13

用ViewContainerRef实现角2误差

11

角viewContainerRef of ViewRef

115

角2理解ViewContainerRef与TemplateRef的用法

11

角指令ViewContainerRef测试模

20
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文