2026.02.02

[AIブログライター] 第4回:Claude code sub-agentとskillsのバイブコーディングで、Pair Trading戦略の検証と記事の自動生成

こんにちは。AI研究開発室のK.S.です。

お久しぶりです。

ブログを書くのは手間がかかりませんか? ネタがあっても、情報収集、要約、図の作成、フォーマット調整などの作業が待っています。特に外国人の私は日本語チェックも必須です(脳内の赤ペンが忙しい)。AI時代だからこそ、精度を保ちつつ効率化できる領域は広がっているはずです。

ということで、今回は「金融特化のAIブログライターを作ってみた」という開発プロセスを、技術進化のステップとして連載でお届けします。最終的には、人間の判断(Human-in-the-Loop)とAIによる自動化がうまく協調できる仕組みを作ることが、個人的な目標です。

この連載では、金融特化のAIブログライターを段階的に作っていきます。

第4回は「Claude codeのsub-agentとskillsを使い、Pair Trading戦略のブログを自動生成する」回です。

AIブログライター・シリーズのご紹介

本シリーズでは、AI Agents・自動化技術を活用した金融分野のブログ記事生成プロセスを、ステップごとに実践的に紹介しています。

この記事でやること

  • Sub-agentsで調査・執筆・編集を分担
  • SkillsでAgentsのパフォーマンスを高め、本文の品質を揃える
  • できるだけ自分でコードを書かず、Claude codeとのやりとりだけで完結するようにする
  • AIが書いたブログは手を入れずにそのまま共有、画像のURLだけ修正
  • (AI経由で)Pair Trading戦略を紹介

使う技術

  • Claude code:AIに様々なタスクを指示したり、独自スキル(コード)を登録できるプラットフォーム
  • sub-agents:Claude code内で調査や執筆などの役割を分担できるサブエージェント
  • skills:Claude code内でタスクごとの情報検索や自動処理や文章生成品質の専用スキル

技術の紹介と実践

Claude code sub-agent

Claude code sub-agentは、ClaudeのAIプラットフォーム内で特定のタスク(調査・執筆・校正など)を分担するために作れるサブエージェント機能です。個々の役割ごとにエージェントを設定し、自動的に協力させることで、効率的かつ一貫性のあるアウトプットが作れます。

作り方は簡単で、Claude CodeのCLIに「/agents」コマンドを入力し、Create new agentでエージェントを作成します。「Generate with Claude (recommended)」を選択すると、Claudeと会話しながら、一個ずつ欲しいエージェントを作成できます。
例えば、「Help me to write a trading technical blog in Japanese using information provided from trading-tech-researcher」を入力すると、様々な質問を聞かれて、.claude/agents/japanese-trading-blog-writer.mdファイルが作成されます。
内容は下記のとおりです。

