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.
In this repository45 other files it gives its agents.
- llms.txtllms.txt
- alpha-zooSkill
- breadth-chart-analystSkill
- canslim-screenerSkill
- factor-mining-pandaaiSkill
- backtesting-bias-avoidanceSkill
- backtest-reviewSkill
- data-quality-auditSkill
- paper-reproSkill
- pine-backtesterSkill
- stats-test-pickerSkill
- vectorbt-backtestSkill
- vectorbt-optimizeSkill
- akquantSkill
- ashare-pre-st-filterSkill
- a-stock-dataSkill
- cninfo-disclosureSkill
- ctp-apiSkill
- hithink-finance-financialsSkill
- hithink-finance-marketSkill
- longbridge-derivativesSkill
- longbridge-market-dataSkill
- ptrade-strategy-writingSkill
- quant-buddySkill
- ssquant-futuresSkill
- tdxquantSkill
- uzi-deep-analysisSkill
- wencai-screenerSkill
- ccxt-pythonSkill
- defillama-dataSkill
- defillama-flowsSkill
- defillama-yieldsSkill
- okx-dex-marketSkill
- perp-funding-basisSkill
- pine-debuggerSkill
- pine-developerSkill
- alphagbm-greeksSkill
- alphagbm-vol-surfaceSkill
- comps-analysisSkill
- dcf-modelSkill
- edgar-financialsSkill
- llmquant-equitiesSkill
- llmquant-macroSkill
- llmquant-riskSkill
- openquant-tradingSkill
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
- Distinctive: line 14
Use this skill to answer TqSdk questions with the repository's real APIs, docs, and examples.
- Distinctive: line 18
Read only the references needed for the user's question.
- Very specific: line 20
Read references/wait-update-and-update-loop.md for wait_update, is_changing, deadline, async update notifications, Jupyter caveats, or …
- Very specific: line 21
Read references/market-data.md for get_quote, get_kline_serial, get_tick_serial, contract discovery, symbol metadata, and DataDownloader.
- Very specific: line 22
Read references/account-type-matrix.md for TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqTradingUnit, OTG account classes, and …
- Distinctive: line 23
Read references/accounts-and-trading.md for account, position, order, and trade getters plus multi-account getter patterns.
- Very specific: line 24
Read references/scenario-and-margin.md for TqScenario, real-account margin-rate lookup, margin occupancy calculation, risk-ratio what-if …
- Very specific: line 25
Read references/order-functions-and-position-tools.md for insert_order, cancel_order, TargetPosTask, support_open_min_volume, …
- Very specific: line 26
Read references/object-fields.md when the user asks what fields mean on Quote, K-line or tick rows, Account, Position, Order, Trade, or …
- Distinctive: line 27
Read references/simulation-and-backtest.md for local sim, Quick sim, stock sim, backtest, and cross-account backtest limits.
- Distinctive: line 28
Read references/error-faq.md when the user asks about common TqSdk failures, confusing behavior, or exception messages.
- Distinctive: line 29
Read references/example-map.md when you want a repository-backed example or doc page to imitate.
- Very specific: line 34
If an example needs a current futures or option contract, verify it with query_quotes(..., expired=False), query_options(..., …
- Very specific: line 35
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 …
- Very specific: line 36
Use a concrete non-expired delivery-month contract for order, position, TargetPosTask, and margin examples.
- Distinctive: line 37
Do not expose real account names, passwords, tokens, or customer credentials.
- Distinctive: line 38
When writing or changing code, run the smallest practical verification, such as import checks, syntax checks, a short quote subscription, …
- Very specific: line 42
Treat get_* results as live references, not snapshots.
- Distinctive: line 51
When the user asks for field meanings, explain the smallest relevant field set first and say whether the object is futures or stock.
- Very specific: line 52
When the user asks for long historical ranges, prefer DataDownloader over pretending get_kline_serial is an unlimited history API.
- Distinctive: line 53
When the user asks for advanced execution, prefer public helpers first:
- Very specific: line 60
Use TqScenario for synchronous what-if margin and risk trials, not for live order placement.
- Very specific: line 64
Treat margin discounts conservatively.
- Very specific: line 69
Prefer imports from tqsdk.__init__ for top-level APIs.
- Distinctive: line 70
Prefer short, correct code blocks over broad pseudo-code.
- Distinctive: line 72
If behavior differs in live trading, Quick sim, local sim, stock sim, or backtest, say so explicitly.
- Distinctive: line 73
If the answer depends on a common pitfall, state the pitfall directly instead of burying it in examples.
- Very specific: line 74
If the answer uses TqScenario, say what snapshot goes into positions, what balance goes into init_balance, and whether the result comes …
≈ “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.
Files
<!--
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.
- Read references/wait-update-and-update-loop.md for
wait_update,is_changing,deadline, async update notifications, Jupyter caveats, or backtest progression questions. - Read references/market-data.md for
get_quote,get_kline_serial,get_tick_serial, contract discovery, symbol metadata, andDataDownloader. - Read references/account-type-matrix.md for
TqAccount,TqKq,TqKqStock,TqSim,TqSimStock,TqTradingUnit, OTG account classes, andTqMultiAccount. - Read references/accounts-and-trading.md for account, position, order, and trade getters plus multi-account getter patterns.
- 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. - Read references/order-functions-and-position-tools.md for
insert_order,cancel_order,TargetPosTask,support_open_min_volume,TargetPosScheduler,Twap, and advanced execution helpers. - 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. - Read references/simulation-and-backtest.md for local sim, Quick sim, stock sim, backtest, and cross-account backtest limits.
- Read references/error-faq.md when the user asks about common TqSdk failures, confusing behavior, or exception messages.
- Read references/example-map.md when you want a repository-backed example or doc page to imitate.
Before Writing Code
- Identify the task mode first: market data only, local sim, Quick sim, real account, stock trading, futures trading, backtest, or margin trial.
- 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. - Prefer main-contract symbols such as
KQ.m@SHFE.rbfor market-data and historical-download examples when the user does not need a tradable delivery month. - Use a concrete non-expired delivery-month contract for order, position,
TargetPosTask, and margin examples. - Do not expose real account names, passwords, tokens, or customer credentials. Use placeholders or environment variables.
- 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
- Treat
get_*results as live references, not snapshots. Explain that they refresh duringwait_update(). - Explain
wait_update()whenever the user is confused by missing data, stale fields, orders not leaving the client, orTargetPosTasknot acting. - 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, andTargetPosTaskis not for stock trading.
- Futures accounts and objects use
- Choose account type before writing code. Do not default to
TqKqorTqAccountunless the user really needs that account mode. - In multi-account mode, pass
account=for getters and trading calls, or use the account object's ownget_account,get_position,get_order, andget_trade. - For current market examples, avoid expired contracts. Prefer contract discovery APIs or main-contract symbols.
- When the user asks for field meanings, explain the smallest relevant field set first and say whether the object is futures or stock.
- When the user asks for long historical ranges, prefer
DataDownloaderover pretendingget_kline_serialis an unlimited history API. - When the user asks for advanced execution, prefer public helpers first:
TargetPosTaskfor target net position.TargetPosTask(..., support_open_min_volume=True)only for contracts with exchange minimum opening size rules when approximate completion is acceptable.TargetPosSchedulerplustwap_tableorvwap_tablefromtqsdk.algorithmfor 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
InsertOrderTaskandInsertOrderUntilAllTradedTaskas internal or advanced helpers, not the default answer.
- Use
TqScenariofor 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. - Explain the margin-rate source in every
TqScenarioanswer:
account=NoneorTqSim()usesQuotemargin data.TqAccount(...)orTqKq()queries account-specific rates synchronously and may fall back toQuotemargin if lookup fails.
- Treat margin discounts conservatively. Reuse one
TqScenarioobject for step-by-step trial actions, and do not promise broker-specific preferential rules beyond the limited built-in rules modeled by TqSdk. - Preserve exchange-specific close semantics in
TqScenario. For SHFE or INE futures, keepCLOSEversusCLOSETODAYconsistent 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 astqsdk.toolsortqsdk.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 intopositions, what balance goes intoinit_balance, and whether the result comes from quote margin or account-specific margin rates.
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
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.

