← 返回 Skills 市场
328
总下载
0
收藏
0
当前安装
4
版本数
在 OpenClaw 中安装
/install irs-strategist
功能描述
This skill should be used when the user needs to write, review, or debug trading strategies using the IRS (SunnyQuant Investment Research System) framework....
使用说明 (SKILL.md)
\r \r
IRS Strategy Development Skill\r
\r IRS(开发代号 SunnyQuant)是一个基于 C#/.NET 的量化投研系统,支持策略编写、回测(IRS.Lab)和实盘交易(IRS.Trader)。\r \r
适用场景\r
\r
- 用户需要编写新的交易策略,或修改现有策略。\r
- 用户需要调试策略代码,解决编译错误或运行时错误。\r
- 用户需要进行回测或模拟交易,以验证策略的有效性。\r \r
项目结构\r
\r
使用 dotnet new irs -n MyStrategy 创建新策略项目,结构如下:\r
\r
MyStrategy/\r
├── MyStrategy/ # 策略代码(核心,在此编写策略)\r
│ ├── MyStrategy.cs\r
│ └── MyStrategy.csproj\r
├── MyStrategy.Lab/ # 回测项目(WinForm UI,Windows专用)\r
├── MyStrategy.Lab.Xplat/ # 回测项目(Blazor UI,跨平台)\r
├── MyStrategy.Lab.Console/ # 回测控制台(无UI,跨平台)\r
├── MyStrategy.Trader/ # 实盘/模拟交易项目\r
└── Directory.Packages.props # 升级IRS版本在此修改 \x3CIRSVersion>\r
```\r
\r
> 如果用户的环境没有dotnet sdk,请引导用户安装最新版的 .NET SDK(https://dotnet.microsoft.com/download)\r
> 没有特殊说明的时候,推荐用户使用`Jetbrains Rider`打开`MyStrategy.sln`进行后续的开发,如果用户未安装`Jetbrains Rider`,提示用户安装`Jetbrains Rider`。\r
> 如果提示没有安装irs模板,可以通过下面命令安装`dotnet new install SGD.InvestorResearchSystem --nuget-source https://nuget.shengguanda.com/v3/index.json --force`. 如果提示nuget.shengguanda.com访问失败,则提示用户,该模板需要访问盛冠达内网才可以访问。\r
\r
## 启动策略\r
\r
如果用户只想查看回测结果,你可以询问用户必要的参数(回测起止日期),修改 `MyStrategy.Lab.Console` 项目的启动参数,启动该项目,回测结果会输出在控制台。其他参数比如开收盘时间,多账号多币种配置等,你可以根据策略的需要自行添加,拿不准的可以询问用户。\r
\r
如果用户想要自己启动回测或者是模拟交易,你可以引导用户运行 `MyStrategy.Lab.Xplat` 或 `MyStrategy.Trader` 项目,并提供用户相关的问题解答。\r
\r
## 策略生命周期\r
\r
所有策略继承 `CommonStrategy`,运行流程:\r
\r
```\r
Init → BeforeTrading → OnQuoteArrive/OnCandleArrive → AfterTrading → AfterSettlement → (循环) → Finished\r
```\r
\r
| 回调方法 | 触发时机 | 关键说明 |\r
|---------|---------|---------|\r
| `Init()` / `InitAsync()` | 整个运行期只调用一次 | 初始化变量、获取准备数据 |\r
| `BeforeTrading()` | 每交易日开始前调用一次 | **必须在此订阅行情**(订阅每日清空) |\r
| `OnQuoteArrive(QuoteData q, bool outDated)` | Tick 数据到达时 | `outDated=true` 表示盘中重启补推的历史数据 |\r
| `OnCandleArrive(Instrument, CandleType, CandleData, bool outDated)` | K线数据到达时 | 同上,用 `outDated` 区分历史与实时 |\r
| `AfterTrading()` | 每日交易结束后(结算前) | 可查当日交易记录、持仓 |\r
| `AfterSettlement()` | 结算完成后 | 分红配股校准后数据 |\r
| `Finished()` | 策略运行结束 | 释放资源 |\r
\r
> `IsTest` 属性:`true` = 回测模式,`false` = 实盘/模拟(两者无法区分)\r
\r
## 行情订阅\r
\r
```csharp\r
// 在 BeforeTrading 中订阅\r
SubMarketData(Instrument.FromCode("000300.SSE")); // Tick\r
SubCandleData(Instrument.FromCode("000300.SSE"), CandleType.Minute); // K线\r
\r
// 接收 Tick\r
public override void OnQuoteArrive(QuoteData q, bool outDated) { }\r
\r
// 接收 K线\r
public override void OnCandleArrive(Instrument instrument, CandleType type, CandleData candle, bool outDated) { }\r
```\r
\r
**Instrument 创建**:\r
\r
所有可以交易的标的都可以通过 `Instrument.FromCode("代码")` 创建,代码格式为 `证券代码.交易所后缀`,如 `000300.SSE`(沪深300)。港股代码后缀为 `.HKEX`,如 `00019.HKEX`。期货代码通常不带后缀,如 `IF2307`。\r
\r
```csharp\r
var stock = Instrument.FromCode("000300.SSE");\r
var future = Instrument.FromCode("IF2307");\r
var hk = Instrument.HKEX("00019");\r
```\r
\r
**历史数据查询**(一般不需要查当日):\r
\r
```csharp\r
var ticks = DataUtils.GetTicks(PreTradingDay, Instrument.FromCode("000300.SSE"));\r
var candles = DataUtils.GetCandles(Instrument.FromCode("000300.SSE"), CandleType.Minute, PreTradingDay, PreTradingDay);\r
```\r
\r
## 算法下单\r
\r
所有下单均通过算法单(AlgoOrder)完成。必须在策略类上添加对应的 `[UseXxxAlgo]` 特性标记。\r
\r
详细算法用法见 `references/algorithms.md`。\r
\r
### 下单流程回调\r
\r
```csharp\r
public override void OnCreateAlgoOrder(AlgoOrder algoOrder) { /* 算法单是否被接受 */ }\r
public override void OnRtnAlgoOrder(AlgoOrder algoOrder) { /* 算法单状态更新 */ }\r
public override void OnRtnSubOrder(SubOrderInfo subOrder) { /* 子单委托回报 */ }\r
public override void OnRtnSubOrderTrade(SubOrderTrade trade) { /* 子单成交回报 */ }\r
```\r
\r
### 资金与持仓\r
\r
```csharp\r
// 资金(异步,不要频繁调用)\r
var asset = await this.GetAssetsAsync(Accounts[0].AccountId);\r
\r
// 持仓(内存操作,可频繁调用)\r
var posVol = this.GetPositionVolume(accountId, code);\r
var pos = GetPositions(accountId, code);\r
// pos.TodayLong / TodayShort / HistoryLong / HistoryShort / TotalShort\r
\r
// 最小变动价位\r
var tickPrice = GetTickPrice("IF2106");\r
```\r
\r
## 策略参数(回测参数调优)\r
\r
```csharp\r
[RangeParams\x3Cint>(Name = "MA周期", Begin = 5, End = 30, Step = 5)]\r
public int MaPeriod { get; set; }\r
\r
[RangeParams\x3Cdouble>(Name = "止损比例", Begin = 0.01, End = 0.05, Step = 0.01)]\r
public double StopLoss { get; set; }\r
\r
[ValueListParams\x3Cstring>(Name = "合约", ValueList = new[] { "IF", "IH", "IC" })]\r
public string ContractType { get; set; } = "IF";\r
\r
[MultiplierParams\x3Clong>(Name = "等比参数", Begin = 1, End = 100, Multiplier = 2)]\r
public long Param { get; set; }\r
\r
[EnumParams\x3CTradeType>(Name = "交易类型")]\r
public TradeType Type { get; set; }\r
```\r
\r
## 定时任务\r
\r
```csharp\r
public override void BeforeTrading()\r
{\r
this.AddTimerTask("换仓", TradingDay.AddHours(9), () =>\r
{\r
// 到时间执行\r
}, cancellationToken);\r
}\r
```\r
\r
> 注意:定时任务收盘后未执行将被取消;如果策略盘中重启,需要自行判断是否补下订单。\r
\r
## K线指标(Stock.Indicators)\r
\r
```csharp\r
List\x3CCandleData> _candles = new();\r
\r
// 在 OnCandleArrive 中积累数据\r
_candles.Add(candle);\r
\r
var sma10 = _candles.GetSma(10).ToArray();\r
var latestMa10 = sma10[^1].Sma; // 最新值在最后\r
\r
var macd = _candles.GetMacd().ToArray();\r
var kdj = _candles.GetStoch();\r
var rsi = _candles.GetRsi();\r
// 更多:https://dotnet.stockindicators.dev/indicators/\r
```\r
\r
> `GetSma()` 结果正向排列,最新在 `[^1]`。注意边界:N个K线计算MA(N)只有1个结果。\r
\r
## 图表可视化\r
\r
```csharp\r
// 全局图(整个运行期数据在一张图)\r
Executor.GetOrAddGraph("每日资金").PutPoint("收益", TradingDay, value);\r
\r
// 日内图(每日清空)\r
Executor.GetOrAddDailyGraph("日内价差").PutPoint("价差", time, value);\r
\r
// K线图\r
Executor.GetOrAddGraph("Main").PutCandle(candle);\r
\r
// 副图(如MACD)\r
Executor.GetOrAddGraph("Main").GetSubGraph("MACD").PutPoint("MACD", candle.BeginTime, macdValue, color: Color.Blue);\r
Executor.GetOrAddGraph("Main").GetSubGraph("MACD").PutPoint("Histogram", candle.BeginTime, histVal, histogram: true);\r
\r
// 标记箭头\r
Executor.GetOrAddGraph("Main").GetSubGraph("MACD").PutMarker(candle.BeginTime, upArrow: true);\r
```\r
\r
## 多账号策略\r
\r
启动策略的时候,可以为不同的账号添加标签,以便标记该账号的功能,然后在策略中通过标签获取账号ID,进行数据隔离和差异化处理。\r
\r
```csharp\r
public override void Init()\r
{\r
var futureAccountId = Accounts.FirstOrDefault(o => o.Tag.Contains("Future"))?.AccountId\r
?? throw new Exception("no future account");\r
var stockAccountId = Accounts.FirstOrDefault(o => o.Tag.Contains("Stock"))?.AccountId\r
?? throw new Exception("no stock account");\r
}\r
```\r
\r
## 子策略(SubStrategy)\r
\r
将多个策略组合为父子结构,子策略数据独立隔离(持仓、委托、行情),但共享资金。这个功能属于高级功能,在用户明确要求的情况下使用。\r
\r
```csharp\r
// 父策略\r
[UseSubOrderAlgo]\r
[UseChasingAlgo]\r
public class ParentStrategy : CommonStrategy\r
{\r
public override void Init()\r
{\r
AddSubStrategy\x3CSubA>("label_a");\r
AddSubStrategy\x3CSubB>("label_b", x => { x.SomeParam = 123; });\r
}\r
}\r
\r
// 子策略\r
[UseChasingAlgo]\r
public class SubA : CommonStrategy { /* 与普通策略写法一致 */ }\r
```\r
\r
> - 父策略需标记所有子策略使用的算法特性\r
> - 子策略只支持一级嵌套\r
> - 避免多个子策略交易同一标的(会导致开平逻辑复杂)\r
\r
## 策略标签(StrategyLabel)\r
\r
用于多策略共用同一账号时隔离数据,这个功能通常在实盘下有用,在回测中通常不需要使用。\r
\r
```csharp\r
// 下单时自动带上策略标签\r
// 获取策略资金\r
var asset = GetStrategyAsset(MainAccountId);\r
var preBalance = Accounts.First(x => x.AccountId == MainAccountId).GetPreBalance();\r
\r
// 禁用标签过滤(查全账号数据)\r
public override void Init() { DisableFilterDataByStrategyLabel = true; }\r
\r
// 为其他策略标签下单\r
this.BuyOpen(code, vol, price,\r
customProperties: new Dictionary\x3Cstring, string>() { [CustomProperty.StrategyLabel] = otherLabel });\r
```\r
\r
## 数据获取\r
\r
IRS 使用两类数据源:**147基础数据**(行情核心)**聚源数据库**(研究用基本面/合约信息)。\r
\r
完整的数据获取文档详见 `references/data.md`,以下为常用速查。\r
\r
### 历史行情(DataUtils)\r
\r
```csharp\r
// Tick 历史(一般不查当日)\r
var ticks = DataUtils.GetTicks(PreTradingDay, Instrument.FromCode("000300.SSE"));\r
\r
// K线历史\r
var candles = DataUtils.GetCandles(\r
Instrument.FromCode("000300.SSE"), CandleType.Minute, PreTradingDay, PreTradingDay);\r
\r
// 日线\r
var daily = GetDailyData(PreTradingDay, Instrument.FromCode("000300.SSE"));\r
// daily.Candle.Open/High/Low/Close, daily.UpperLimit, daily.LowerLimit\r
```\r
\r
### 主力合约\r
\r
```csharp\r
// 获取某品种某天的主力合约代码\r
var mains = DataUtils.GetMainContracts(PreTradingDay, "IF");\r
// mains[0] => "IF2503"\r
```\r
\r
### 交易日历\r
\r
```csharp\r
bool isTrading = IsTradingDay(someDate); // 按策略当前日历\r
DateTime[] days = CommonStrategy.GetTradingDays(startDate, endDate);\r
```\r
\r
### 汇率\r
\r
```csharp\r
// 查人民币汇率\r
CurrencyRateManager.Default.TryGetRate("HKD",Date, out double rate);\r
\r
// 回测时设置临时汇率\r
CurrencyRateManager.Default.SetTempFixedRate("HKD", 0.92);\r
\r
\r
```\r
\r
### 分红送股\r
\r
```csharp\r
// 获取分红序列(用于除权处理),来源:factor/bonus.csv\r
var dividends = GetStockDividend(Instrument.FromCode("000001.SZSE"));\r
\r
// 当日实际发生的分红在 AfterSettlement 中获取\r
// dailyInfo.AccountDailyInfos[MainAccountId].StockCashDividend / StockDividend / StockExtension\r
// 注意:所有行情数据均为未除权数据\r
```\r
\r
### ETF申赎\r
\r
```csharp\r
// 获取ETF成分清单\r
var components = DataUtils.GetEtfComponentInfos(Instrument.FromCode("588030"), PreTradingDay);\r
// 获取申赎参数\r
var purRedInfo = DataUtils.GetEtfPurRedInfo(Instrument.FromCode("588030"), PreTradingDay);\r
\r
// 聚源查成分清单细节(MF_ETFPRComponents)\r
// 含现金替代标志(1-允许/2-必须/3-禁止/4-退补)、替代金额、溢/折价比例等\r
```\r
\r
### 停牌\r
\r
```csharp\r
if (Instrument.FromCode("600036").IsSuspend(PreTradingDay)) { /* 停牌 */ }\r
// 数据来源:聚源 LC_SuspendResumption 表\r
```\r
\r
### 数据库访问(FreeSql)\r
\r
```csharp\r
// 聚源数据(通用写法)\r
var data = IRS.Common.DataBase.SqlHelper.JYDB\r
.Select\x3CIRS.Common.DataBase.JYDB.FutContractMain>()\r
.Where(o => o.ContractCode.StartsWith("IF"))\r
.OrderBy(o => o.DeliveryDate)\r
.ToList();\r
```\r
\r
> 聚源数据字典在线:https://dd.gildata.com/(szsgdsjk01 / gildata@123),本地版本见 `references/data.md` 中的「常用表速查」。\r
\r
\r
## 融资融券\r
\r
```csharp\r
// 融券卖出(下单价需 >= 最新价)\r
this.ShortSell(code, 1000, lastTick.LastPrice);\r
\r
// 获取融券持仓\r
var pos = GetPositions(MainAccountId, code);\r
// pos.TotalShort / TodayShort / HistoryShort\r
\r
// 获取融券额度 (回测固定100w额度,实盘不支持查询)\r
var quota = GetMarginQuota(MainAccountId, code);\r
\r
// 买券还券\r
this.BuyAndRepayStock(code, 1000, lastTick.AskPrice1);\r
\r
// 融资买入\r
this.MarginBuy(code, 1000, lastTick.LastPrice);\r
```\r
\r
## 手续费设置\r
\r
| 标的种类 | 默认手续费 |\r
|---------|-----------|\r
| 国内股票/港股通 | 买0.0002,卖0.0007 |\r
| 国内ETF | 买0.0006,卖0.0006 |\r
| 国内ETF期权 | 每手1.5元 |\r
| 国内期货 | 按配置文件 |\r
\r
```csharp\r
// 调整单个标的\r
this.ConfigTradeFee(Instrument.FromCode("IF2306"), TradeFeeConfig.RateFeeConfig(0.0001));\r
// 调整全部股票\r
this.ConfigStockTradeFee(TradeFeeConfig.RateFeeConfig(0.0001, 0.0006));\r
```\r
\r
## 下单数量规则\r
\r
| 标的类型 | 下单量单位 | 最小量 | 倍数 |\r
|---------|----------|--------|------|\r
| A股股票 | 股数 | 100 | 100 |\r
| 科创板 | 股数 | 200 | 1 |\r
| 上海可转债 | 手数(1手=10张) | 1 | 1 |\r
| 深圳可转债 | 张数 | 10 | 10 |\r
| 期货 | 手数 | 1(部分品种不同) | 1 |\r
\r
```csharp\r
// 获取下单规则\r
var maxVol = instrument.GetMaxSubmitVolume();\r
var minVol = instrument.GetMinSubmitVolume();\r
var multiple = instrument.GetSubmitMultiple();\r
var volumeMultiple = instrument.GetVolumeMultiple(); // 合约乘数\r
```\r
\r
## References 文档\r
\r
- 详细算法用法(子单/追单/Twap/配对):请读取 `references/algorithms.md`\r
- 策略完整代码示例:请读取 `references/examples.md`\r
- 数据获取完整参考(日线/Tick/K线/主力合约/交易日/汇率/分红/ETF申赎/聚源表速查):请读取 `references/data.md`\r
- 基类CommonStrategy的所有方法和属性:\x3Chttps://irs_doc.shengguanda.com/docs/api/IRS.Common/CommonStrategy>\r
安全使用建议
This skill appears to be internal/enterprise documentation for the IRS (SunnyQuant) system and mostly does what it says — but it contains many internal network addresses and plaintext credentials embedded in the package. Before installing or enabling it: 1) Confirm the publisher/source and ensure you trust them (this is not from a public/verified project). 2) Do not install in an environment where exposing internal hosts or embedded secrets could leak sensitive data. 3) Ask the author for a sanitized version that removes plaintext credentials and internal UNC/IP references; credentials should be provided via secure configuration or environment variables only. 4) If you are an internal user: rotate any credentials found in these files (treat them as potentially leaked) and replace embedded secrets with secure configuration. 5) If you expected a public skill, treat this as suspicious and avoid granting access to any systems until the package is cleaned and the source verified.
功能分析
Type: OpenClaw Skill
Name: irs-strategist
Version: 0.1.0
The irs-strategist skill bundle is a comprehensive development assistant for the IRS (SunnyQuant) C# trading framework. It contains extensive documentation on the strategy lifecycle and a large collection of JSON files in the 'references/tableInfo/' directory that define database schemas for financial instruments. While SKILL.md includes hardcoded credentials for an external data dictionary (gildata.com) and points to a private NuGet source (shengguanda.com), these elements are consistent with the framework's institutional context and do not demonstrate malicious intent or unauthorized data exfiltration.
能力评估
Purpose & Capability
The name/description and the SKILL.md focus on developing and debugging IRS (SunnyQuant) C# strategies; the large set of reference docs, examples, and table schemas are coherent with that purpose. However, the package also bundles internal network paths, IP addresses (e.g. 192.168.x.x), UNC shares (\\192.168.x.x\...), private NuGet endpoints (nuget.shengguanda.com) and explicit DB connection strings — items that are only appropriate for an internal/enterprise distribution, not a general public skill. The presence of these resources without declaring them as required environment values is unexpected.
Instruction Scope
SKILL.md stays on-topic for strategy development and contains actionable instructions (how to create projects, subscribe market data, order flows). But it references environment configuration (DATA_SOURCE_BASE_PATH), suggests installing an internal dotnet template from a private NuGet server, and demonstrates setting a SqlServer connection string. The instructions do not instruct reading arbitrary user files, but they do assume access to internal network storage and databases — scope that may be inappropriate for public use and that could expose sensitive infrastructure details if the skill is shared publicly.
Install Mechanism
There is no install spec (instruction-only), which is low risk in itself. However the package contains 616 files of internal reference material and JSON table schemas embedded in the skill bundle. Packaging/redistributing that much internal documentation (including credentials and internal-host names) increases risk of accidental leakage of sensitive information. No downloaded executables or remote installs were observed.
Credentials
The metadata declares no required env vars or credentials, yet the content includes hardcoded connection strings (e.g. SqlServer connection string with User Id=Traders;Password=abcd4321), usernames/passwords for an online data dictionary (szsgdsjk01 / gildata@123), internal Redis and file-share addresses, and a private NuGet source. Those secrets/endpoints are not justified as public requirements of the skill and were not declared in requires.env; this is disproportionate and may leak internal credentials/hosts.
Persistence & Privilege
The skill does not request always:true, does not declare system-wide config modifications, and is user-invocable with normal model invocation. No elevated persistence or privileged flags were found.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install irs-strategist - 安装完成后,直接呼叫该 Skill 的名称或使用
/irs-strategist触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Initial release of irs-strategist.
- Provides comprehensive documentation and quickstart guide for developing trading strategies using the IRS (SunnyQuant) C#/.NET framework.
- Details CommonStrategy lifecycle, event callbacks, quote/K-line subscription, algorithmic order handling, strategy parameters, charting APIs, multi-account support, and sub-strategy patterns.
- Includes reference on data sources, backtesting, live trading setup, and troubleshooting.
- Offers practical code examples and best practices for typical strategy development tasks.
v1.0.3
## irs-strategist v1.0.3 Changelog
- Added `package.json` for package management and metadata.
- Updated all documentation and data reference files for improved clarity and structure.
- Major refresh to references/algorithms.md, data.md, examples.md, jydb.md, and all `references/tableInfo/*.json` data files to ensure completeness and up-to-date field definitions.
- Refined and expanded SKILL.md to provide clearer instructions, usage patterns, troubleshooting tips, and best practices.
- No breaking changes to user workflow; all updates are documentation and metadata enhancements.
v1.0.1
irs-strategist 1.0.1
- Expanded documentation to include detailed instructions for IRS strategy template installation, including troubleshooting NuGet source accessibility.
- Added step-by-step guidance for installing the IRS template via `dotnet new install` and clarifying internal network requirements.
- No changes to code execution or APIs; all updates are to SKILL.md and related reference documents.
- Housekeeping: package.json and package-lock.json removed.
v1.0.0
IRS Strategy Development Skill v1.0.0
- Introduces a comprehensive guide for writing, reviewing, and debugging trading strategies using the IRS (SunnyQuant) framework.
- Includes clear instructions on project structure, strategy lifecycle (with all callback methods), and order placement using algorithmic orders.
- Provides examples and tips for quote/candle data subscription, historical data access, backtesting, and live trading.
- Covers key features: custom parameters, scheduled tasks, trading chart visualization, multi-account and sub-strategy architecture, and data APIs.
- Adds guidance for developer tooling (suggests Jetbrains Rider and .NET SDK installation).
元数据
常见问题
IRS Strategy Development Skill 是什么?
This skill should be used when the user needs to write, review, or debug trading strategies using the IRS (SunnyQuant Investment Research System) framework.... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 328 次。
如何安装 IRS Strategy Development Skill?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install irs-strategist」即可一键安装,无需额外配置。
IRS Strategy Development Skill 是免费的吗?
是的,IRS Strategy Development Skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
IRS Strategy Development Skill 支持哪些平台?
IRS Strategy Development Skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 IRS Strategy Development Skill?
由 Dameng(@dameng324)开发并维护,当前版本 v0.1.0。
推荐 Skills