Agent skill

TqSdk Trading and Data

by shinnytech in shinnytech/tqsdk-python

Answers TqSdk Python questions on market data, accounts, orders, margin trials, simulation and backtesting, using the library's own docs and examples.

Apache-2.0Auto-check passedBusiness, Finance & HR

Install TqSdk Trading and Data

skills CLI
$ npx skills add shinnytech/tqsdk-python --skill tqsdk-trading-and-data -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install shinnytech/tqsdk-python tqsdk-trading-and-data --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/shinnytech/tqsdk-python.git skills-src && mkdir -p .claude/skills && cp -r skills-src/doc/ai_editor/skills/tqsdk-trading-and-data .claude/skills/tqsdk-trading-and-data && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tqsdk-trading-and-data
GitHub stars
5.1k
Token cost
~2k tokens
SKILL.md length
832 words
Files
12 (incl. references)
Skills in repo
1
Repo updated
First seen
Licence
Apache-2.0

At a glance

Answers TqSdk Python questions on market data, accounts, orders, margin trials, simulation and backtesting, using the library's own docs and examples.

  • Works in 10 steps: Read… → Read references/market-data.md for… → Read references/account-type-matrix.md… → …
  • Debugging a TqSdk strategy that stalls or never updates in its wait_update loop
  • SKILL.md covers Route The Request First, Before Writing Code, Core Rules and Answering Style
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

The skill answers TqSdk questions from the library's real APIs, docs and examples, preferring minimal runnable snippets and keeping futures and stock behavior separate. Whenever a problem depends on `wait_update()`, it explains the update loop explicitly, and before writing code it identifies the task mode: market data only, local simulation, quick simulation, real account, stock or futures trading, backtest or margin trial.

A routing list sends the agent to one reference file per topic: the update loop and `is_changing`, market data (`get_quote`, `get_kline_serial`, `get_tick_serial`, `DataDownloader`), account classes such as `TqAccount`, `TqKq`, `TqSim` and `TqMultiAccount`, account and order getters, `TqScenario` margin and risk-ratio what-if analysis, order and position tools such as `insert_order`, `TargetPosTask` and `Twap`, field meanings, simulation and backtest limits, an error FAQ and an example map.

When your agent uses it

  • Debugging a TqSdk strategy that stalls or never updates in its wait_update loop
  • Downloading historical K-line or tick data with TqSdk
  • Choosing between TqSim, TqKq and real-account classes
  • Placing, cancelling or adjusting positions with TargetPosTask
  • Estimating margin or risk ratio with TqScenario

Example prompts

  • “My TqSdk script prints the same quote forever. Explain how wait_update and is_changing should be used.”
  • “Write a TqSdk snippet that downloads daily K-lines for a futures contract to a CSV file with DataDownloader.”
  • “Set up a TargetPosTask that moves my simulated account to a long position of one lot.”
  • “Which account class should I use to backtest a stock strategy across two accounts?”

Requirements

  • Python with the TqSdk library

Workflow steps

10 steps, taken from the first numbered list in SKILL.md.

  1. Read references/wait-update-and-update-loop.md for wait_update, is_changing, deadline, async update notifications, Jupyter caveats, or…
  2. Read references/market-data.md for get_quote, get_kline_serial, get_tick_serial, contract discovery, symbol metadata, and DataDownloader.
  3. Read references/account-type-matrix.md for TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqTradingUnit, OTG account classes, and…
  4. Read references/accounts-and-trading.md for account, position, order, and trade getters plus multi-account getter patterns.
  5. Read references/scenario-and-margin.md for TqScenario, real-account margin-rate lookup, margin occupancy calculation, risk-ratio what-if…
  6. Read references/order-functions-and-position-tools.md for insert_order, cancel_order, TargetPosTask, support_open_min_volume…
  7. Read references/object-fields.md when the user asks what fields mean on Quote, K-line or tick rows, Account, Position, Order, Trade, or…
  8. Read references/simulation-and-backtest.md for local sim, Quick sim, stock sim, backtest, and cross-account backtest limits.
  9. Read references/error-faq.md when the user asks about common TqSdk failures, confusing behavior, or exception messages.
  10. Read references/example-map.md when you want a repository-backed example or doc page to imitate.

What it can do on your machine

Read from SKILL.md and the folder at commit 78c9922. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

