Runtime API Examples
This page demonstrates usage of some of the runtime APIs provided by VitePress.
The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:
md
<script setup>
import { useData } from 'vitepress'
const { theme, page, frontmatter } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Results
Theme Data
{
"logo": "/pbnz-icon.png",
"siteTitle": "ib俱乐部",
"outline": [
2,
4
],
"outlineTitle": "目录",
"nav": [
{
"text": "IB教程",
"link": "/ibkr-guide/ib-content"
}
],
"sidebar": {
"/ibkr-guide": [
{
"text": "开户、软件下载、出入金",
"collapsed": true,
"items": [
{
"text": "开户相关",
"collapsed": true,
"items": [
{
"text": "开户须知",
"link": "/ibkr-guide/getting-started/account-opening-guide"
},
{
"text": "经纪商专属开户流程",
"link": "/ibkr-guide/getting-started/referral-account-opening"
},
{
"text": "IB官网推荐链接开户流程",
"link": "/ibkr-guide/getting-started/official-account-opening"
},
{
"text": "通过经纪商重置密码",
"link": "/ibkr-guide/getting-started/broker-reset-password"
},
{
"text": "IB官网自助重置密码",
"link": "/ibkr-guide/getting-started/official-reset-password"
}
]
},
{
"text": "软件下载",
"collapsed": true,
"items": [
{
"text": "电脑TWS下载",
"link": "/ibkr-guide/setup-and-login/tws-download"
},
{
"text": "手机APP下载",
"link": "/ibkr-guide/setup-and-login/download-ibkr-mobile"
},
{
"text": "绑定IB KEY安全令牌",
"link": "/ibkr-guide/setup-and-login/ib-key-setup"
},
{
"text": "登录相关问题",
"link": "/ibkr-guide/setup-and-login/login-troubleshooting"
}
]
},
{
"text": "出入金、转仓",
"collapsed": true,
"items": [
{
"text": "出入金注意事项",
"link": "/ibkr-guide/funding/deposit-withdrawal-rules"
},
{
"text": "出入金流程",
"link": "/ibkr-guide/funding/deposit-withdrawal-guide"
},
{
"text": "股票转仓",
"link": "/ibkr-guide/funding/transfer-positions"
},
{
"text": "IB内部转账",
"link": "/ibkr-guide/funding/internal-transfer"
},
{
"text": "货币兑换(电脑)",
"link": "/ibkr-guide/funding/forex-conversion"
},
{
"text": "货币兑换(APP)",
"link": "/ibkr-guide/funding/mobile-forex-conversion"
},
{
"text": "其他收费",
"link": "/ibkr-guide/funding/fees-commissions"
}
]
}
]
},
{
"text": "交易相关",
"collapsed": true,
"items": [
{
"text": "交易前准备",
"collapsed": true,
"items": [
{
"text": "账户类型",
"link": "/ibkr-guide/pre-trading-setup/account-types"
},
{
"text": "模拟交易账户",
"link": "/ibkr-guide/pre-trading-setup/paper-trading"
},
{
"text": "申请交易权限",
"link": "/ibkr-guide/pre-trading-setup/trading-permissions"
},
{
"text": "订阅实时行情",
"link": "/ibkr-guide/pre-trading-setup/market-data-subscription"
},
{
"text": "如何搜索代码",
"link": "/ibkr-guide/pre-trading-setup/search-ticker-symbols"
},
{
"text": "盘前盘后交易时段",
"link": "/ibkr-guide/pre-trading-setup/extended-hours-trading"
},
{
"text": "盘前盘后K线图",
"link": "/ibkr-guide/pre-trading-setup/extended-hours-charts"
}
]
},
{
"text": "开始交易",
"collapsed": true,
"items": [
{
"text": "下单、查看挂单、查询成交",
"link": "/ibkr-guide/trading-basics/placing-orders"
},
{
"text": "平仓、查看盈亏",
"link": "/ibkr-guide/trading-basics/close-positions-check-pnl"
},
{
"text": "止盈止损单",
"link": "/ibkr-guide/trading-basics/stop-loss-take-profit"
},
{
"text": "预设交易参数",
"link": "/ibkr-guide/trading-basics/order-presets"
},
{
"text": "云条件单",
"link": "/ibkr-guide/trading-basics/cloud-orders"
},
{
"text": "一键下单",
"link": "/ibkr-guide/trading-basics/trading-hotkeys"
}
]
},
{
"text": "进阶交易",
"collapsed": true,
"items": [
{
"text": "账户指标",
"link": "/ibkr-guide/advanced-trading/account-window-balances"
},
{
"text": "常用定单类型",
"link": "/ibkr-guide/advanced-trading/common-order-types"
},
{
"text": "定单颜色和状态",
"link": "/ibkr-guide/advanced-trading/order-status-colors"
},
{
"text": "股票日内交易",
"link": "/ibkr-guide/advanced-trading/pattern-day-trader-rule"
},
{
"text": "强平、杠杆、融资",
"link": "/ibkr-guide/advanced-trading/margin-leverage-liquidation"
},
{
"text": "股票做空",
"link": "/ibkr-guide/advanced-trading/how-to-short-stocks"
},
{
"text": "跨币种交易",
"link": "/ibkr-guide/advanced-trading/auto-currency-conversion-vs-margin"
}
]
}
]
},
{
"text": "美股相关",
"collapsed": true,
"items": [
{
"text": "美股基础知识",
"link": "/ibkr-guide/us-stocks/us-stock-market-basics"
},
{
"text": "美股实时行情",
"link": "/ibkr-guide/us-stocks/real-time-market-data"
},
{
"text": "美股T+1结算",
"link": "/ibkr-guide/us-stocks/t-1-settlement"
},
{
"text": "美股夜盘交易",
"link": "/ibkr-guide/us-stocks/us-overnight-trading-hours"
},
{
"text": "美股碎股、小数股交易",
"link": "/ibkr-guide/us-stocks/fractional-shares"
},
{
"text": "股票收益增强计划",
"link": "/ibkr-guide/us-stocks/stock-yield-enhancement-program"
},
{
"text": "如何定投美股",
"link": "/ibkr-guide/us-stocks/recurring-investment"
},
{
"text": "美股退市、合股与拆股等公司行动",
"link": "/ibkr-guide/us-stocks/corporate-actions-splits"
}
]
},
{
"text": "港股相关",
"collapsed": true,
"items": [
{
"text": "港股基础知识",
"link": "/ibkr-guide/hk-stocks/hk-stock-market-basics"
},
{
"text": "港股交易税费",
"link": "/ibkr-guide/hk-stocks/trading-fees-stamp-duty"
},
{
"text": "港股实时行情订阅",
"link": "/ibkr-guide/hk-stocks/real-time-market-data"
},
{
"text": "港股打新流程",
"link": "/ibkr-guide/hk-stocks/hk-ipo-subscription"
},
{
"text": "港股开盘集合竞价单",
"link": "/ibkr-guide/hk-stocks/pre-opening-session-order"
},
{
"text": "港股碎股交易",
"link": "/ibkr-guide/hk-stocks/odd-lots-trading"
},
{
"text": "港股北向交易",
"link": "/ibkr-guide/hk-stocks/stock-connect-northbound"
}
]
},
{
"text": "期权涡轮权证",
"collapsed": true,
"items": [
{
"text": "期权交易权限申请与测试题指南",
"link": "/ibkr-guide/options-warrants/options-trading-permissions"
},
{
"text": "期权实时行情订阅",
"link": "/ibkr-guide/options-warrants/options-market-data-opra"
},
{
"text": "T型期权报价界面使用介绍",
"link": "/ibkr-guide/options-warrants/optiontrader-chain-guide"
},
{
"text": "组合期权与策略构建器",
"link": "/ibkr-guide/options-warrants/strategy-builder-multi-leg"
},
{
"text": "期权保证金规则与末日轮强平机制",
"link": "/ibkr-guide/options-warrants/options-margin-liquidation"
},
{
"text": "美股期权交易、行权与指派",
"link": "/ibkr-guide/options-warrants/options-exercise-assignment"
},
{
"text": "港股涡轮、权证交易",
"link": "/ibkr-guide/options-warrants/hk-warrants-cbbc"
}
]
},
{
"text": "期货相关",
"collapsed": true,
"items": [
{
"text": "期货代码一览",
"link": "/ibkr-guide/futures/futures-symbols-list"
},
{
"text": "期货实时数据订阅",
"link": "/ibkr-guide/futures/real-time-market-data"
},
{
"text": "微型和迷你股指期货",
"link": "/ibkr-guide/futures/micro-emini-index-futures"
},
{
"text": "IB期货保证金规则与强平制度",
"link": "/ibkr-guide/futures/margin-requirements-liquidation"
},
{
"text": "期货换月、展期与交割",
"link": "/ibkr-guide/futures/rollover-and-delivery"
},
{
"text": "期货跨币种结算",
"link": "/ibkr-guide/futures/cross-currency-settlement"
},
{
"text": "期货常见问题",
"link": "/ibkr-guide/futures/futures-faq"
}
]
},
{
"text": "债券相关",
"collapsed": true,
"items": [
{
"text": "债券搜索工具使用教程",
"link": "/ibkr-guide/bonds/bond-search-scanner"
},
{
"text": "到期收益率(YTM)与面值",
"link": "/ibkr-guide/bonds/yield-to-maturity-pricing)"
},
{
"text": "应计利息详解",
"link": "/ibkr-guide/bonds/accrued-interest-explained"
},
{
"text": "美债自动展期设置指南",
"link": "/ibkr-guide/bonds/treasuries-auto-roll"
},
{
"text": "银行大额存单购买指南",
"link": "/ibkr-guide/bonds/brokered-certificates-of-deposit"
},
{
"text": "美国国债",
"link": "/ibkr-guide/bonds/us-treasuries"
},
{
"text": "公司债券",
"link": "/ibkr-guide/bonds/corporate-bonds"
},
{
"text": "国债ETF介绍",
"link": "/ibkr-guide/bonds/us-treasuries-etf"
}
]
},
{
"text": "杠杆外汇相关",
"collapsed": true,
"items": [
{
"text": "IB杠杆外汇简介",
"link": "ibkr-guide/forex/forex-trading-idealpro"
},
{
"text": "虚拟外汇头寸介绍",
"link": "/ibkr-guide/forex/virtual-fx-position"
},
{
"text": "杠杆外汇交易与差价合约",
"link": "/ibkr-guide/forex/leveraged-forex-cfd-trading"
},
{
"text": "外汇隔夜利息与基准利率",
"link": "/ibkr-guide/forex/forex-overnight-interest-swap"
}
]
},
{
"text": "账户设置",
"collapsed": true,
"items": [
{
"text": "修改密码、邮箱、手机号码",
"link": "/ibkr-guide/account-management/update-email-phone-password"
},
{
"text": "修改账户基础货币",
"link": "/ibkr-guide/account-management/change-base-currency"
},
{
"text": "升级、降级账户类型",
"link": "/ibkr-guide/account-management/change-account-type"
}
]
},
{
"text": "账单与报表",
"collapsed": true,
"items": [
{
"text": "非美国(含中国大陆)居民股息税",
"link": "/ibkr-guide/reports-and-taxes/dividend-withholding-tax"
},
{
"text": "8BEN表格更新指南",
"link": "/ibkr-guide/reports-and-taxes/w8ben-form-renewal"
},
{
"text": "如何下载对账单",
"link": "/ibkr-guide/reports-and-taxes/download-account-statements"
},
{
"text": "如何看账户投资组合",
"link": "/ibkr-guide/reports-and-taxes/portfolio-analyst-guide"
}
]
},
{
"text": "量化交易",
"collapsed": true,
"items": [
{
"text": "IBKR API 接口简介",
"link": "/ibkr-guide/api-and-algo/ibkr-api-introduction"
}
]
},
{
"text": "经纪商介绍",
"collapsed": true,
"items": [
{
"text": "什么是介绍经纪商",
"link": "/ibkr-guide/introducing-brokers/what-is-introducing-broker"
},
{
"text": "检查账户是否了绑定经纪商",
"link": "/ibkr-guide/introducing-brokers/check-linked-broker"
},
{
"text": "绑定经纪商",
"link": "/ibkr-guide/introducing-brokers/link-introducing-broker"
},
{
"text": "转换经纪商",
"link": "/ibkr-guide/introducing-brokers/change-introducing-broker"
},
{
"text": "解绑经纪商",
"link": "/ibkr-guide/introducing-brokers/delink-introducing-broker"
}
]
},
{
"text": "其他",
"collapsed": true,
"items": [
{
"text": "大额存款保险",
"link": "/ibkr-guide/others/insured-bank-deposit-sweep"
},
{
"text": "ib推荐人计划",
"link": "/ibkr-guide/others/ibkr-referral-program"
}
]
}
]
},
"lastUpdatedText": "更新于",
"docFooter": {
"prev": "上一篇",
"next": "下一篇"
},
"socialLinks": [
{
"icon": {
"svg": "<svg viewBox=\"0 0 64 30\" fill=\"#1772F6\" width=\"52\" height=\"24.375\"><path d=\"M29.05 4.582H16.733V25.94h3.018l.403 2.572 4.081-2.572h4.815V4.582zm-5.207 18.69l-2.396 1.509-.235-1.508h-1.724V7.233h6.78v16.04h-2.425zM14.46 14.191H9.982c0-.471.033-.954.039-1.458v-5.5h5.106V5.935a1.352 1.352 0 0 0-.404-.957 1.378 1.378 0 0 0-.968-.396H5.783c.028-.088.056-.177.084-.255.274-.82 1.153-3.326 1.153-3.326a4.262 4.262 0 0 0-2.413.698c-.57.4-.912.682-1.371 1.946-.532 1.453-.997 2.856-1.31 3.693C1.444 8.674.28 11.025.28 11.025a5.85 5.85 0 0 0 2.52-.61c1.119-.593 1.679-1.502 2.054-2.883l.09-.3h2.334v5.5c0 .5-.045.982-.073 1.46h-4.12c-.71 0-1.39.278-1.893.775a2.638 2.638 0 0 0-.783 1.874h6.527a17.717 17.717 0 0 1-.778 3.649 16.796 16.796 0 0 1-3.012 5.273A33.104 33.104 0 0 1 0 28.74s3.13 1.175 5.425-.954c1.388-1.292 2.631-3.814 3.23-5.727a28.09 28.09 0 0 0 1.12-5.229h5.967v-1.37a1.254 1.254 0 0 0-.373-.899 1.279 1.279 0 0 0-.909-.37z\"></path><path d=\"M11.27 19.675l-2.312 1.491 5.038 7.458a6.905 6.905 0 0 0 .672-2.218 3.15 3.15 0 0 0-.28-2.168l-3.118-4.563zM51.449 15.195V5.842c4.181-.205 7.988-.405 9.438-.483l.851-.05c.387-.399.885-2.395.689-3.021-.073-.25-.213-.666-.638-.555a33.279 33.279 0 0 1-4.277.727c-2.766.321-3.97.404-7.804.682-6.718.487-12.709.72-12.709.72a2.518 2.518 0 0 0 .788 1.834 2.567 2.567 0 0 0 1.883.706c2.278-.095 5.598-.25 8.996-.41v9.203h-12.78c0 .703.281 1.377.783 1.874a2.69 2.69 0 0 0 1.892.777h10.105v7.075c0 .887-.464 1.192-1.231 1.214h-3.92a4.15 4.15 0 0 0 .837 1.544 4.2 4.2 0 0 0 1.403 1.067 6.215 6.215 0 0 0 2.71.277c1.36-.066 2.967-.826 2.967-3.57v-7.607h11.28c.342 0 .67-.135.91-.374.242-.239.378-.563.378-.902v-1.375H51.449z\"></path><path d=\"M42.614 8.873a2.304 2.304 0 0 0-1.508-.926 2.334 2.334 0 0 0-1.727.405l-.376.272 4.255 5.85 2.24-1.62-2.884-3.98zM57.35 8.68l-3.125 4.097 2.24 1.663 4.517-5.927-.375-.277a2.32 2.32 0 0 0-1.722-.452 2.327 2.327 0 0 0-1.536.896z\"></path></svg>"
},
"link": "https://www.zhihu.com/people/peter-pbnz"
}
],
"footer": {
"message": "",
"copyright": "ib俱乐部 @ 2017 - 2026"
},
"returnToTopLabel": "回到顶部",
"search": {
"provider": "local"
},
"externalLinkIcon": true,
"notFound": {
"title": "页面不存在",
"quote": "很抱歉,当前页面不存在,请联系网站管理员,或加载其他页面",
"linkLabel": "回到首页",
"linkText": "回到首页",
"code": "404"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1712845137000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.