### Starting API Environment - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Starts the internal trading thread and prepares the environment necessary for trading operations. This should be called after creating the API instance and registering callbacks. ```python start() ``` ```python # 启动交易线程 #xt_trader为XtQuant API实例对象 xt_trader.start() ``` -------------------------------- ### Get IPO Info - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Returns new stock initial public offering (IPO) information within a specified date range. Returns a list of dictionaries, each containing details about an IPO. If start and end times are empty, returns all available data. ```python get_ipo_info(start_time, end_time) ``` -------------------------------- ### Get ETF Info - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves redemption and creation list information for all ETFs. Returns a dictionary containing the ETF information. Requires the data to have been downloaded first using `download_etf_info`. ```python get_etf_info() ``` -------------------------------- ### Download Holiday Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads holiday data synchronously. This data is required for functions like getting the trading calendar. ```python download_holiday_data() ``` -------------------------------- ### Get Sector List - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves a list of available sector names. Returns a list of strings representing sector names. Requires sector classification information to have been downloaded. ```python get_sector_list() ``` -------------------------------- ### Get Trading Calendar - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves the trading calendar for a specified market within a given time range. Returns a list of trading dates. Requires downloading the holiday list beforehand to get future trading days. ```python get_trading_calendar(market, start_time = '', end_time = '') ``` -------------------------------- ### Get Convertible Bond Info - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves base information for a specified convertible bond code. Returns a dictionary containing the convertible bond's information. Requires the data to have been downloaded first using `download_cb_data`. ```python get_cb_info(stockcode) ``` -------------------------------- ### Get Stocks in Sector - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves the list of constituent stock codes for a specified sector name. Returns a list of stock code strings. Requires sector classification information to have been downloaded. ```python get_stock_list_in_sector(sector_name) ``` -------------------------------- ### Get Available Period List - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Returns a list of available periods (e.g., '1m', '1d', '1w') that can be used for historical data functions. ```python get_period_list() ``` -------------------------------- ### Get Holidays - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves a list of holiday dates up to the current year. The dates are returned as 8-digit string format. ```python get_holidays() ``` -------------------------------- ### Get Index Weight - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves the constituent stock weights for a specified index code. Returns a dictionary where keys are stock codes and values are their respective weights. Requires index weight information to have been downloaded. ```python get_index_weight(index_code) ``` -------------------------------- ### Get Instrument Detail - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves base information for a specified contract code. Can fetch a limited or complete set of fields. Returns a dictionary of data fields or None if the contract is not found. Useful for validating contract codes. ```python get_instrument_detail(stock_code, iscomplete) ``` -------------------------------- ### Get Trading Dates - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves a list of trading dates for a specified market within a given range or count. Returns a list of timestamp strings. ```python get_trading_dates(market, start_time='', end_time='', count=-1) ``` -------------------------------- ### Get Level 2 Transaction Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves Level 2 tick-by-tick transaction data from the cache. Data is returned as a numpy.ndarray, sorted ascending by time. Requires data to have been previously received and cached. ```python get_l2_transaction(field_list=[], stock_code='', start_time='', end_time='', count=-1) ``` -------------------------------- ### Get Financial Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves financial data for a list of stock codes and specified tables within a time range. Data can be filtered by report date or announcement date. Returns a nested dictionary where keys are stock codes, and values are dictionaries of tables containing pandas DataFrames. See appendix for detailed fields. ```python get_financial_data(stock_list, table_list=[], start_time='', end_time='', report_type='report_time') ``` -------------------------------- ### Get Instrument Type - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Retrieves the type information for a specified contract code. Returns a dictionary indicating whether the contract is an index, stock, fund, or ETF (True/False). Returns None if the contract is not found. ```python get_instrument_type(stock_code) ``` -------------------------------- ### Get Trading Time Periods - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Returns the trading time periods for a specified contract code. Returns a list of lists, where each inner list contains [start_time_seconds, end_time_seconds, trade_type]. Times are in seconds relative to the current day's midnight. Returns an empty list for invalid stock codes. ```python get_trading_time(stockcode) ``` -------------------------------- ### Creating XtQuantTrader Instance - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Initializes a new instance of the XtQuant API for trading. Requires the path to the MiniQMT client's userdata directory and a unique session ID to communicate with MiniQMT. ```python XtQuantTrader(path, session_id) ``` ```python path = 'D:\\迅投极速交易终端 睿智融科版\\userdata_mini' # session_id为会话编号,策略使用方对于不同的Python策略需要使用不同的会话编号 session_id = 123456 #后续的所有示例将使用该实例对象 xt_trader = XtQuantTrader(path, session_id) ``` -------------------------------- ### Download ETF Info - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads redemption and creation list information for all ETFs synchronously. The function returns after the download is complete. ```python download_etf_info() ``` -------------------------------- ### Download Convertible Bond Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads base information for all convertible bonds synchronously. The function returns after the download is complete. ```python download_cb_data() ``` -------------------------------- ### Download Financial Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads financial data for a list of stock codes and specified tables synchronously. The function returns after the download is complete. ```python download_financial_data(stock_list, table_list=[]) ``` -------------------------------- ### Asynchronous Stock Ordering - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Places a stock order asynchronously, immediately returning a request sequence number (seq). A successful placement is indicated by a positive seq; failure results in -1. Feedback is provided via the `on_order_stock_async_response` callback or failure push. ```python order_stock_async(account, stock_code, order_type, order_volume, price_type, price, strategy_name, order_remark) ``` ```python account = StockAccount('1000000365') #xt_trader为XtQuant API实例对象 seq = xt_trader.order_stock_async(account, '600000.SH', xtconstant.STOCK_BUY, 1000, xtconstant.FIX_PRICE, 10.5, 'strategy1', 'order_test') ``` -------------------------------- ### Download Financial Data (Batch) - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads financial data for a list of stock codes and specified tables in batch, executing synchronously. Data can be filtered by announcement date. Progress updates can be received via an optional callback function. ```python download_financial_data2(stock_list, table_list=[], start_time='', end_time='', callback=None) ``` -------------------------------- ### Connecting to MiniQMT - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Establishes a connection to the MiniQMT client. This is a one-time connection; if it disconnects, you must explicitly call this method again to reconnect. ```python connect() ``` ```python # 建立交易连接,返回0表示连接成功 #xt_trader为XtQuant API实例对象 connect_result = xt_trader.connect() print(connect_result) ``` -------------------------------- ### Download Historical Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads or supplements historical market data synchronously. The function returns after data download is complete. Use the `incrementally` parameter or `start_time` to control incremental updates. ```python download_history_data(stock_code, period, start_time='', end_time='', incrementally = None) ``` -------------------------------- ### Registering Callback - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Registers a callback instance with the API instance. This callback object will receive messages, push notifications, and asynchronous responses from the MiniQMT client. ```python register_callback(callback) ``` ```python # 创建交易回调类对象,并声明接收回调 class MyXtQuantTraderCallback(XtQuantTraderCallback): ... pass callback = MyXtQuantTraderCallback() #xt_trader为XtQuant API实例对象 xt_trader.register_callback(callback) ``` -------------------------------- ### Describing Level2 Order Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists the field names for Level 2 tick-by-tick order data available via the xtquant API. It includes timestamp, price, volume, order number, and types/directions of orders. This data provides a granular view of individual orders entering the market. ```python 'time' #时间戳 'price' #委托价 'volume' #委托量 'entrustNo' #委托号 'entrustType' #委托类型 'entrustDirection' #委托方向 ``` -------------------------------- ### Subscribing Account Info - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Subscribes to receive push notifications for a specific account's information. This includes updates on funds, orders, trades, and positions. ```python subscribe(account) ``` ```python account = StockAccount('1000000365') #xt_trader为XtQuant API实例对象 subscribe_result = xt_trader.subscribe(account) ``` -------------------------------- ### Synchronous Stock Ordering - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Places a stock order synchronously and waits for the system's initial order ID response. Returns a positive integer for a successful order ID or -1 if the order placement failed. ```python order_stock(account, stock_code, order_type, order_volume, price_type, price, strategy_name, order_remark) ``` ```python account = StockAccount('1000000365') #xt_trader为XtQuant API实例对象 order_id = xt_trader.order_stock(account, '600000.SH', xtconstant.STOCK_BUY, 1000, xtconstant.FIX_PRICE, 10.5, 'strategy1', 'order_test') ``` -------------------------------- ### Create Sector Folder Node - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Creates a directory node for organizing sectors. Allows specifying a parent node and whether to overwrite existing nodes. Returns the actual name of the created folder, which may include a numerical suffix if overwrite is False and the name exists. ```python create_sector_folder(parent_node, folder_name, overwrite) ``` -------------------------------- ### Describing Level2 Order Queue Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists the field names for Level 2 order queue data (specifically for the first bid/ask level) available via the xtquant API. It provides details about the price, volume, and number of orders at the best bid and ask prices. This allows analysis of immediate market depth and order structure. ```python 'time' #时间戳 'bidLevelPrice' #委买价 'bidLevelVolume' #委买量 'offerLevelPrice' #委卖价 'offerLevelVolume' #委卖量 'bidLevelNumber' #委买数量 'offLevelNumber' #委卖数量 ``` -------------------------------- ### Key Financial Metrics Data Keys - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Lists Python string identifiers used to query or reference various key financial metrics, such as per-share values, profitability ratios, and growth rates, within the xtquant system. Each key is accompanied by its Chinese description. ```Python 's_fa_ocfps' #每股经营活动现金流量 's_fa_bps' #每股净资产 's_fa_eps_basic' #基本每股收益 's_fa_eps_diluted' #稀释每股收益 's_fa_undistributedps' #每股未分配利润 's_fa_surpluscapitalps' #每股资本公积金 'adjusted_earnings_per_share' #扣非每股收益 'du_return_on_equity' #净资产收益率 'sales_gross_profit' #销售毛利率 'inc_revenue_rate' #主营收入同比增长 'du_profit_rate' #净利润同比增长 'inc_net_profit_rate' #归属于母公司所有者的净利润同比增长 'adjusted_net_profit_rate' #扣非净利润同比增长 'inc_total_revenue_annual' #营业总收入滚动环比增长 'inc_net_profit_to_shareholders_annual' #归属净利润滚动环比增长 'adjusted_profit_to_profit_annual' #扣非净利润滚动环比增长 'equity_roe' #加权净资产收益率 'net_roe' #摊薄净资产收益率 'total_roe' #摊薄总资产收益率 'gross_profit' #毛利率 'net_profit' #净利率 'actual_tax_rate' #实际税率 'pre_pay_operate_income' #预收款 / 营业收入 'sales_cash_flow' #销售现金流 / 营业收入 'gear_ratio' #资产负债比率 'inventory_turnover' #存货周转率 'm_anntime' #公告日 'm_timetag' #报告截止日 ``` -------------------------------- ### Download Index Weight Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads index constituent weight information synchronously. The function returns after the download is complete. This data is required to retrieve index weights using `get_index_weight`. ```python download_index_weight() ``` -------------------------------- ### Describing Contract Information Fields (Python) Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet provides a comprehensive list of fields available for querying and representing detailed contract information across various financial instruments. It includes identifiers, names, dates, pricing details, volume information, margin rates, and specific attributes for different asset types. ```python 'ExchangeID' #合约市场代码 'InstrumentID' #合约代码 'InstrumentName' #合约名称 'Abbreviation' #合约名称的拼音简写 'ProductID' #合约的品种ID(期货) 'ProductName' #合约的品种名称(期货) 'UnderlyingCode' #标的合约 'ExtendName' #扩位名称 'ExchangeCode' #交易所代码 'RzrkCode' #rzrk代码 'UniCode' #统一规则代码 'CreateDate' #上市日期(期货) 'OpenDate' #IPO日期(股票) 'ExpireDate' #退市日或者到期日 'PreClose' #前收盘价格 'SettlementPrice' #前结算价格 'UpStopPrice' #当日涨停价 'DownStopPrice' #当日跌停价 'FloatVolume' #流通股本 'TotalVolume' #总股本 'AccumulatedInterest' #自上市付息日起的累积未付利息额(债券) 'LongMarginRatio' #多头保证金率 'ShortMarginRatio' #空头保证金率 'PriceTick' #最小变价单位 'VolumeMultiple' #合约乘数(对期货以外的品种,默认是1) 'MainContract' #主力合约标记,1、2、3分别表示第一主力合约,第二主力合约,第三主力合约 'MaxMarketOrderVolume' #市价单最大下单量 'MinMarketOrderVolume' #市价单最小下单量 'MaxLimitOrderVolume' #限价单最大下单量 'MinLimitOrderVolume' #限价单最小下单量 'MaxMarginSideAlgorithm' #上期所大单边的处理算法 'DayCountFromIPO' #自IPO起经历的交易日总数 'LastVolume' #昨日持仓量 'InstrumentStatus' #合约停牌状态 'IsTrading' #合约是否可交易 'IsRecent' #是否是近月合约 'IsContinuous' #是否是连续合约 'bNotProfitable' #是否非盈利状态 'bDualClass' #是否同股不同权 'ContinueType' #连续合约类型 'secuCategory' #证券分类 'secuAttri' #证券属性 'MaxMarketSellOrderVolume' #市价卖单最大单笔下单量 'MinMarketSellOrderVolume' #市价卖单最小单笔下单量 'MaxLimitSellOrderVolume' #限价卖单最大单笔下单量 'MinLimitSellOrderVolume' #限价卖单最小单笔下单量 'MaxFixedBuyOrderVol' #盘后定价委托数量的上限(买) 'MinFixedBuyOrderVol' #盘后定价委托数量的下限(买) 'MaxFixedSellOrderVol' #盘后定价委托数量的上限(卖) 'MinFixedSellOrderVol' #盘后定价委托数量的下限(卖) 'HSGTFlag' #标识港股是否为沪港通或深港通标的证券。沪港通:0-非标的,1-标的,2-历史标的;深港通:0-非标的,3-标的,4-历史标的,5-是沪港通也是深港通 'BondParValue' #债券面值 'QualifiedType' #投资者适当性管理分类 'PriceTickType' #价差类别(港股用),1-股票,3-债券,4-期权,5-交易所买卖基金 'tradingStatus' #交易状态 'OptUnit' #期权合约单位 'MarginUnit' #期权单位保证金 'OptUndlCode' #期权标的证券代码或可转债正股标的证券代码 'OptUndlMarket' #期权标的证券市场或可转债正股标的证券市场 'OptLotSize' #期权整手数 'OptExercisePrice' #期权行权价或可转债转股价 'NeeqExeType' #全国股转转让类型,1-协议转让方式,2-做市转让方式,3-集合竞价+连续竞价转让方式(当前全国股转并未实现),4-集合竞价转让 'OptExchFixedMargin' #交易所期权合约保证金不变部分 'OptExchMiniMargin' #交易所期权合约最小保证金 'Ccy' #币种 'IbSecType' #IB安全类型,期货或股票 'OptUndlRiskFreeRate' #期权标的无风险利率 'OptUndlHistoryRate' #期权标的历史波动率 'EndDelivDate' #期权行权终止日 'RegisteredCapital' #注册资本(单位:百万) 'MaxOrderPriceRange' #最大有效申报范围 'MinOrderPriceRange' #最小有效申报范围 'VoteRightRatio' #同股同权比例 'm_nMinRepurchaseDaysLimit' #最小回购天数 'm_nMaxRepurchaseDaysLimit' #最大回购天数 'DeliveryYear' #交割年份 'DeliveryMonth' #交割月 'ContractType' #标识期权,1-过期,2-当月,3-下月,4-下季,5-隔季,6-隔下季 'ProductTradeQuota' #期货品种交易配额 'ContractTradeQuota' #期货合约交易配额 'ProductOpenInterestQuota' #期货品种持仓配额 'ContractOpenInterestQuota' #期货合约持仓配额 'ChargeType' #期货和期权手续费方式,0-未知,1-按元/手,2-按费率 'ChargeOpen' #开仓手续费率,-1表示没有 'ChargeClose' #平仓手续费率,-1表示没有 'ChargeTodayOpen' #开今仓(日内开仓)手续费率,-1表示没有 'ChargeTodayClose' #平今仓(日内平仓)手续费率,-1表示没有 'OptionType' #期权类型,-1为非期权,0为期权认购,1为期权认沽 'OpenInterestMultiple' #交割月持仓倍数 ``` -------------------------------- ### Download Historical Data (Batch) - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads or supplements historical market data for a list of stocks in batch, executing synchronously. Progress updates can be received via an optional callback function. The callback function receives a dictionary with download progress details. ```python download_history_data2(stock_list, period, start_time='', end_time='', callback=None) ``` -------------------------------- ### Download Sector Data - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Downloads sector classification information synchronously. The function returns after the download is complete. This data is required to retrieve sector lists and constituents. ```python download_sector_data() ``` -------------------------------- ### Describing Ex-Right Data Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists the field names for ex-right (dividend/split) data available through the xtquant API. It covers details like dividends, bonus shares, stock gifts, allotment specifics, and ex-right factors used in calculating adjusted prices. This data is essential for handling corporate actions in historical data analysis. ```python 'interest' #每股股利(税前,元) 'stockBonus' #每股红股(股) 'stockGift' #每股转增股本(股) 'allotNum' #每股配股数(股) 'allotPrice' #配股价格(元) 'gugai' #是否股改, 对于股改,在算复权系数时,系统有特殊算法 'dr' #除权系数 ``` -------------------------------- ### Performing Fund Transfer - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Initiates a fund transfer operation for the specified account. Requires the account details, the direction of the transfer, and the amount. ```python fund_transfer(account, transfer_direction, price) ``` -------------------------------- ### Create Sector - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Creates a sector node, optionally within a parent folder. Allows specifying whether to overwrite existing sectors with the same name. Returns the actual name of the created sector, which may include a numerical suffix if overwrite is False and the name exists. ```python create_sector(parent_node, sector_name, overwrite) ``` -------------------------------- ### Describing K-Line Data Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists the field names available for K-line data (1m, 5m, 1d intervals) provided by the xtquant API. It includes standard OHLCV data along with settlement price, open interest, previous close, and suspension flag. These fields are used to retrieve historical or real-time bar data. ```python 'time' #时间戳 'open' #开盘价 'high' #最高价 'low' #最低价 'close' #收盘价 'volume' #成交量 'amount' #成交额 'settelementPrice' #今结算 'openInterest' #持仓量 'preClose' #前收价 'suspendFlag' #停牌标记 0 - 正常 1 - 停牌 -1 - 当日起复牌 ``` -------------------------------- ### Describing Level2 Quote Auxiliary Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists supplementary field names for Level 2 real-time quote data from the xtquant API, focusing on aggregated bid/ask information. It includes average bid/offer prices, total bid/offer quantities, and quantities/amounts for withdrawn bid/offer orders. This provides insight into overall supply and demand pressure. ```python 'time' #时间戳 'avgBidPrice' #委买均价 'totalBidQuantity' #委买总量 'avgOffPrice' #委卖均价 'totalOffQuantity' #委卖总量 'withdrawBidQuantity' #买入撤单总量 'withdrawBidAmount' #买入撤单总额 'withdrawOffQuantity' #卖出撤单总量 'withdrawOffAmount' #卖出撤单总额 ``` -------------------------------- ### Querying Stock Orders - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Queries all orders placed on the current day for a specific stock account. Optionally filters to retrieve only cancelable orders. Returns a list of `XtOrder` objects or `None` if the query fails or the list is empty. ```python query_stock_orders(account, cancelable_only = False) ``` ```python account = StockAccount('1000000365') #xt_trader为XtQuant API实例对象 orders = xt_trader.query_stock_orders(account, False) ``` -------------------------------- ### Querying Stock Asset - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Queries the current asset information for a specific stock account. Returns an `XtAsset` object containing details like available balance, total assets, etc., or `None` if the query fails. ```python query_stock_asset(account) ``` ```python account = StockAccount('1000000365') #xt_trader为XtQuant API实例对象 asset = xt_trader.query_stock_asset(account) ``` -------------------------------- ### Describing Level2 Quote Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists the field names for Level 2 real-time quote snapshot data from the xtquant API. It provides detailed market depth information including latest price, OHLC, volume, amount, open interest, stock status, transaction count, various settlement/close prices, PE ratio, and multi-level bid/ask prices and volumes. This data is used for in-depth real-time market monitoring. ```python 'time' #时间戳 'lastPrice' #最新价 'open' #开盘价 'high' #最高价 'low' #最低价 'amount' #成交额 'volume' #成交总量 'pvolume' #原始成交总量 'openInt' #持仓量 'stockStatus' #证券状态 'transactionNum' #成交笔数 'lastClose' #前收盘价 'lastSettlementPrice' #前结算 'settlementPrice' #今结算 'pe' #市盈率 'askPrice' #多档委卖价 'bidPrice' #多档委买价 'askVol' #多档委卖量 'bidVol' #多档委买量 ``` -------------------------------- ### Describing Balance Sheet Fields - xtquant - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists field names for Balance Sheet data provided by the xtquant API. It includes a comprehensive set of asset, liability, and equity line items from corporate balance sheets. This data is used for fundamental analysis of a company's financial position. ```python 'm_anntime' #披露日期 'm_timetag' #截止日期 'internal_shoule_recv' #内部应收款 'fixed_capital_clearance' #固定资产清理 'should_pay_money' #应付分保账款 'settlement_payment' #结算备付金 'receivable_premium' #应收保费 'accounts_receivable_reinsurance' #应收分保账款 'reinsurance_contract_reserve' #应收分保合同准备金 'dividends_payable' #应收股利 'tax_rebate_for_export' #应收出口退税 'subsidies_receivable' #应收补贴款 'deposit_receivable' #应收保证金 'apportioned_cost' #待摊费用 'profit_and_current_assets_with_deal' #待处理流动资产损益 'current_assets_one_year' #一年内到期的非流动资产 'long_term_receivables' #长期应收款 'other_long_term_investments' #其他长期投资 'original_value_of_fixed_assets' #固定资产原值 'net_value_of_fixed_assets' #固定资产净值 'depreciation_reserves_of_fixed_assets' #固定资产减值准备 'productive_biological_assets' #生产性生物资产 'public_welfare_biological_assets' #公益性生物资产 'oil_and_gas_assets' #油气资产 'development_expenditure' #开发支出 'right_of_split_share_distribution' #股权分置流通权 'other_non_mobile_assets' #其他非流动资产 'handling_fee_and_commission' #应付手续费及佣金 'other_payables' #其他应交款 'margin_payable' #应付保证金 'internal_accounts_payable' #内部应付款 'advance_cost' #预提费用 'insurance_contract_reserve' #保险合同准备金 'broker_buying_and_selling_securities' #代理买卖证券款 'acting_underwriting_securities' #代理承销证券款 'international_ticket_settlement' #国际票证结算 'domestic_ticket_settlement' #国内票证结算 'deferred_income' #递延收益 'short_term_bonds_payable' #应付短期债券 'long_term_deferred_income' #长期递延收益 'undetermined_investment_losses' #未确定的投资损失 'quasi_distribution_of_cash_dividends' #拟分配现金股利 'provisions_not' #预计负债 'cust_bank_dep' #吸收存款及同业存放 'provisions' #预计流动负债 'less_tsy_stk' #减:库存股 'cash_equivalents' #货币资金 'loans_to_oth_banks' #拆出资金 'tradable_fin_assets' #交易性金融资产 'derivative_fin_assets' #衍生金融资产 'bill_receivable' #应收票据 'account_receivable' #应收账款 'advance_payment' #预付款项 'int_rcv' #应收利息 'other_receivable' #其他应收款 'red_monetary_cap_for_sale' #买入返售金融资产 'agency_bus_assets' #以公允价值计量且其变动计入当期损益的金融资产 'inventories' #存货 'other_current_assets' #其他流动资产 'total_current_assets' #流动资产合计 'loans_and_adv_granted' #发放贷款及垫款 'fin_assets_avail_for_sale' #可供出售金融资产 'held_to_mty_invest' #持有至到期投资 'long_term_eqy_invest' #长期股权投资 'invest_real_estate' #投资性房地产 'accumulated_depreciation' #累计折旧 'fix_assets' #固定资产 'constru_in_process' #在建工程 'construction_materials' #工程物资 'long_term_liabilities' #长期负债 'intang_assets' #无形资产 'goodwill' #商誉 'long_deferred_expense' #长期待摊费用 'deferred_tax_assets' #递延所得税资产 'total_non_current_assets' #非流动资产合计 'tot_assets' #资产总计 'shortterm_loan' #短期借款 'borrow_central_bank' #向中央银行借款 'loans_oth_banks' #拆入资金 'tradable_fin_liab' #交易性金融负债 'derivative_fin_liab' #衍生金融负债 'notes_payable' #应付票据 'accounts_payable' #应付账款 'advance_peceipts' #预收账款 'fund_sales_fin_assets_rp' #卖出回购金融资产款 'empl_ben_payable' #应付职工薪酬 'taxes_surcharges_payable' #应交税费 'int_payable' #应付利息 'dividend_payable' #应付股利 'other_payable' #其他应付款 'non_current_liability_in_one_year' #一年内到期的非流动负债 'other_current_liability' #其他流动负债 'total_current_liability' #流动负债合计 'long_term_loans' #长期借款 'bonds_payable' #应付债券 'longterm_account_payable' #长期应付款 'grants_received' #专项应付款 'deferred_tax_liab' #递延所得税负债 'other_non_current_liabilities' #其他非流动负债 'non_current_liabilities' #非流动负债合计 'tot_liab' #负债合计 'cap_stk' #实收资本(或股本) 'cap_rsrv' #资本公积 'specific_reserves' #专项储备 'surplus_rsrv' #盈余公积 'prov_nom_risks' #一般风险准备 'undistributed_profit' #未分配利润 'cnvd_diff_foreign_curr_stat' #外币报表折算差额 'tot_shrhldr_eqy_excl_min_int' #归属于母公司股东权益合计 'minority_int' #少数股东权益 'total_equity' #所有者权益合计 'tot_liab_shrhldr_eqy' #负债和股东权益总计 ``` -------------------------------- ### Describing TOP10HOLDER/TOP10FLOWHOLDER Fields (Python) Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md This snippet lists the key fields available for representing data related to a stock's top 10 shareholders and top 10 circulating shareholders. It includes identification details, quantity, ratio, type, and rank. ```python 'declareDate' #公告日期 'endDate' #截止日期 'name' #股东名称 'type' #股东类型 'quantity' #持股数量 'reason' #变动原因 'ratio' #持股比例 'nature' #股份性质 'rank' #持股排名 ``` -------------------------------- ### Asynchronous Stock Cancellation by System ID - XtQuant API - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xttrader.md Requests the asynchronous cancellation of a stock order using the contract number provided by the broker's system. Returns a positive integer seq for a successful request or -1 if the request failed. Feedback is provided via the cancellation failure push. ```python cancel_order_stock_sysid_async(account, market, order_sysid) ``` ```python account = StockAccount('1000000365') market = xtconstant.SH_MARKET order_sysid = "100" #xt_trader为XtQuant API实例对象 cancel_result = xt_trader.cancel_order_stock_sysid_async(account, market, order_sysid) ``` -------------------------------- ### Capital Structure Data Keys - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Lists Python string identifiers used to query or reference data points related to a company's capital structure, such as total shares and circulating shares, within the xtquant system. Each key is accompanied by its Chinese description. ```Python 'total_capital' #总股本 'circulating_capital' #已上市流通A股 'restrict_circulating_capital' #限售流通股份 'm_timetag' #报告截止日 'm_anntime' #公告日 ``` -------------------------------- ### Add Custom Sector - xtquant Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Adds a custom sector with a list of constituent stock codes. Creates a new sector or updates an existing one with the provided stocks. Note: The description in the source for `remove_stock_from_sector` seems to have copied the description for `create_sector`. ```python add_sector(sector_name, stock_list) ``` -------------------------------- ### Income Statement Data Keys - Python Source: https://github.com/jqbsoft/xtquant/blob/master/xtquant/doc/xtdata.md Lists Python string identifiers used to query or reference data points from a company's income statement within the xtquant system. Each key is accompanied by its Chinese description, indicating the specific financial metric it represents. ```Python 'm_anntime' #披露日期 'm_timetag' #截止日期 'revenue_inc' #营业收入 'earned_premium' #已赚保费 'real_estate_sales_income' #房地产销售收入 'total_operating_cost' #营业总成本 'real_estate_sales_cost' #房地产销售成本 'research_expenses' #研发费用 'surrender_value' #退保金 'net_payments' #赔付支出净额 'net_withdrawal_ins_con_res' #提取保险合同准备金净额 'policy_dividend_expenses' #保单红利支出 'reinsurance_cost' #分保费用 'change_income_fair_value' #公允价值变动收益 'futures_loss' #期货损益 'trust_income' #托管收益 'subsidize_revenue' #补贴收入 'other_business_profits' #其他业务利润 'net_profit_excl_merged_int_inc' #被合并方在合并前实现净利润 'int_inc' #利息收入 'handling_chrg_comm_inc' #手续费及佣金收入 'less_handling_chrg_comm_exp' #手续费及佣金支出 'other_bus_cost' #其他业务成本 'plus_net_gain_fx_trans' #汇兑收益 'il_net_loss_disp_noncur_asset' #非流动资产处置收益 'inc_tax' #所得税费用 'unconfirmed_invest_loss' #未确认投资损失 'net_profit_excl_min_int_inc' #归属于母公司所有者的净利润 'less_int_exp' #利息支出 'other_bus_inc' #其他业务收入 'revenue' #营业总收入 'total_expense' #营业成本 'less_taxes_surcharges_ops' #营业税金及附加 'sale_expense' #销售费用 'less_gerl_admin_exp' #管理费用 'financial_expense' #财务费用 'less_impair_loss_assets' #资产减值损失 'plus_net_invest_inc' #投资收益 'incl_inc_invest_assoc_jv_entp' #联营企业和合营企业的投资收益 'oper_profit' #营业利润 'plus_non_oper_rev' #营业外收入 'less_non_oper_exp' #营业外支出 'tot_profit' #利润总额 'net_profit_incl_min_int_inc' #净利润 'net_profit_incl_min_int_inc_after' #净利润(扣除非经常性损益后) 'minority_int_inc' #少数股东损益 's_fa_eps_basic' #基本每股收益 's_fa_eps_diluted' #稀释每股收益 'total_income' #综合收益总额 'total_income_minority' #归属于少数股东的综合收益总额 'other_compreh_inc' #其他收益 ```