Skip to main content

An interface encapsulated based on Tushare, which implements rate limiting and retry mechanisms.

Project description

tushare-interface

将tushare接口封装在类中,并提供限流、重试功能

安装教程

  1. pip install tushare-interface
  2. 在.bashrc中添加环境变量:
  • export TUSHARE_TOKEN='xxxxxxxxxx' 该api从tushare.pro网站购买
  • export TUSHARE_POINTS='120', 设置你的实际积分,将据此设定每分钟可访问接口的次数,需要注意的是,与网站上说明的不同,120积分实际只支持10次查询/分钟

使用说明

  1. from tushare_interface import interfaceTuShare as pro
  2. package内有实例化对象: interfaceTuShare,
  • 如果环境变量已经设置好,import后即可使用
  • 如果环境变量未设置,可通过setToken函数设置从htp://tushare.pro获得的token; 以及
  • 通过setPoints函数设置积分,最低120
  1. interfaceTuShare还可以使用setRetry设置重试次数(最少0次)和重试间隔(以秒为单位,最低1秒)
  2. 如果发现请求后出现流控告警,可以通过setTimesPerMinutus直接设置每分钟发送请求的数量,最低1次/分钟。
  3. 调用query接口从tushare下载数据,接口与tushare原始的query保持一致
  4. 函数原型
  • setToken(self, token: str) -> None
  • setPoints(self, points: int) -> None:
  • setTimesPerMinutus(self, timesPerMinutus: int) -> None
  • setRetry(self, retrys: int, secondsWaitRetry: int) -> None
  • query(self, func_name: str, **kwds: object) -> pandas.DataFrame | None

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tushare_interface-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

tushare_interface-0.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file tushare_interface-0.2.0.tar.gz.

File metadata

  • Download URL: tushare_interface-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.14

File hashes

Hashes for tushare_interface-0.2.0.tar.gz
Algorithm Hash digest
SHA256 642825f9dcd0ddf25f8f61145538f6f1c0866fae68e3cab0dae4a2fb287d8c2e
MD5 b91da32b4c867f44bb1b0298173ffe01
BLAKE2b-256 d417dbff674eb32109356ca06261d329a0d3821f75351baecde05dc88eb1ad50

See more details on using hashes here.

File details

Details for the file tushare_interface-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tushare_interface-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f16a5e2c0af743db74d279887d8f71aa26699a981b391810864827dca5d7f0a2
MD5 7469a8aadb705ab59d2e27fe3303c7a2
BLAKE2b-256 f3ce7c727787a06dd5e7fd483ba416ec3225b1daf33811a85fd4283a846e3780

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page