🔑 认证与初始化

# 安装JoinQuant
pip install joinquant

# 导入SDK
from joinquant import api

# 初始化
api.login('username', 'password')

# 或者使用token
api.set_token('your_token')

📊 股票数据

接口 说明 示例
get_price() 获取行情数据 get_price('000001.XSHE', start_date='2024-01-01')
get_bars() 获取K线数据 get_bars('000001.XSHE', count=30)
get_current_data() 获取当前数据 get_current_data(['000001.XSHE'])
get_all_securities() 获取所有证券 get_all_securities(['stock'])
get_security_info() 获取证券信息 get_security_info('000001.XSHE')

🏢 财务数据

接口 说明 示例
get_fundamentals() 财务数据 get_fundamentals(query(valuation), date='2024-01-01')
get_indicator() 财务指标 get_indicator('000001.XSHE')
get_billboard_list() 龙虎榜 get_billboard_list(end_date='2024-01-01')
get_locked_shares() 限售股 get_locked_shares('000001.XSHE')
get_money_flow() 资金流向 get_money_flow('000001.XSHE')

💹 指数数据

接口 说明 示例
get_index_stocks() 指数成分股 get_index_stocks('000001.XSHG')
get_industry_stocks() 行业成分股 get_industry_stocks('医药生物')
get_concept_stocks() 概念成分股 get_concept_stocks('人工智能')
get_index_weights() 指数权重 get_index_weights('000300.XSHG')

📈 技术指标

接口 说明 示例
MA() 移动平均 MA(price, 20)
EMA() 指数移动平均 EMA(price, 12)
MACD() MACD指标 MACD(price, 12, 26, 9)
RSI() 相对强弱指标 RSI(price, 14)
BOLL() 布林带 BOLL(price, 20)
KDJ() KDJ指标 KDJ(price)

🔄 交易函数

接口 说明 示例
order() 下单 order('000001.XSHE', 100)
order_value() 按金额下单 order_value('000001.XSHE', 10000)
order_percent() 按比例下单 order_percent('000001.XSHE', 0.1)
order_target() 调整到目标持仓 order_target('000001.XSHE', 1000)
order_target_percent() 调整到目标比例 order_target_percent('000001.XSHE', 0.5)
cancel_order() 撤单 cancel_order(order_id)

📊 账户信息

接口 说明 示例
get_account() 账户信息 get_account()
get_orders() 订单信息 get_orders()
get_open_orders() 未完成订单 get_open_orders()
get_positions() 持仓信息 get_positions()
context.portfolio 组合信息 context.portfolio

调度函数

接口 说明 示例
schedule_function() 定时任务 schedule_function(rebalance, time_rule=time_rules.market_close())
time_rules 时间规则 time_rules.market_open(hours=1)
date_rules 日期规则 date_rules.every_day()
⚠️
使用限制

聚宽API需要在聚宽平台上运行。回测和实盘环境有差异, 注意数据延迟和交易限制。部分高级功能需要付费会员。