Back to Registry
View Author Profile
Official Verified
myquant
掘金量化Python SDK - 事件驱动量化平台,支持A股、期货、期权、ETF、可转债回测与实盘交易。
skill-install — Terminal
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/coderwpf/myquantOr
掘金量化(MyQuant / GoldMiner)
掘金量化 是专业量化交易平台,提供事件驱动策略开发、回测、模拟交易和实盘交易。支持A股、期货、期权、ETF、可转债和融资融券,通过统一的Python SDK(gm.api)操作。
需要在 https://www.myquant.cn 注册获取Token进行认证。实盘交易需要通过掘金终端连接券商账户。
安装
pip install gm
也可从官网下载:https://www.myquant.cn/docs/downloads/698
架构概述
你的Python脚本(strategy.py)
↓ gm SDK(from gm.api import *)
├── 回测模式 → 掘金回测引擎(云端/本地)
├── 模拟交易 → 掘金模拟交易服务器
└── 实盘交易 → 掘金终端 → 券商网关
策略程序结构
所有策略遵循事件驱动架构,包含生命周期函数:
from gm.api import *
def init(context):
"""Initialization function — called once when the strategy starts, used to set up subscriptions and parameters"""
# Subscribe to 30-second bars for two stocks, keeping the most recent 5 historical bars
subscribe(symbols='SHSE.600000,SZSE.000001', frequency='30s', count=5)
context.my_param = 0.8 # Custom context attribute
def on_bar(context, bars):
"""Bar event — triggered at each bar close, write main trading logic here"""
bar = bars[0]
if bar['close'] > bar['open']:
# Close price above open price, place a limit buy order for 1000 shares
order_volume(symbol=bar['symbol'], volume=1000,
side=OrderSide_Buy, order_type=OrderType_Limit,
position_effect=PositionEffect_Open, price=bar['close'])
def on_tick(context, tick):
"""Tick event — triggered on each tick push (real-time mode)"""
print(tick['symbol'], tick['price'])
def on_order_status(context, order):
"""Order status event — triggered when order status changes"""
print(f"Order {order['cl_ord_id']}: status={order['status']}")
def on_execution_report(context, execrpt):
"""Execution report event — triggered on trade execution"""
print(f"Executed: {execrpt['symbol']} {execrpt['filled_volume']}@{execrpt['filled_vwap']}")
if __name__ == '__main__':
run(strategy_id='your_strategy_id',
filename='main.py',
mode=MODE_BACKTEST, # Run mode: backtest
token='your_token',
backtest_start_time='2024-01-01 09:30:00', # Backtest start time
backtest_end_time='2024-06-30 15:00:00', # Backtest end time
backtest_initial_cash=1000000, # Initial capital 1,000,000
backtest_commission_ratio=0.0003, # Commission rate 0.03%
backtest_slippage_ratio=0.001, # Slippage 0.1%
backtest_adjust=ADJUST_PREV) # 前复权
基本函数
init — 策略初始化
def init(context):
# Subscribe to daily bars, keeping the most recent 20
subscribe(symbols='SHSE.600000', frequency='1d', count=20)
context.ratio = 0.8 # Custom parameter
- 策略启动时调用一次
- 用于设置订阅、定义参数和初始化状态
- 回测模式下init中不允许下单(模拟/实盘模式允许)
schedule — 定时任务
Metadata
AI Skill Finder
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skill Add to Configuration
Paste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-coderwpf-myquant": {
"enabled": true,
"auto_update": true
}
}
}Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.
Related Skills
backtrader
Backtrader 开源量化回测框架 - 支持多数据源、多策略、多周期回测与实盘交易,纯Python实现。
coderwpf 3409
pywencai
同花顺问财自然语言数据查询工具 - 使用中文自然语言查询A股、指数、基金、港美股、可转债等市场数据。
coderwpf 3409
tqsdk
天勤量化TqSdk - 开源Python期货/期权交易SDK,提供实时行情、回测和实盘交易功能。
coderwpf 3409
rqalpha
RQAlpha 米筐开源事件驱动回测框架 - 支持A股和期货,模块化架构,可自由扩展。
coderwpf 3409
baostock
BaoStock 免费A股数据平台 - 支持K线、财务数据、行业分类查询,无需注册即可使用。
coderwpf 3409