(クリックでjapanese-fintech-blog-writer.mdを開く)
  ---
  name: japanese-fintech-blog-writer
  description: "Use this agent when you need to write or draft technical trading strategy (取引戦略) blog posts in Japanese, particularly when leveraging research from the fintech-researcher agent. This agent handles 記事執筆 (article writing) - transforming trading research into engaging Japanese content for intermediate-level engineers (技術者向け・中級レベル).\\n\\nExamples:\\n\\n<example>\\nContext: The user has received research from the fintech-researcher agent and wants to create a blog post.\\nuser: \"I have this research about algorithmic trading. Can you turn it into a blog post?\"\\nassistant: \"I'll use the japanese-fintech-blog-writer agent to transform this research into a 2000-3000 character Japanese technical blog post.\"\\n</example>\\n\\n<example>\\nContext: The user wants to write about a specific trading topic in Japanese.\\nuser: \"最新のアルゴリズム取引について日本語でブログ記事を書いて\"\\nassistant: \"japanese-fintech-blog-writer エージェントを使用して、アルゴリズム取引に関する技術ブログ記事を執筆します。\"\\n</example>\\n\\n<example>\\nContext: The user has completed research and is ready for content creation.\\nuser: \"The research phase is done. Now I need to write the actual blog article in Japanese.\"\\nassistant: \"I'll use the japanese-fintech-blog-writer agent to draft the Japanese blog article based on your completed research.\"\\n</example>"
  tools: Read, Edit, Write, NotebookEdit, Skill
  model: sonnet
  color: blue
  ---
  
  You are an expert Japanese trading strategy (取引戦略) content writer specializing in technical blogs for intermediate-level engineers (技術者向け・中級レベル). You transform research from the fintech-researcher agent into engaging, well-structured Japanese blog content.
  
  ## Your Core Mission: 記事執筆 (Article Writing)
  
  You write technical trading strategy blog posts in Japanese that:
  - Are **2000-3000 characters** in length
  - Target **技術者向け(中級レベル)** - intermediate-level engineers
  - Focus on **技術的内容を中心** - technical content
  - Cover topics from **最新1ヶ月以内** - within the latest 1 month
  - Output in **HTML format** with UTF-8 encoding
  
  ## Areas of Expertise
  
  - **アルゴリズム取引** (Algorithmic Trading): HFT, market making, statistical arbitrage
  - **クオンツ戦略** (Quantitative Strategies): Factor models, momentum, mean reversion
  - **マーケットマイクロストラクチャー** (Market Microstructure): Order flow, liquidity, price impact
  - **機械学習トレーディング** (ML Trading): Deep learning, reinforcement learning, feature engineering
  - **リスク管理** (Risk Management): VaR, position sizing, portfolio optimization
  - **バックテスト** (Backtesting): Historical simulation, walk-forward analysis, overfitting prevention
  - **執行アルゴリズム** (Execution Algorithms): TWAP, VWAP, implementation shortfall
  
  ## Required Article Structure (HTML Format)
  
  ```html
  <!-- 1. 自己紹介(定型文) -->
  <p>こんにちは。AI研究開発室のK.S.です。</p>
  
  <!-- 2. 導入(トピックの背景) -->
  <h2>[導入見出し]</h2>
  <p>[背景説明・なぜこのトピックが重要か]</p>
  
  <!-- 3. 本文(技術的解説) -->
  <h2>[技術解説見出し1]</h2>
  <p>[技術的な説明]</p>
  
  <h2>[技術解説見出し2]</h2>
  <p>[具体例・実装詳細]</p>
  
  <!-- 4. 参考文献 -->
  <h2>参考文献</h2>
  <ol>
    <li><a href="[URL1]">[ソースタイトル1]</a></li>
    <li><a href="[URL2]">[ソースタイトル2]</a></li>
    <li><a href="[URL3]">[ソースタイトル3]</a></li>
  </ol>
  
  <!-- 5. 採用情報(定型文) -->
  <h2>最後に</h2>
  <p>グループ研究開発本部 AI研究開発室では、データサイエンティスト/機械学習エンジニアを募集しています。
  ビッグデータの解析業務などAI研究開発室にご興味を持って頂ける方がいらっしゃいましたら、ぜひ <a href="https://recruit.group.gmo/engineer/jisedai/entry/">募集職種一覧</a> からご応募をお願いします。
  皆さんのご応募をお待ちしています。
  一緒に勉強しながら楽しく働きたい方のご応募をお待ちしています。</p>
  ```
  
  ## Writing Guidelines
  
  ### Content Requirements
  - **文字数**: 2000-3000字(本文部分)
  - **難易度**: 技術者向け(中級レベル)
  - **言語**: 日本語
  - **専門用語**: 簡潔な説明を付与
  
  ### Tone and Style
  - Professional yet accessible です/ます form
  - Technical accuracy with clear explanations
  - わかりやすい文章表現 (easy-to-understand writing)
  - Natural Japanese, not translations from English
  
  ### Quality Standards (品質基準)
  - わかりやすい文章表現
  - 複数ソースによる情報の裏付け (use references from researcher)
  - 専門用語には簡潔な説明を付与
  - Technical accuracy verified
  
  ## Working with Research Input
  
  When receiving information from the fintech-researcher:
  1. Use the provided reference list for 参考文献 section
  2. Verify you understand the technical concepts
  3. Tailor depth for intermediate engineers
  4. Include relevant Japanese market context
  
  ## Output Requirements
  
  - **Format**: Complete HTML document section
  - **Encoding**: UTF-8
  - **References**: Numbered list with links (from researcher)
  - **Length**: 2000-3000 characters (main content)
  
  ## Self-Verification Checklist
  
  Before finalizing:
  - [ ] HTML structure follows template exactly
  - [ ] Character count: 2000-3000字
  - [ ] Technical terms have explanations
  - [ ] Natural Japanese (not translated)
  - [ ] References properly formatted with links
  - [ ] 自己紹介 and 採用情報 sections included exactly as specified
  

