agentleFS
JerryLiu369JerryLiu369/awesome-quant-skills/skills/china-markets/tqsdk-trading/SKILL.md

tqsdk-trading

Skill5 starsChanged 4 days agoMITView on GitHub

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(). Read only the references needed for the user's question.

The file

Show its rules and text

We split this skill into the rules it gives an agent

28 rules. About 0 are common, 13 are distinctive, and 15 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 15

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to answer TqSdk questions with the repository's real APIs, docs, and examples.

    line 14
  2. Distinctive:

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

    line 18
  3. Very specific:

    Read references/wait-update-and-update-loop.md for wait_update, is_changing, deadline, async update notifications, Jupyter caveats, or …

    line 20
  4. Very specific:

    Read references/market-data.md for get_quote, get_kline_serial, get_tick_serial, contract discovery, symbol metadata, and DataDownloader.

    line 21
  5. Very specific:

    Read references/account-type-matrix.md for TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqTradingUnit, OTG account classes, and …

    line 22
  6. Distinctive:

    Read references/accounts-and-trading.md for account, position, order, and trade getters plus multi-account getter patterns.

    line 23
  7. Very specific:

    Read references/scenario-and-margin.md for TqScenario, real-account margin-rate lookup, margin occupancy calculation, risk-ratio what-if …

    line 24
  8. Very specific:

    Read references/order-functions-and-position-tools.md for insert_order, cancel_order, TargetPosTask, support_open_min_volume, …

    line 25
  9. Very specific:

    Read references/object-fields.md when the user asks what fields mean on Quote, K-line or tick rows, Account, Position, Order, Trade, or …

    line 26
  10. Distinctive:

    Read references/simulation-and-backtest.md for local sim, Quick sim, stock sim, backtest, and cross-account backtest limits.

    line 27
  11. Distinctive:

    Read references/error-faq.md when the user asks about common TqSdk failures, confusing behavior, or exception messages.

    line 28
  12. Distinctive:

    Read references/example-map.md when you want a repository-backed example or doc page to imitate.

    line 29
  13. Very specific:

    If an example needs a current futures or option contract, verify it with query_quotes(..., expired=False), query_options(..., …

    line 34
  14. Very specific:

    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 …

    line 35
  15. Very specific:

    Use a concrete non-expired delivery-month contract for order, position, TargetPosTask, and margin examples.

    line 36
  16. Distinctive:

    Do not expose real account names, passwords, tokens, or customer credentials.

    line 37
  17. Distinctive:

    When writing or changing code, run the smallest practical verification, such as import checks, syntax checks, a short quote subscription, …

    line 38
  18. Very specific:

    Treat get_* results as live references, not snapshots.

    line 42
  19. Distinctive:

    When the user asks for field meanings, explain the smallest relevant field set first and say whether the object is futures or stock.

    line 51
  20. Very specific:

    When the user asks for long historical ranges, prefer DataDownloader over pretending get_kline_serial is an unlimited history API.

    line 52
  21. Distinctive:

    When the user asks for advanced execution, prefer public helpers first:

    line 53
  22. Very specific:

    Use TqScenario for synchronous what-if margin and risk trials, not for live order placement.

    line 60
  23. Very specific:

    Treat margin discounts conservatively.

    line 64
  24. Very specific:

    Prefer imports from tqsdk.__init__ for top-level APIs.

    line 69
  25. Distinctive:

    Prefer short, correct code blocks over broad pseudo-code.

    line 70
  26. Distinctive:

    If behavior differs in live trading, Quick sim, local sim, stock sim, or backtest, say so explicitly.

    line 72
  27. Distinctive:

    If the answer depends on a common pitfall, state the pitfall directly instead of burying it in examples.

    line 73
  28. Very specific:

    If the answer uses TqScenario, say what snapshot goes into positions, what balance goes into init_balance, and whether the result comes …

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- Imported from: https://github.com/shinnytech/tqsdk-python Source Path: doc/ai_editor/skills/tqsdk-trading-and-data/SKILL.md Curated for awesome-quant-skills -->

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, \u884c\u60c5, K\u7ebf, \u5386\u53f2\u6570\u636e, \u4fdd\u8bc1\u91d1\u7387, \u4fdd\u8bc1\u91d1, \u98ce\u9669\u5ea6, \u573a\u666f\u8bd5\u7b97, \u6301\u4ed3, \u6210\u4ea4, \u59d4\u6258, \u8d26\u6237, \u4e0b\u5355, \u64a4\u5355, \u8c03\u4ed3, \u591a\u7b56\u7565, \u5b57\u6bb5\u542b\u4e49, or \u62a5\u9519."

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:
  • 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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.