Skip to main content
Glama

get_price_chart

Retrieve price chart data for specified currency pairs and timeframes to support trading decisions, trend analysis, and technical calculations. Ideal for identifying patterns, support/resistance levels, and market trends.

Instructions

    指定期間の価格チャートデータを取得し、投資判断やトレンド分析に活用します。
    
    このツールは以下の用途で使用されます:
    - 価格トレンドの分析とパターン認識
    - 買い時・売り時の判断材料として
    - サポート・レジスタンスレベルの特定
    - テクニカル分析(移動平均、RSI等の計算基礎データ)
    - 価格変動の要因分析
    
    期間指定のガイドライン:
    - 1分足・5分足: 数時間~1日分のデータが適切です
    - 1時間足: 1週間~1ヶ月分のデータが適切です
    - 日足: 1ヶ月~6ヶ月分のデータが適切です
    - 週足: 6ヶ月~2年分のデータが適切です
    
    注意: 極端に長い期間(例: 1分足で1年分)を指定すると、
    データ量が膨大になり処理に時間がかかる場合があります。
    
    Args:
        currency_pair: 通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
        timeframe: 時間足('1': 1分足、'5': 5分足、'15': 15分足、'30': 30分足、'60': 1時間足、
                  '240': 4時間足、'480': 8時間足、'720': 12時間足、'D': 日足、'W': 週足)
        start_date: 開始日時(ISO形式: 'YYYY-MM-DDTHH:MM:SS')
        end_date: 終了日時(ISO形式: 'YYYY-MM-DDTHH:MM:SS')
    
    Returns:
        PriceChartData: 価格チャートデータ
            - currency_pair: 通貨ペア
            - timeframe: 時間足の表示名(例: '1時間足')
            - start_date: 開始日時(ISO 8601形式)
            - end_date: 終了日時(ISO 8601形式)
            - candlesticks: ローソク足データのリスト(時系列順)
                - timestamp: ISO 8601形式の日時文字列
                - open_price: 始値
                - high_price: 高値
                - low_price: 安値
                - close_price: 終値
                - volume: 出来高
            - data_count: データ件数
    
    Raises:
        ValueError: 日付形式が不正な場合や、APIエラーが発生した場合
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currency_pairYes
end_dateYes
start_dateYes
timeframeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_dateYes
timeframeYes
data_countYes
start_dateYes
candlesticksYes
currency_pairYes