TqSdk Trading and Data loads about 2k tokens when it runs, and up to ~15k if it reads all its reference files. Until then it costs about 247 tokens; SKILL.md has 832 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~247
When it runs · the whole SKILL.md, loaded when a task matches
~2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~15k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from shinnytech/tqsdk-python at commit 78c9922, republished under its Apache-2.0 licence (© shinnytech). 832 words, ~2,024 tokens.

Download SKILL.mdSave it as .claude/skills/tqsdk-trading-and-data/SKILL.md (or your agent's skills folder). This skill also uses 11 other files; get the full folder from GitHub.
name
tqsdk-trading-and-data
description
Explain, implement, or debug TqSdk Python workflows for wait_update or is_changing update loops, market data retrieval, historical download, account type selection, funds or positions or orders or trades, field meanings, order placement or cancellation, target-position tools, TqScenario margin trials, real-account margin-rate lookup, margin or risk-ratio what-if analysis, simulation, backtest, multi-strategy, and common TqSdk errors. Use when a request mentions TqSdk, TqApi, TqAuth, TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqMultiAccount, TqTradingUnit, TqBacktest, TqScenario, TargetPosTask, TargetPosScheduler, Twap, DataDownloader, margin rate, margin calculation, risk ratio, scenario trial, market data, K-line, tick, historical data, positions, trades, orders, account data, order placement, cancellation, position adjustment, field meanings, wait_update, debugging, 行情, K线, 历史数据, 保证金率, 保证金, 风险度, 场景试算, 持仓, 成交, 委托, 账户, 下单, 撤单, 调仓, 多策略, 字段含义, or 报错.

TqSdk Trading and Data

Use this skill to answer TqSdk questions with the repository's real APIs, docs, and examples. Prefer minimal runnable snippets, keep futures and stock behavior separate, and explain the update loop explicitly whenever the user's issue depends on wait_update().

Route The Request First

Read only the references needed for the user's question.

  1. Read references/wait-update-and-update-loop.md for wait_update, is_changing, deadline, async update notifications, Jupyter caveats, or backtest progression questions.
  2. Read references/market-data.md for get_quote, get_kline_serial, get_tick_serial, contract discovery, symbol metadata, and DataDownloader.
  3. Read references/account-type-matrix.md for TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqTradingUnit, OTG account classes, and TqMultiAccount.
  4. Read references/accounts-and-trading.md for account, position, order, and trade getters plus multi-account getter patterns.
  5. Read references/scenario-and-margin.md for TqScenario, real-account margin-rate lookup, margin occupancy calculation, risk-ratio what-if analysis, and limited built-in margin discount rules.
  6. Read references/order-functions-and-position-tools.md for insert_order, cancel_order, TargetPosTask, support_open_min_volume, TargetPosScheduler, Twap, and advanced execution helpers.
  7. Read references/object-fields.md when the user asks what fields mean on Quote, K-line or tick rows, Account, Position, Order, Trade, or their stock variants.
  8. Read references/simulation-and-backtest.md for local sim, Quick sim, stock sim, backtest, and cross-account backtest limits.
  9. Read references/error-faq.md when the user asks about common TqSdk failures, confusing behavior, or exception messages.
  10. Read references/example-map.md when you want a repository-backed example or doc page to imitate.

Before Writing Code

  1. Identify the task mode first: market data only, local sim, Quick sim, real account, stock trading, futures trading, backtest, or margin trial.
  2. If an example needs a current futures or option contract, verify it with query_quotes(..., expired=False), query_options(..., expired=False), or a main-contract symbol before using it.
  3. Prefer main-contract symbols such as KQ.m@SHFE.rb for market-data and historical-download examples when the user does not need a tradable delivery month.
  4. Use a concrete non-expired delivery-month contract for order, position, TargetPosTask, and margin examples.
  5. Do not expose real account names, passwords, tokens, or customer credentials. Use placeholders or environment variables.
  6. When writing or changing code, run the smallest practical verification, such as import checks, syntax checks, a short quote subscription, or a narrow backtest.

Core Rules

  1. Treat get_* results as live references, not snapshots. Explain that they refresh during wait_update().
  2. Explain wait_update() whenever the user is confused by missing data, stale fields, orders not leaving the client, or TargetPosTask not acting.
  3. Distinguish futures and stock workflows:
    • Futures accounts and objects use Account, Position, Order, Trade.
    • Stock accounts and objects use SecurityAccount, SecurityPosition, SecurityOrder, SecurityTrade.
    • Stock trading does not use offset, and TargetPosTask is not for stock trading.
  4. Choose account type before writing code. Do not default to TqKq or TqAccount unless the user really needs that account mode.
  5. In multi-account mode, pass account= for getters and trading calls, or use the account object's own get_account, get_position, get_order, and get_trade.
  6. For current market examples, avoid expired contracts. Prefer contract discovery APIs or main-contract symbols.
  7. When the user asks for field meanings, explain the smallest relevant field set first and say whether the object is futures or stock.
  8. When the user asks for long historical ranges, prefer DataDownloader over pretending get_kline_serial is an unlimited history API.
  9. When the user asks for advanced execution, prefer public helpers first:
    • TargetPosTask for target net position.
    • TargetPosTask(..., support_open_min_volume=True) only for contracts with exchange minimum opening size rules when approximate completion is acceptable.
    • TargetPosScheduler plus twap_table or vwap_table from tqsdk.algorithm for scheduled execution.
    • TargetPosScheduler(..., support_open_min_volume=True) when the scheduled execution targets a contract with exchange minimum opening size rules.
    • Direct tqsdk.algorithm.Twap(..., support_open_min_volume=True) only when the user asks for the older/direct TWAP helper; note that it is not for backtest.
    • Mention InsertOrderTask and InsertOrderUntilAllTradedTask as internal or advanced helpers, not the default answer.
  10. Use TqScenario for synchronous what-if margin and risk trials, not for live order placement. It is futures-only, single-account, and updates the trial snapshot immediately after each call.
  11. Explain the margin-rate source in every TqScenario answer:
Show full SKILL.md (181 more words)Show less
  • account=None or TqSim() uses Quote margin data.
  • TqAccount(...) or TqKq() queries account-specific rates synchronously and may fall back to Quote margin if lookup fails.
  1. Treat margin discounts conservatively. Reuse one TqScenario object for step-by-step trial actions, and do not promise broker-specific preferential rules beyond the limited built-in rules modeled by TqSdk.
  2. Preserve exchange-specific close semantics in TqScenario. For SHFE or INE futures, keep CLOSE versus CLOSETODAY consistent with the imported position snapshot.

Answering Style

  • Prefer imports from tqsdk.__init__ for top-level APIs. When an API is documented under a submodule, use that official submodule path such as tqsdk.tools or tqsdk.algorithm.
  • Prefer short, correct code blocks over broad pseudo-code.
  • Name the exact API the user should call next.
  • If behavior differs in live trading, Quick sim, local sim, stock sim, or backtest, say so explicitly.
  • If the answer depends on a common pitfall, state the pitfall directly instead of burying it in examples.
  • If the answer uses TqScenario, say what snapshot goes into positions, what balance goes into init_balance, and whether the result comes from quote margin or account-specific margin rates.

© shinnytech, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 11 other files (references) in doc/ai_editor/skills/tqsdk-trading-and-data of shinnytech/tqsdk-python.

  • SKILL.md
  • agents/openai.yaml
  • references/account-type-matrix.md
  • references/accounts-and-trading.md
  • references/error-faq.md
  • references/example-map.md
  • references/market-data.md
  • references/object-fields.md
  • references/order-functions-and-position-tools.md
  • references/scenario-and-margin.md
  • references/simulation-and-backtest.md
  • references/wait-update-and-update-loop.md

Open the folder on GitHubat commit 78c9922

Compare with similar skills

TqSdk Trading and Data next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

TqSdk Trading and Data compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
TqSdk Trading and Data this skillshinnytech/tqsdk-python5.1k—~2kAutomated safety check: PassApache-2.0
CCXT Crypto Exchange Library2025Emma/vibe-coding-cn23k1 repos~4.4kAutomated safety check: PassMIT
Tiger Brokers OpenAPI SDKqusong0627/QuantMind1.7k—~1.4kAutomated safety check: PassApache-2.0
Backtest DiagnosisHKUDS/Vibe-Trading35k—~1.2kAutomated safety check: PassMIT
Vibetrading Code GenLeoYeAI/openclaw-master-skills2.2k—~5.7kAutomated safety check: PassMIT
Polymarket Tennislivetennisapi/livetennisapi-mcp152—~3kAutomated safety check: PassMIT

Similar skills

  • CCXT Crypto Exchange Library

    2025Emma/vibe-coding-cn

    Reference help for the CCXT library covering crypto exchange APIs, market data, trading and order management across 150+ exchanges in JavaScript, Python and PHP.

    23k GitHub starsUsed in 1 repo~4.4k tokens
    Business, Finance & HRAuto-check passed
  • Tiger Brokers OpenAPI SDK

    qusong0627/QuantMind

    Covers the Tiger Brokers OpenAPI Python SDK for market data, stock, futures and options trading, push subscriptions, a CLI and an MCP server, defaulting to paper trading.

    1.7k GitHub stars~1.4k tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Backtest Diagnosis

    HKUDS/Vibe-Trading

    Finds why a trading backtest crashed or gave odd results, sorts the cause into a runtime, logic or data error, fixes the code and checks the rerun metrics.

    35k GitHub stars~1.2k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Vibetrading Code Gen

    LeoYeAI/openclaw-master-skills

    Generate executable Hyperliquid trading strategy code from natural language prompts.

    2.2k GitHub stars~5.7k tokensUpdated 2 mo ago
    Business, Finance & HRAuto-check passed
  • Polymarket Tennis

    livetennisapi/livetennisapi-mcp

    Build observe-only Polymarket and Kalshi tennis market tooling on the polymarket-tennis Python package (MIT) plus the Live Tennis API free tier.

    152 GitHub stars~3k tokensUpdated 3 days ago
    Business, Finance & HRAuto-check passed
  • Version Bump

    marketcalls/openalgo

    Bump a version in the OpenAlgo repo. An agent skill from marketcalls/openalgo.

    2.8k GitHub stars~1.8k tokensUpdated yesterday
    DevelopmentAuto-check passed

Works with

Questions about TqSdk Trading and Data

What does TqSdk Trading and Data do?

Answers TqSdk Python questions on market data, accounts, orders, margin trials, simulation and backtesting, using the library's own docs and examples. The skill answers TqSdk questions from the library's real APIs, docs and examples, preferring minimal runnable snippets and keeping futures and stock behavior separate. Whenever a problem depends on `wait_update()`, it explains the update loop explicitly, and before writing code it identifies the task mode: market data only, local simulation, quick simulation, real account, stock or futures trading, backtest or margin trial.

When should I use TqSdk Trading and Data?

TqSdk Trading and Data fits situations like: debugging a TqSdk strategy that stalls or never updates in its wait_update loop; downloading historical K-line or tick data with TqSdk; choosing between TqSim, TqKq and real-account classes; placing, cancelling or adjusting positions with TargetPosTask.

How do I install TqSdk Trading and Data in Claude Code?

Run `npx skills add shinnytech/tqsdk-python --skill tqsdk-trading-and-data -a claude-code`. Or copy the skill folder (doc/ai_editor/skills/tqsdk-trading-and-data in shinnytech/tqsdk-python) into .claude/skills/tqsdk-trading-and-data in your project. Claude Code loads it when a task matches its description.

How do I install TqSdk Trading and Data in Codex?

Run `npx skills add shinnytech/tqsdk-python --skill tqsdk-trading-and-data -a codex`. Or copy the skill folder (doc/ai_editor/skills/tqsdk-trading-and-data in shinnytech/tqsdk-python) into .agents/skills/tqsdk-trading-and-data in your project. Codex loads it when a task matches its description.

Can I use TqSdk Trading and Data in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add shinnytech/tqsdk-python --skill tqsdk-trading-and-data -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tqsdk-trading-and-data, .gemini/skills/tqsdk-trading-and-data, .github/skills/tqsdk-trading-and-data and .opencode/skills/tqsdk-trading-and-data in your project.

What does TqSdk Trading and Data need to run?

SKILL.md names no scripts, command-line tools or credentials: TqSdk Trading and Data is instructions for the agent only. Our summary lists: Python with the TqSdk library.

Does TqSdk Trading and Data access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is TqSdk Trading and Data safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does TqSdk Trading and Data use?

TqSdk Trading and Data is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does TqSdk Trading and Data use?

About 2k tokens (SKILL.md is roughly 8.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 13k tokens, read only when the agent opens those files.

What are the alternatives to TqSdk Trading and Data?

Skills that share tags, products or a category with TqSdk Trading and Data: CCXT Crypto Exchange Library (2025Emma/vibe-coding-cn, 23k stars), Tiger Brokers OpenAPI SDK (qusong0627/QuantMind, 1.7k stars), Backtest Diagnosis (HKUDS/Vibe-Trading, 35k stars) and Vibetrading Code Gen (LeoYeAI/openclaw-master-skills, 2.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains TqSdk Trading and Data?

shinnytech (a GitHub organization) maintains it in shinnytech/tqsdk-python, which has 5,070 GitHub stars. The repository was last updated on August 18, 2026.

Source: shinnytech/tqsdk-python on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.