Skip to main content
Glama

get_open_orders

Retrieve a list of active (unexecuted) cryptocurrency orders on Zaif exchange. Filter by currency pair or view all open orders to monitor strategy progress or identify cancellations.

Instructions

    現在有効な(未約定の)暗号資産取引注文一覧を取得します。

    このツールは、現在板に出ている未約定注文(一部約定を含む)の一覧を確認するために使用します。
    特定の通貨ペアでフィルタリングすることも、すべての通貨ペアの注文を取得することもできます。

    使用例:
    - 現在の注文状況を確認したい場合
    - キャンセルすべき注文を特定したい場合
    - 注文戦略の進捗を確認したい場合

    注意: このツールを使用するには、環境変数にAPIキーとシークレットが設定されている必要があります。

    Args:
        currency_pair: 通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
                      指定しない場合、すべての通貨ペアの注文が返されます

    Returns:
        OpenOrderList: 未約定注文一覧
            - open_orders: 注文IDをキーとする注文情報の辞書
                - currency_pair: 通貨ペア
                - order_type: 注文タイプ('bid': 買い、'ask': 売り)
                - price: 注文価格
                - quantity: 注文数量
                - order_time: 注文日時のISO 8601形式の文字列(例: '2023-05-24T15:30:45+09:00')

    Raises:
        ValueError: 認証情報が設定されていない場合や、APIエラーが発生した場合
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currency_pairNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
open_ordersYes

