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 cancelation, target-position tools, TqScenario margin trials, real-account margin-rate lookup, margin or risk-ratio what-if analysis, simulation, backtest, and common TqSdk errors. Use when a request mentions TqSdk, TqApi, TqAuth, TqAccount, TqKq, TqKqStock, TqSim, TqSimStock, TqMultiAccount, TqBacktest, TqScenario, TargetPosTask, TargetPosScheduler, DataDownloader, margin rate, margin calculation, risk ratio, scenario trial, market data, K-line, tick, historical data, positions, trades, orders, account data, order placement, cancelation, position adjustment, field meanings, wait_update, debugging, 行情, K线, 历史数据, 保证金率, 保证金, 风险度, 场景试算, 持仓, 成交, 委托, 账户, 下单, 撤单, 调仓, 字段含义, or 报错.
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.
wait_update, is_changing, deadline, async update notifications, Jupyter caveats, or backtest progression questions.get_quote, get_kline_serial, get_tick_serial, contract discovery, symbol metadata, and DataDownloader.TqAccountTqKqTqKqStockTqSimTqSimStockTqMultiAccountTqScenario, real-account margin-rate lookup, margin occupancy calculation, risk-ratio what-if analysis, and limited built-in margin discount rules.insert_order, cancel_order, TargetPosTask, TargetPosScheduler, and advanced execution helpers.Quote, K-line or tick rows, Account, Position, Order, Trade, or their stock variants.get_* results as live references, not snapshots. Explain that they refresh during wait_update().wait_update() whenever the user is confused by missing data, stale fields, orders not leaving the client, or TargetPosTask not acting.Account, Position, Order, Trade.SecurityAccount, SecurityPosition, SecurityOrder, SecurityTrade.offset, and TargetPosTask is not for stock trading.TqKq or TqAccount unless the user really needs that account mode.account= for getters and trading calls, or use the account object's own get_account, get_position, get_order, and get_trade.DataDownloader over pretending get_kline_serial is an unlimited history API.TargetPosTask for target net position.TargetPosScheduler plus twap_table or vwap_table from tqsdk.algorithm for scheduled execution.InsertOrderTask and InsertOrderUntilAllTradedTask as internal or advanced helpers, not the default answer.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.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.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.TqScenario. For SHFE or INE futures, keep CLOSE versus CLOSETODAY consistent with the imported position snapshot.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.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.