Implementation Reference

  • The core handler function for the 'get_price_chart' tool. It validates dates, calls the Zaif API for OHLC data, and returns a PriceChartData object.
    @mcp.tool()
    def get_price_chart(currency_pair: SupportedPair, timeframe: SupportedPeriod, start_date: str, end_date: str) -> PriceChartData:
        """
        指定期間の価格チャートデータを取得し、投資判断やトレンド分析に活用します。
        
        このツールは以下の用途で使用されます:
        - 価格トレンドの分析とパターン認識
        - 買い時・売り時の判断材料として
        - サポート・レジスタンスレベルの特定
        - テクニカル分析(移動平均、RSI等の計算基礎データ)
        - 価格変動の要因分析
        
        期間指定のガイドライン:
        - 1分足・5分足: 数時間~1日分のデータが適切です
        - 1時間足: 1週間~1ヶ月分のデータが適切です
        - 日足: 1ヶ月~6ヶ月分のデータが適切です
        - 週足: 6ヶ月~2年分のデータが適切です
        
        注意: 極端に長い期間(例: 1分足で1年分)を指定すると、
        データ量が膨大になり処理に時間がかかる場合があります。
        
        Args:
            currency_pair: 通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
            timeframe: 時間足('1': 1分足、'5': 5分足、'15': 15分足、'30': 30分足、'60': 1時間足、
                      '240': 4時間足、'480': 8時間足、'720': 12時間足、'D': 日足、'W': 週足)
            start_date: 開始日時(ISO形式: 'YYYY-MM-DDTHH:MM:SS')
            end_date: 終了日時(ISO形式: 'YYYY-MM-DDTHH:MM:SS')
        
        Returns:
            PriceChartData: 価格チャートデータ
                - currency_pair: 通貨ペア
                - timeframe: 時間足の表示名(例: '1時間足')
                - start_date: 開始日時(ISO 8601形式)
                - end_date: 終了日時(ISO 8601形式)
                - candlesticks: ローソク足データのリスト(時系列順)
                    - timestamp: ISO 8601形式の日時文字列
                    - open_price: 始値
                    - high_price: 高値
                    - low_price: 安値
                    - close_price: 終値
                    - volume: 出来高
                - data_count: データ件数
        
        Raises:
            ValueError: 日付形式が不正な場合や、APIエラーが発生した場合
        """
        try:
            from_dt = datetime.fromisoformat(start_date)
            to_dt = datetime.fromisoformat(end_date)
        except ValueError:
            raise ValueError("日付形式が不正です。'YYYY-MM-DDTHH:MM:SS'形式で指定してください。")
            
        # APIからデータを取得
        api_response = api.chart.get_ohlc(
            currency_pair=currency_pair,
            period=timeframe,
            from_datetime=from_dt,
            to_datetime=to_dt
        )
        
        # 新しいモデル形式に変換
        return PriceChartData.from_dict(
            data=api_response.to_dict(),
            currency_pair=currency_pair,
            timeframe=timeframe,
            start_date=start_date,
            end_date=end_date
        )
  • The import and invocation of register_chart_tools, which registers the get_price_chart tool on the MCP server.
    from zaifer_mcp.tools.chart import register_chart_tools
    
    register_market_tools(mcp, zaif_api)
    register_account_tools(mcp, zaif_api)
    register_trade_tools(mcp, zaif_api)
    register_chart_tools(mcp, zaif_api)
  • Output schema (PriceChartData dataclass) for the get_price_chart tool, explicitly noted as corresponding to its return value.
    class PriceChartData:
        """
        価格チャートデータ全体を表すデータクラス。
        get_price_chartの戻り値に対応します。
        
        Attributes:
            currency_pair: 通貨ペア(例: 'btc_jpy')
            timeframe: 時間足(例: '1時間足')
            start_date: 開始日時(ISO 8601形式)
            end_date: 終了日時(ISO 8601形式)
            candlesticks: ローソク足データ(時系列順)
            data_count: データ件数
        """
        currency_pair: str
        timeframe: str
        start_date: str
        end_date: str
        candlesticks: List[CandlestickData]
        data_count: int
  • Input schema type literals (SupportedPair, SupportedPeriod) used as parameter types in get_price_chart.
    # 対応する通貨ペアを明示的に制限
    SupportedPair = Literal["btc_jpy", "eth_jpy", "xym_jpy"]
    
    # 対応する通貨を明示的に制限
    SupportedCurrency = Literal["btc", "eth", "xym", "jpy"]
    
    # 対応する期間を明示的に制限
    SupportedPeriod = Literal["1", "5", "15", "30", "60", "240", "480", "720", "D", "W"]
  • Helper method to convert Zaif API response dictionary to PriceChartData instance, used directly in the handler.
    @classmethod
    def from_dict(cls, data: Dict[str, Any], currency_pair: str, timeframe: str, start_date: str, end_date: str) -> 'PriceChartData':
        """
        APIレスポンスからPriceChartDataインスタンスを作成します。
        
        Args:
            data: APIレスポンスの辞書
            currency_pair: 通貨ペア
            timeframe: 時間足
            start_date: 開始日時(ISO 8601形式)
            end_date: 終了日時(ISO 8601形式)
            
        Returns:
            PriceChartDataインスタンス
        """
        candlesticks = []
        for item in data.get('ohlc_data', []):
            # ミリ秒単位のタイムスタンプをISO 8601形式に変換
            timestamp_ms = int(item.get('time', 0))
            timestamp_iso = datetime.fromtimestamp(timestamp_ms / 1000).isoformat()
            
            candlesticks.append(CandlestickData(
                timestamp=timestamp_iso,
                open_price=Decimal(str(item.get('open', '0'))),
                high_price=Decimal(str(item.get('high', '0'))),
                low_price=Decimal(str(item.get('low', '0'))),
                close_price=Decimal(str(item.get('close', '0'))),
                volume=Decimal(str(item.get('volume', '0')))
            ))
        
        # 時間足の表示名を生成
        timeframe_names = {
            "1": "1分足", "5": "5分足", "15": "15分足", "30": "30分足",
            "60": "1時間足", "240": "4時間足", "480": "8時間足", 
            "720": "12時間足", "D": "日足", "W": "週足"
        }
        timeframe_display = timeframe_names.get(timeframe, f"{timeframe}足")
        
        return cls(
            currency_pair=currency_pair,
            timeframe=timeframe_display,
            start_date=start_date,
            end_date=end_date,
            candlesticks=candlesticks,
            data_count=int(data.get('data_count', 0))
        )
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: it retrieves data (not modifies), includes performance warnings about long periods causing processing delays, and specifies error conditions (ValueError for invalid dates or API errors). However, it doesn't mention rate limits, authentication requirements, or data freshness, leaving some gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, use cases, guidelines, parameters, returns, errors) and uses bullet points for readability. While comprehensive, it's slightly verbose; some redundancy exists (e.g., repeating timeframe details in guidelines and Args). Every sentence adds value, but it could be more front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, 0% schema coverage, no annotations) and the presence of an output schema, the description is highly complete. It covers purpose, usage, behavioral traits, parameter details, return structure (though output schema handles this), and error conditions. No significant gaps remain for effective tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must fully compensate. It provides comprehensive parameter semantics: currency_pair enum values with Japanese translations, timeframe enum values with explanations (e.g., '1': 1分足), and date format specifications (ISO format). This adds significant meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '指定期間の価格チャートデータを取得し、投資判断やトレンド分析に活用します' (retrieves price chart data for a specified period for investment decisions and trend analysis). It specifies both the action (retrieve) and resource (price chart data), and distinguishes itself from siblings like get_ticker (single price) or get_market_depth (order book).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidelines with a detailed list of use cases (e.g., trend analysis, support/resistance identification) and timeframe-specific recommendations (e.g., '1分足・5分足: 数時間~1日分のデータが適切です'). It also includes warnings about performance implications for extreme date ranges, offering clear when-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/curio184/zaifer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server