Implementation Reference

  • The core handler function for the 'get_open_orders' tool, decorated with @mcp.tool(). It checks authentication, calls ZaifApi to get active orders, filters for supported currency pairs (btc_jpy, eth_jpy, xym_jpy), and returns an OpenOrderList.
    @mcp.tool()
    def get_open_orders(currency_pair: SupportedPair = None) -> OpenOrderList:
        """
        現在有効な(未約定の)暗号資産取引注文一覧を取得します。
    
        このツールは、現在板に出ている未約定注文(一部約定を含む)の一覧を確認するために使用します。
        特定の通貨ペアでフィルタリングすることも、すべての通貨ペアの注文を取得することもできます。
    
        使用例:
        - 現在の注文状況を確認したい場合
        - キャンセルすべき注文を特定したい場合
        - 注文戦略の進捗を確認したい場合
    
        注意: このツールを使用するには、環境変数にAPIキーとシークレットが設定されている必要があります。
    
        Args:
            currency_pair: 通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
                          指定しない場合、すべての通貨ペアの注文が返されます
    
        Returns:
            OpenOrderList: 未約定注文一覧
                - open_orders: 注文IDをキーとする注文情報の辞書
                    - currency_pair: 通貨ペア
                    - order_type: 注文タイプ('bid': 買い、'ask': 売り)
                    - price: 注文価格
                    - quantity: 注文数量
                    - order_time: 注文日時のISO 8601形式の文字列(例: '2023-05-24T15:30:45+09:00')
    
        Raises:
            ValueError: 認証情報が設定されていない場合や、APIエラーが発生した場合
        """
        if not api.trade.http.auth_provider:
            raise ValueError(
                "認証情報が設定されていません。APIキーとシークレットを.envファイルに設定してください。"
            )
    
        orders = api.trade.get_active_orders(currency_pair)
    
        # 対応している通貨ペアのみをフィルタリング
        if orders.open_orders:
            filtered_orders = {}
            for order_id, order in orders.open_orders.items():
                if order.currency_pair in ["btc_jpy", "eth_jpy", "xym_jpy"]:
                    filtered_orders[order_id] = order
    
            # 元のオブジェクトのopen_ordersを置き換え
            orders.open_orders = filtered_orders
    
        return orders
  • Schema definitions for the tool's output: OpenOrder (individual order) and OpenOrderList (dict of orders by ID), with methods to convert to/from Zaif API response dictionaries.
    class OpenOrder:
        """
        未約定注文の情報を表すデータクラス。
    
        Attributes:
            currency_pair: 通貨ペア(例: 'btc_jpy')
            order_type: 注文タイプ('bid': 買い注文、'ask': 売り注文)
            price: 注文価格(通貨単位)
            quantity: 注文数量(暗号資産の量)
            order_time: 注文日時のISO 8601形式の文字列
        """
    
        currency_pair: str
        order_type: str
        price: Decimal
        quantity: Decimal
        order_time: str
    
    
    @dataclass
    class OpenOrderList:
        """
        未約定注文一覧を表すデータクラス。
        get_open_ordersの戻り値に対応します。
    
        Attributes:
            open_orders: 注文IDをキーとする未約定注文情報の辞書
        """
    
        open_orders: Dict[int, OpenOrder]
    
        @classmethod
        def from_dict(cls, data: Dict[str, Any]) -> "OpenOrderList":
            """
            APIレスポンスからOpenOrderListインスタンスを作成します。
    
            Args:
                data: APIレスポンスの辞書
    
            Returns:
                OpenOrderListインスタンス
            """
            open_orders = {}
            for order_id_str, order_data in data.items():
                if order_id_str.isdigit():  # 注文IDのみを処理
                    order_id = int(order_id_str)
                    open_orders[order_id] = OpenOrder(
                        currency_pair=order_data.get("currency_pair", ""),
                        order_type=order_data.get("action", ""),
                        price=Decimal(str(order_data.get("price", "0"))),
                        quantity=Decimal(str(order_data.get("amount", "0"))),
                        order_time=datetime.fromtimestamp(
                            int(order_data.get("timestamp", 0))
                        ).isoformat(),
                    )
            return cls(open_orders=open_orders)
    
        def to_dict(self) -> Dict[str, Any]:
            """
            OpenOrderListインスタンスを辞書に変換します。
    
            Returns:
                APIレスポンス形式の辞書
            """
            result = {}
            for order_id, order_item in self.open_orders.items():
                result[str(order_id)] = {
                    "currency_pair": order_item.currency_pair,
                    "action": order_item.order_type,
                    "price": str(order_item.price),
                    "amount": str(order_item.quantity),
                    "date": order_item.order_time,
                }
            return result
  • Top-level registration in register_all_components: imports and invokes register_trade_tools(mcp, zaif_api), which registers the get_open_orders tool among others.
    from zaifer_mcp.tools.market import register_market_tools
    from zaifer_mcp.tools.account import register_account_tools
    from zaifer_mcp.tools.trade import register_trade_tools
    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)
  • Intermediate registration function register_trade_tools that defines and registers the get_open_orders tool using @mcp.tool() decorator.
    def register_trade_tools(mcp: FastMCP, api: ZaifApi):
        """
        Zaifの取引APIをMCPツールとして登録する
    
        Args:
            mcp: FastMCPインスタンス
            api: ZaifApiインスタンス
        """
    
        @mcp.tool()
        def place_order(
            currency_pair: SupportedPair,
            order_type: OrderType,
            price: float,
            quantity: float,
        ) -> OrderResponse:
            """
            暗号資産の売買注文を発注します。
    
            このツールは、指定した通貨ペアで新規の売買注文を市場に出すために使用します。
            価格と数量を指定して、指値注文を出すことができます。
    
            使用例:
            - ビットコインを指定価格で購入したい場合
            - イーサリアムを売却して利益を確定したい場合
            - 特定の価格で指値注文を出したい場合
    
            注意: このツールを使用するには、環境変数にAPIキーとシークレットが設定されている必要があります。
    
            Args:
                currency_pair: 取引する通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
                order_type: 注文タイプ('bid': 買い注文、'ask': 売り注文)
                price: 注文価格(日本円)- 指値注文の場合の1単位あたりの価格
                quantity: 注文数量 - 売買する暗号資産の量(例: ビットコインの場合は0.01BTCなど)
    
            Returns:
                OrderResponse: 注文結果情報
                    - filled_amount: 即時約定した数量
                    - unfilled_amount: 未約定の残り数量
                    - order_id: 注文ID(全約定の場合は0)
                    - balances: 注文後の各通貨の残高情報
    
            Raises:
                ValueError: 認証情報が設定されていない場合や、APIエラーが発生した場合
            """
            if not api.trade.http.auth_provider:
                raise ValueError(
                    "認証情報が設定されていません。APIキーとシークレットを.envファイルに設定してください。"
                )
    
            return api.trade.open_order(
                currency_pair=currency_pair,
                action=order_type,  # APIの引数名は変更できないのでマッピング
                price=Decimal(str(price)),
                amount=Decimal(str(quantity)),  # APIの引数名は変更できないのでマッピング
            )
    
        @mcp.tool()
        def cancel_order(
            order_id: int, currency_pair: SupportedPair = None
        ) -> CancelOrderResponse:
            """
            未約定の暗号資産取引注文をキャンセルします。
    
            このツールは、既に発注済みで未約定(一部約定を含む)の注文をキャンセルするために使用します。
            注文IDを指定してキャンセルでき、任意で通貨ペアも指定できます。
    
            使用例:
            - 価格変動により注文戦略を変更したい場合
            - 誤った注文をキャンセルしたい場合
            - 長時間約定しない注文を取り消したい場合
    
            注意: このツールを使用するには、環境変数にAPIキーとシークレットが設定されている必要があります。
    
            Args:
                order_id: キャンセルする注文のID(get_open_ordersで取得可能)
                currency_pair: 通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
                              指定しない場合、システムは注文IDから自動的に判断します
    
            Returns:
                CancelOrderResponse: キャンセル結果情報
                    - order_id: キャンセルした注文ID
                    - balances: キャンセル後の各通貨の残高情報
    
            Raises:
                ValueError: 認証情報が設定されていない場合や、APIエラーが発生した場合
            """
            if not api.trade.http.auth_provider:
                raise ValueError(
                    "認証情報が設定されていません。APIキーとシークレットを.envファイルに設定してください。"
                )
    
            return api.trade.cancel_order(order_id, currency_pair)
    
        @mcp.tool()
        def get_open_orders(currency_pair: SupportedPair = None) -> OpenOrderList:
            """
            現在有効な(未約定の)暗号資産取引注文一覧を取得します。
    
            このツールは、現在板に出ている未約定注文(一部約定を含む)の一覧を確認するために使用します。
            特定の通貨ペアでフィルタリングすることも、すべての通貨ペアの注文を取得することもできます。
    
            使用例:
            - 現在の注文状況を確認したい場合
            - キャンセルすべき注文を特定したい場合
            - 注文戦略の進捗を確認したい場合
    
            注意: このツールを使用するには、環境変数にAPIキーとシークレットが設定されている必要があります。
    
            Args:
                currency_pair: 通貨ペア('btc_jpy': ビットコイン/円、'eth_jpy': イーサリアム/円、'xym_jpy': シンボル/円)
                              指定しない場合、すべての通貨ペアの注文が返されます
    
            Returns:
                OpenOrderList: 未約定注文一覧
                    - open_orders: 注文IDをキーとする注文情報の辞書
                        - currency_pair: 通貨ペア
                        - order_type: 注文タイプ('bid': 買い、'ask': 売り)
                        - price: 注文価格
                        - quantity: 注文数量
                        - order_time: 注文日時のISO 8601形式の文字列(例: '2023-05-24T15:30:45+09:00')
    
            Raises:
                ValueError: 認証情報が設定されていない場合や、APIエラーが発生した場合
            """
            if not api.trade.http.auth_provider:
                raise ValueError(
                    "認証情報が設定されていません。APIキーとシークレットを.envファイルに設定してください。"
                )
    
            orders = api.trade.get_active_orders(currency_pair)
    
            # 対応している通貨ペアのみをフィルタリング
            if orders.open_orders:
                filtered_orders = {}
                for order_id, order in orders.open_orders.items():
                    if order.currency_pair in ["btc_jpy", "eth_jpy", "xym_jpy"]:
                        filtered_orders[order_id] = order
    
                # 元のオブジェクトのopen_ordersを置き換え
                orders.open_orders = filtered_orders
    
            return orders
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 key behaviors: it's a read-only operation (implied by '取得します'), requires API authentication ('環境変数にAPIキーとシークレットが設定されている必要があります'), and can raise errors for authentication or API issues. It also clarifies the scope ('一部約定を含む' - includes partially filled orders). The main gap is lack of rate limit or pagination information.

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, usage guidelines, authentication requirements, parameters, returns, errors) and uses bullet points effectively. While comprehensive, it could be slightly more concise - some information in the Returns section could potentially be moved to an output schema. However, every sentence adds value and the structure helps with readability.

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 moderate complexity (1 parameter, read operation), the description provides excellent contextual completeness. It covers purpose, usage scenarios, authentication requirements, parameter semantics, return format (with detailed field descriptions), and error conditions. The presence of an output schema would reduce the need for the Returns section, but the current description stands well on its own as a complete guide for the agent.

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 description adds substantial semantic value beyond the input schema. While the schema only shows currency_pair as an enum with three values, the description explains: 1) the parameter is optional ('指定しない場合、すべての通貨ペアの注文が返されます'), 2) provides human-readable labels for each enum value, and 3) clarifies the default behavior when not specified. With 0% schema description coverage, the description fully compensates with clear parameter documentation.

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: '現在有効な(未約定の)暗号資産取引注文一覧を取得します' (Get a list of currently active/unfilled cryptocurrency trading orders). It specifies the verb '取得します' (get/retrieve) and the resource '注文一覧' (order list), and distinguishes it from siblings like cancel_order (which modifies orders) and place_order (which creates orders).

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 three specific use cases ('使用例') and distinguishes when to use this tool versus alternatives. It mentions this is for viewing unfilled orders (including partially filled ones), while siblings like cancel_order are for modifying orders and place_order is for creating new orders. The guidance is comprehensive and practical.

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