Claude code skills

Claude code skillsは、ユーザー自身が作成・登録できるタスク特化型のコード(スキル)をAIエージェントが使える仕組みです。繰り返し行う作業や特化したデータ生成、品質基準の統一などに活用されます。ノーコード感覚で高度なカスタマイズが可能です。

作り方は簡単で、Claude CodeのCLIに「/plugin」を入力し、marketplace add anthropics/skillsを入力すると、スキルを作成できます。
「/plugin install example-skills@anthropic-agent-skills」と「/plugin install document-skills@anthropic-agent-skills」をinstallするのがおすすめです。
入れておけば、今後はskillsを簡単に作成できます。雰囲気のため、作成されたSKILL.mdの例を載せておきます。

(クリックでskills/gemini-image/SKILL.mdを開く)
  ---
  name: gemini-image
  description: Generate professional fintech blog summary images using Gemini 3 Pro image preview API. Use when you need to create visual headers for Japanese financial technology blog posts.
  ---
  
  # Gemini 3 Pro Image Generation
  
  Generate professional fintech blog summary images using Google's Gemini 3 Pro image preview API.
  
  ## Prerequisites
  
  Set the `GEMINI_API_KEY` environment variable:
  ```bash
  export GEMINI_API_KEY="your-api-key"
  ```
  
  ## Quick Usage
  
  ### Using Python SDK
  
  ```python
  import asyncio
  from sdk.gemini_image import generate_blog_image
  
  async def main():
      image = await generate_blog_image(
          topic="momentum trading strategies",
          article_title="ペアトレード取引戦略の実装",
      )
      print(image.to_html_img())
  
  asyncio.run(main())
  ```
  
  ### Using curl
  
  ```bash
  curl -X POST \
    "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent?key=${GEMINI_API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{
      "contents": [{
        "parts": [{
          "text": "Professional fintech blog header: Abstract visualization of trading algorithms, blue and white color scheme, modern minimalist design, suitable for Japanese corporate tech blog"
        }]
      }],
      "generationConfig": {
        "responseModalities": ["image", "text"],
        "imageSizeConfig": {
          "aspectRatio": "16:9"
        }
      }
    }' | python -c "
  import sys, json, base64
  response = json.load(sys.stdin)
  for candidate in response.get('candidates', []):
      for part in candidate.get('content', {}).get('parts', []):
          if 'inlineData' in part:
              data = part['inlineData']['data']
              with open('output/images/blog_image.png', 'wb') as f:
                  f.write(base64.b64decode(data))
              print('Image saved to output/images/blog_image.png')
  "
  ```
  
  ## Image Prompt Templates
  
  ### Algorithmic Trading
  ```
  Professional blog header: Abstract visualization of automated trading algorithms,
  digital charts with flowing data streams, blue and white color scheme,
  modern minimalist design, suitable for Japanese corporate tech blog
  ```
  
  ### High-Frequency Trading (HFT)
  ```
  Professional blog header: High-speed data visualization showing network connections,
  microsecond timing displays, abstract geometric patterns representing speed,
  clean modern design with blue tones
  ```
  
  ### Machine Learning Trading
  ```
  Professional blog header: Neural network patterns with financial data overlay,
  gradient flows representing prediction models, abstract AI visualization,
  professional fintech aesthetic
  ```
  
  ### Quantitative Strategies
  ```
  Professional blog header: Mathematical formulas and statistical distributions overlay,
  factor analysis charts, quantitative finance visualization,
  professional corporate aesthetic with blue tones
  ```
  
  ### Risk Management
  ```
  Professional blog header: Abstract risk matrix visualization,
  probability distributions and hedging diagrams,
  professional blue and white color scheme
  ```
  
  ### Blockchain/Crypto
  ```
  Professional blog header: Distributed ledger visualization,
  crypto network nodes and digital transaction flows,
  modern fintech aesthetic with abstract geometric design
  ```
  
  ## API Reference
  
  ### Endpoint
  ```
  POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent
  ```
  
  ### Request Body
  ```json
  {
    "contents": [{
      "parts": [{"text": "Your image prompt here. Generate in 16:9 landscape aspect ratio."}]
    }],
    "generationConfig": {
      "responseModalities": ["IMAGE", "TEXT"],
      "temperature": 1.0
    }
  }
  ```
  
  **Note**: Aspect ratio is specified in the prompt text, not in `generationConfig`.
  
  ### Response
  The response contains base64-encoded image data in `candidates[0].content.parts[0].inlineData.data`.
  
  ## Output Format
  
  Generate HTML img tag for embedding in blog posts:
  
  ```html
  <!-- For file-based images -->
  <img src="output/images/blog_image.png" alt="記事タイトル" />
  
  <!-- For base64 embedded images -->
  <img src="data:image/png;base64,[base64_data]" alt="記事タイトル" />
  ```
  
  ## Best Practices
  
  1. **Use Descriptive Prompts**: Be specific about the fintech theme and visual style
  2. **Maintain Consistency**: Use blue/white color schemes for corporate aesthetic
  3. **16:9 Aspect Ratio**: Standard for blog headers
  4. **Alt Text**: Always include Japanese article title in alt attribute
  5. **Save to output/images/**: Store generated images in the designated directory
  
  ## Troubleshooting
  
  ### API Key Not Set
  ```
  Error: API key required
  ```
  Solution: Set `GEMINI_API_KEY` environment variable
  
  ### Rate Limiting
  ```
  Error: 429 Too Many Requests
  ```
  Solution: Wait and retry, or upgrade API quota
  
  ### Image Generation Failed
  ```
  Error: No image data in response
  ```
  Solution: Check prompt for policy violations, simplify the request

AI orchestration

やりたいことはbusiness_requirements.mdに簡単に入れて、Claudeにそれを読んだ上で、適切にsub-agentsやskillsを使ってCLAUDE.mdを作成し、AI orchestrationを行ってもらいました。

まず、私のbusiness_requirements.mdは下記のように簡単で詳細の実装pipelineはAIに任せてしまいます。

  # ビジネス要件

  ## 1. 目的
  指定された取引戦略を調査し、簡単な実装を行い、ブログ記事として日本語で解説する。
  AIエージェントシステムで自動生成する。
  
  ## 2. コンテンツ要件
  ### 2.1 基本仕様
  - **言語**: 日本語
  - **文字数**: 2000-3000字
  - **対象期間**: 最新1ヶ月以内の情報
  - **難易度**: 技術者向け(中級レベル)
  - **フォーカス**: 技術的内容を中心
  
  ### 2.2 記事構成
  1. 取引戦略の概要
  2. 導入(トピックの背景)
  3. 本文(取引戦略の実装結果と技術的解説)
  4. まとめ図を作成し、記事に貼り付ける
  5. 参考文献
  
  ### 2.3 品質基準
  - わかりやすい文章表現
  - 複数ソースによる情報の裏付け
  - 専門用語には簡潔な説明を付与
  - AIレビュー&修正を経た最終版
  
  ## 3. 出力形式
  - **フォーマット**: HTML
  - **文字エンコーディング**: UTF-8
  - **参考文献形式**: 番号付きリスト with リンク
  
  ## 4. 運用想定
  - UIで取引戦略を記入し、AIに実装を依頼する。
  - 承認フロー: AI生成 → 人間確認 → 公開

 

ここで、Claudeが勝手にpipelineを考えてくれて、時間がかからず完了です。Claudeが考えた内容を確認する方が、待つ時間より長かったです。

2026Q1_blog4_pipeline

また、画像生成にはGeminiを使いたかったので、SDK Agentを利用して、画像を生成してもらいました。

それでは、実際にテストしてみましょう。

テスト

指示の例は「please edit agents expertise and description based on business_requirements.md」や「understand all sub-agents and write Claude.md」とやりとりをしました。

(Claude Codeとのやりとりしかやることがないので、ここに何を書くべきか悩んでしまいました。)

とりあえず、最後に「please write a blog about Pair Trading」と指示したら、AIが勝手に適切なagentsを読んだり、skillsを使ったり、していました。

一点ですが、Agentsが多くて、今回のブログを書くのに時間がかかり、どんどん遊んだら、Claude ProのLimit制限が大変なことになりました。今回は様々なPythonモジュールやライブラリを利用し実装のところがハマって修正していたのが原因のようで、ある程度にしてくださいと指示し、無事に完了してくれました。(本当はバックテストを行いたかったのですが、時間がかかりすぎたので、雰囲気で結果を見せます。)

ということで、結果を見ていきましょう。

AIブログライターの記事

今回生成された結果は下記のとおりで、HTMLフォーマットで出力されましたので、画像で載せます。

================ START ===========

2026Q1_blog4_blog_result_1
2026Q1_blog4_blog_result_2
2026Q1_blog4_blog_result_3

================ END ===========

感想

いかがでしょうか?

Claude code sub-agentsとskillsの組み合わせで、いい感じに記事生成可能性が高まってきた感触があります。

個人的な好みと意見になってしまいますが、複数のsub-agentsを利用することで、AI agentsに自由させることができて、意外な面白いものが出てきていると感じます。一方、Claude ProのLimitsを超えやすく、コスト面は管理しにくいです。
また、効率面は最初の検証段階は検討しやすいのですが、ある程度設計が決まったら、
n8nワークフロー作成、又は、SDK Agentを利用することで、より複雑なワークフローを管理しやすいと思います。

今回のPair Tradingについて、基本構造は自動で揃い、AI orchestration的にも悪くなかったと感じます。ただ、検証するにはもう少し工夫する価値があるかもしれません。
ちなみに、(どこかのagentsの判断で?)載せた内容には記載されなかったが、途中まで、勝手にこの手法のバックテストを行っていたようで、雰囲気で結果を見せます。

2026Q1_blog4_pairs_trading_results

まさに、様々なagentsの展開はどこまで何をやっているのか追いかけにくい課題がありつつ、手法や結果は参考になる気がします。

その後は、human-in-the-loopに入るかどうか、どこまで自動化すべきか、はそれぞれの判断になるのではないでしょうか。

まとめ

AIブログライターの技術面として、Claude code sub-agentsとskillsの組み合わせを紹介し、仮のAI orchestrationを行いました。

また、金融知識の紹介として、AIを活用してPair Tradingの基本構造や実装例を紹介しました。

最後に

グループ研究開発本部 AI研究開発室では、データサイエンティスト/機械学習エンジニアを募集しています。
ビッグデータの解析業務などAI研究開発室にご興味を持って頂ける方がいらっしゃいましたら、ぜひ 募集職種一覧 からご応募をお願いします。
皆さんのご応募をお待ちしています。
一緒に勉強しながら楽しく働きたい方のご応募をお待ちしています。

  • Twitter
  • Facebook
  • はてなブックマークに追加

グループ研究開発本部の最新情報をTwitterで配信中です。ぜひフォローください。

 
  • AI研究開発室
  • 大阪研究開発グループ

関連記事