{"id":19844577,"url":"https://github.com/tigerfintech/openapi-python-sdk","last_synced_at":"2025-04-06T10:12:34.734Z","repository":{"id":33246660,"uuid":"155828756","full_name":"tigerfintech/openapi-python-sdk","owner":"tigerfintech","description":"Python SDK for Tiger Open API","archived":false,"fork":false,"pushed_at":"2025-02-25T08:52:45.000Z","size":1103,"stargazers_count":85,"open_issues_count":3,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T09:06:33.368Z","etag":null,"topics":["openapi","python","quant","tigerbrokers","trade"],"latest_commit_sha":null,"homepage":"https://quant.itiger.com/#openapi","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tigerfintech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-02T07:18:59.000Z","updated_at":"2025-03-26T21:46:07.000Z","dependencies_parsed_at":"2024-12-28T18:15:24.487Z","dependency_job_id":null,"html_url":"https://github.com/tigerfintech/openapi-python-sdk","commit_stats":{"total_commits":395,"total_committers":6,"mean_commits":65.83333333333333,"dds":0.4177215189873418,"last_synced_commit":"eb1cc179faf9a301a054ebe145a44722ab03ea66"},"previous_names":["tigerbrokers/openapi-python-sdk"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigerfintech%2Fopenapi-python-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigerfintech%2Fopenapi-python-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigerfintech%2Fopenapi-python-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigerfintech%2Fopenapi-python-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tigerfintech","download_url":"https://codeload.github.com/tigerfintech/openapi-python-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339155,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openapi","python","quant","tigerbrokers","trade"],"created_at":"2024-11-12T13:04:44.334Z","updated_at":"2025-04-06T10:12:34.699Z","avatar_url":"https://github.com/tigerfintech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TigerOpen - 老虎量化开放平台 (Tiger Quant Open API)\n\n### 简介\n\n老虎开放平台可以为个人开发者和机构客户提供接口服务，投资者可以充分的利用老虎的交易服务、行情服务、账户服务等实现自己的投资应用程序。\n\n- [官方在线文档](https://quant.itiger.com/openapi/zh/python/overview/introduction.html)\n\n-------------------\n\n### 安装\n```\npip install tigeropen\n\n或者\n\ngit clone https://github.com/tigerfintech/openapi-python-sdk.git\npython setup.py install\n\n```\n\n### 使用须知\n\n- 接入前需要在[开放平台](https://quant.itiger.com/#openapi)登记开发者信息\n- 详情查看[接入说明](https://quant.itiger.com/openapi/zh/python/overview/introduction.html)\n\n###### 注: 本SDK当前支持 Python3.4 及以上版本\n\n---\n\n### 快速上手\n- 行情和交易接口\n```\nimport traceback\n\nfrom tigeropen.common.consts import Language, Market, TimelinePeriod, QuoteRight\nfrom tigeropen.common.response import TigerResponse\nfrom tigeropen.quote.quote_client import QuoteClient\nfrom tigeropen.quote.request import OpenApiRequest\nfrom tigeropen.tiger_open_client import TigerOpenClient\nfrom tigeropen.tiger_open_config import TigerOpenClientConfig\nfrom tigeropen.common.util.signature_utils import read_private_key\nfrom tigeropen.common.consts.service_types import ACCOUNTS\nfrom tigeropen.trade.request.model import AccountsParams\nfrom tigeropen.trade.trade_client import TradeClient\n\n\ndef get_client_config():\n    \"\"\"\n    :return:\n    \"\"\"\n    is_sandbox = False\n    client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox)\n    client_config.private_key = read_private_key('your private key file path')\n    client_config.tiger_id = 'your tiger id'\n    client_config.account = 'your account'\n    client_config.language = Language.en_US\n    return client_config\n\ndef get_account_info():\n    client_config = get_client_config()\n    openapi_client = TigerOpenClient(client_config)\n    account = AccountsParams()\n    account.account = 'DU575569'\n    request = OpenApiRequest(method=ACCOUNTS, biz_model=account)\n\n    response_content = None\n    try:\n        response_content = openapi_client.execute(request)\n    except Exception as e:\n        print(traceback.format_exc())\n    if not response_content:\n        print(\"failed to execute\")\n    else:\n        response = TigerResponse()\n        response.parse_response_content(response_content)\n        if response.is_success():\n            print(\"get response data:\" + response.data)\n        else:\n            print(response.code + \",\" + response.msg + \",\" + response.data)\n\ndef get_trade_apis():\n    client_config = get_client_config()\n    trade_client = TradeClient(client_config)\n    trade_client.get_managed_accounts()\n    \ndef get_quote_apis():\n    client_config = get_client_config()\n    quote_client = QuoteClient(client_config)\n    quote_client.get_market_status(Market.US)\n    quote_client.get_briefs(symbols=['AAPL', '00700', '600519'], include_ask_bid=True, right=QuoteRight.BR)\n    quote_client.get_timeline(['AAPL'], period=TimelinePeriod.DAY, include_hour_trading=True)\n    quote_client.get_bars(['AAPL'])\n    \ndef get_option_quote():\n    client_config = get_client_config()\n    quote_client = QuoteClient(client_config)\n    symbol = 'AAPL'\n    expirations = quote_client.get_option_expirations(symbols=[symbol])\n    if len(expirations) \u003e 1:\n        expiry = int(expirations[expirations['symbol'] == symbol].at[0, 'timestamp'])\n        quote_client.get_option_chain(symbol, expiry)\n\n    quote_client.get_option_briefs(['AAPL  190104C00121000'])\n    quote_client.get_option_bars(['AAPL  190104P00134000'])\n    quote_client.get_option_trade_ticks(['AAPL  190104P00134000'])\n\n\ndef get_future_quote():\n    client_config = get_client_config()\n    quote_client = QuoteClient(client_config)\n    exchanges = quote_client.get_future_exchanges()\n    print(exchanges)\n    quote_client.get_future_bars(['CN1901'], begin_time=-1, end_time=1545105097358)\n    quote_client.get_future_trade_ticks(['CN1901'])\n    quote_client.get_future_contracts('CME')\n    quote_client.get_future_trading_times('CN1901', trading_date=1545049282852)\n    quote_client.get_future_brief(['ES1906', 'CN1901'])\n\n```\n\n- 行情和交易信息推送\n```\nfrom tigeropen.common.consts import Language\nfrom tigeropen.common.util.signature_utils import read_private_key\nfrom tigeropen.push.push_client import PushClient\nfrom tigeropen.tiger_open_config import TigerOpenClientConfig\n\n\ndef on_query_subscribed_quote(symbols, focus_keys, limit, used):\n    print(symbols, focus_keys, limit, used)\n\n\ndef on_quote_changed(symbol, items, hour_trading):\n    print(symbol, items, hour_trading)\n\n\nis_sandbox = False\nclient_config = TigerOpenClientConfig(sandbox_debug=is_sandbox)\nclient_config.private_key = read_private_key('your private key file path')\n# https://www.itiger.com/openapi/info 开发者信息获取\nclient_config.tiger_id = 'your tiger id'\nclient_config.account = 'your account'\nclient_config.language = Language.en_US\nprotocol, host, port = client_config.socket_host_port\npush_client = PushClient(host, port, use_ssl=(protocol == 'ssl'))\npush_client.quote_changed = on_quote_changed\npush_client.subscribed_symbols = on_query_subscribed_quote\npush_client.connect(client_config.tiger_id, client_config.private_key)\npush_client.query_subscribed_quote()\npush_client.subscribe_quote(['AAPL', 'GOOG'])\npush_client.subscribe_asset()\n\ntime.sleep(600)\npush_client.disconnect()\n\n```\n\n---\n\n### 示例代码\n\n- 示例代码位于目录: (tigeropen包安装目录)/tigeropen/examples\n\n***\n\n### 开放平台及量化平台交流\n\n* 老虎量化QQ群(869893807) \n* 团队或公司客户请在入群后联系群主\n\n***\n\n### 使用说明\n\n* 有任何问题可以到 issues  处提出，我们会及时进行解答。\n* 使用新版本时请先仔细阅读接口文档，大部分问题都可以在接口文档中找到你想要的答案。\n* 欢迎大家提出建议、也可以提出各种需求，我们一定会尽量满足大家的需求。\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigerfintech%2Fopenapi-python-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftigerfintech%2Fopenapi-python-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigerfintech%2Fopenapi-python-sdk/lists"}