python sdk与www.worldtradingdata.com交互

worldtradingdata的Python项目详细描述


世界贸易数据python sdk

这是一个非正式的sdk。这意味着这份回购协议和作者都没有 与世界贸易数据的关系。此回购协议只是一个简单的工具,旨在使 与rest api集成。

此sdk旨在访问财务数据。因此,作者想强调 您对通过这个sdk获得的任何数据所做的操作是您自己的问题,也是您自己的问题。我接受 对于使用此sdk可能导致的任何损失或问题,绝对不承担任何责任。 我也不对任何数据的准确性负责。
用gnu的话来说(即使这个项目是在mit许可下的),
“本软件绝对不提供保修”

开始

此sdk将要求您拥有一个具有世界贸易数据的帐户(注册 here

安装
  1. 确保已安装PIP3或PIP
  2. 在控制台中pip3 install worldtradingdata==0.1.1

然后在python中…

>>> from WorldTradingData import WorldTradingData
>>> my_api_token = get_my_token_from_somewhere_safe()
# provide the api_token once when creating the WorldTradingData instance.
# you do not need to provide the api_token on each request

>>> wtd = WorldTradingData(my_api_token)
>>> wtd.stock_search('AAPL') # will find all your favourite fruity stocks

一般指南

必需的参数应该单独给出,可选的参数应该是 作为字典提供,参数名为键,参数值为值。

例如 使用
执行基本库存搜索 wtd.stock_search('AAPL')

任何在正式文档中是可选查询字符串param的内容都可以在字典中传递 作为第二个论点 (see official docs for full argument reference)。

optional_params = {'output': 'csv', 'currency': 'usd'}
wtd.stock_search('AAPL', optional_params)

方法是根据官方文档中该请求的url路径后缀命名的。 即,如果请求的基url是 https://api.worldtradingdata.com/api/v1 外汇历史请求的最终url是 https://api.worldtradingdata.com/api/v1/forex_history 然后请求的url路径后缀被认为是/forex_history

sdk中的所有方法都是根据它们对应的url路径后缀命名的,没有/
例如wtd.forex_history(args, in, here)

方法参考

请注意,这个sdk是为官方rest api设计的一个松散包装。 由www.worldtradingdata.com提供。 这意味着它不包括飞行前检查,以确保您提供的参数是正确的。 这提供了更多的灵活性,但这意味着如果提供的格式不正确。 对于sdk,它们将被忽略,并且您得到的结果可能不是您所期望的。

我正在对版本2进行更严格的类型检查。

#注意:“api_token”是自动提供的

实时市场数据

https://www.worldtradingdata.com/documentation#real-time-market-data
股票和指数实时
wtd.stock(symbol: list [, optional_params: dict])
示例
more_params = {'output': 'csv'}
wtd.stock(['AAPL', 'GOOG'], more_params)

实时共同基金
wtd.mutual_fund(symbol: list [, optional_params: dict])
示例
my_symbol_array = ['AAAAX', 'AAADX', 'AAAGX']
wtd.mutual_fund(my_symbol_array)

日内市场数据

https://www.worldtradingdata.com/documentation#intraday-market-data
股票和指数日内
wtd.intraday(symbol: str, interval: int, range: int [, optional_params: dict])

历史市场数据

https://www.worldtradingdata.com/documentation#historical-market-data
完整历史记录
wtd.history(symbol: str [, optional_params: dict])

多个单日历史记录
wtd.history_multi_single_day(symbol: str, date: str [, optional_params: dict])
# date should be formatted as 'YYYY-MM-DD'

外汇

https://www.worldtradingdata.com/documentation#forex-data
实时
wtd.forex(base: str)

历史
wtd.forex_history(base: str, convert_to: str [, optional_params: dict])

单日历史记录
wtd.forex_single_day(base: str, date: str [, optional_params: dict])

搜索股票

https://www.worldtradingdata.com/documentation#searching
wtd._stock_search(search_term: string [, optional_params: dict])

使用
执行基本库存搜索 wtd.stock_search('AAPL')

任何在正式文档中是查询字符串参数的都可以传递 在可选参数字典中。

optional_params = {'output': 'csv', 'currency': 'usd'}
wtd.stock_search('AAPL', optional_params)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何正确测试和调试使用照相机闪光灯的应用程序?   组织。jboss。放松点。spi。未处理的异常:java。lang.NoSuchMethodError:org。冬眠SessionFactory。openSession()Lorg/hibernate/Session;   在同一行上声明多个Java数组?   java Spring批处理管理员,无法替换占位符“批处理”。商业模式。脚本'   使用JQuery的网站上出现java HtmlUnit“不支持浏览器”错误   java JavaFX如何将图形“裁剪”到按钮   java处理mysql中包含逗号的数字   java Hibernate语法错误:应为点   如何根据给定的日期在java中获取30天的回溯日期   java Servlet URL映射   线程“awteventque0”java中的多线程java JFrame异常。util。EmptyStackException,即使堆栈先初始化   JavaSpring控制器/组件实现可序列化   java如何在游戏完成时启动带有按钮的对话框?   java Hibernate双向多对多实现   如何使用Xpath Java修改XML中的属性值,包括注释部分   java Mockito模拟构造函数示例   java如何在不重写的情况下写入文本文件?