Client¶
- class gmocoin_client.client.Client(api_key=None, api_secret=None, *, public_base_url='https://api.coin.z.com/public', private_base_url='https://api.coin.z.com/private', timeout=10.0, raise_on_error=True, client=None)[source]¶
Bases:
objectGMO Coin REST API client
GMO Coin の REST API クライアント
- Parameters:
api_key (str | None)
api_secret (str | None)
public_base_url (str)
private_base_url (str)
timeout (float | None)
raise_on_error (bool)
client (httpx.Client | None)
- get_status()[source]¶
Fetch service status.
サービスステータスを取得します。
Docs: https://api.coin.z.com/docs/#status
- Parameters:
None.
- Returns:
APIResponse containing service status data.
- Return type:
Examples
{ "status": 0, "data": { "status": "OPEN" }, "responsetime": "2019-03-19T02:15:06.001Z" }
- get_ticker(symbol=None)[source]¶
Fetch latest ticker rates.
最新レートを取得します。パラメータ指定がない場合、全シンボルの情報を返します。
Docs: https://api.coin.z.com/docs/#ticker
- Parameters:
symbol (str | None) – Optional symbol filter. If omitted, returns all symbols.
- Returns:
APIResponse containing a list of ticker items.
- Return type:
APIResponse[list[TickerItem]]
Examples
{ "status": 0, "data": [ { "ask": "750760", "bid": "750600", "high": "762302", "last": "756662", "low": "704874", "symbol": "BTC", "timestamp": "2018-03-30T12:34:56.789Z", "volume": "194785.8484" } ], "responsetime": "2019-03-19T02:15:06.014Z" }
- get_orderbooks(symbol)[source]¶
Fetch order book snapshot for a symbol.
板情報(スナップショット)を取得します。
Docs: https://api.coin.z.com/docs/#orderbooks
- Parameters:
symbol (str) – Target symbol (e.g., “BTC”).
- Returns:
APIResponse containing order book data.
- Return type:
Examples
{ "status": 0, "data": { "asks": [ { "price": "455659", "size": "0.1" } ], "bids": [ { "price": "455659", "size": "0.1" } ], "symbol": "BTC" }, "responsetime": "2019-03-19T02:15:06.026Z" }
- get_trades(symbol, *, page=None, count=None)[source]¶
Fetch recent trades for a symbol.
約定履歴を取得します。
Docs: https://api.coin.z.com/docs/#trades
- Parameters:
symbol (str) – Target symbol (e.g., “BTC”).
page (int | None) – Optional page number.
count (int | None) – Optional page size.
- Returns:
APIResponse containing trades data.
- Return type:
Examples
{ "status": 0, "data": { "pagination": { "currentPage": 1, "count": 30 }, "list": [ { "price": "750760", "side": "BUY", "size": "0.1", "timestamp": "2018-03-30T12:34:56.789Z" } ] }, "responsetime": "2019-03-28T09:28:07.980Z" }
- get_klines(symbol, interval, date)[source]¶
Fetch OHLCV kline data.
ローソク足データを取得します。
Docs: https://api.coin.z.com/docs/#klines
- Parameters:
symbol (str) – Target symbol (e.g., “BTC”).
interval (str) – Kline interval (e.g., “1min”).
date (str) – Date filter (YYYYMMDD or YYYY).
- Returns:
APIResponse containing a list of kline items.
- Return type:
APIResponse[list[KlineItem]]
Examples
{ "status": 0, "data": [ { "openTime":"1618588800000", "open":"6418255", "high":"6518250", "low":"6318250", "close":"6418253", "volume":"0.0001" }, { "openTime":"1618588860000", "open":"6418251", "high":"6418252", "low":"6415250", "close":"6418245", "volume":"0.0001" } ], "responsetime": "2019-03-28T09:28:07.980Z" }
- get_symbols()[source]¶
Fetch trading rules and symbols.
取引ルールとシンボル情報を取得します。
Docs: https://api.coin.z.com/docs/#symbols
- Parameters:
None.
- Returns:
APIResponse containing symbol rules.
- Return type:
APIResponse[list[SymbolRule]]
Examples
{ "status": 0, "data": [ { "symbol": "BTC", "minOrderSize": "0.0001", "maxOrderSize": "5", "sizeStep": "0.0001", "tickSize": "1", "takerFee": "0.0005", "makerFee": "-0.0001" }, { "symbol": "BTC_JPY", "minOrderSize": "0.01", "maxOrderSize": "5", "sizeStep": "0.01", "tickSize": "1", "takerFee": "0", "makerFee": "0" } ], "responsetime": "2022-12-15T19:22:23.792Z" }
- get_margin()[source]¶
Fetch margin summary.
証拠金サマリーを取得します。
Docs: https://api.coin.z.com/docs/#margin
- Parameters:
None.
- Returns:
APIResponse containing margin data.
- Return type:
Examples
{ "status": 0, "data": { "actualProfitLoss": "68286188", "availableAmount": "57262506", "margin": "1021682", "marginCallStatus": "NORMAL", "marginRatio": "6683.6", "profitLoss": "0", "transferableAmount": "57262506" }, "responsetime": "2019-03-19T02:15:06.051Z" }
- get_assets()[source]¶
Fetch asset balances.
資産残高を取得します。
Docs: https://api.coin.z.com/docs/#assets
- Parameters:
None.
- Returns:
APIResponse containing asset balances.
- Return type:
APIResponse[list[AssetItem]]
Examples
{ "status": 0, "data": [ { "amount": "993982448", "available": "993982448", "conversionRate": "1", "symbol": "JPY" }, { "amount": "4.0002", "available": "4.0002", "conversionRate": "859614", "symbol": "BTC" } ], "responsetime": "2019-03-19T02:15:06.055Z" }
- get_trading_volume()[source]¶
Fetch trading volume information.
取引量情報を取得します。
Docs: https://api.coin.z.com/docs/#tradingVolume
- Parameters:
None.
- Returns:
APIResponse containing trading volume data.
- Return type:
Examples
{ "status": 0, "data": { "jpyVolume": "9988888", "tierLevel": 1, "limit": [ { "symbol": "BTC/JPY", "todayLimitOpenSize": "10000", "takerFee": "0", "makerFee": "0" }, { "symbol": "BTC", "todayLimitBuySize": "98", "todayLimitSellSize": "102", "takerFee": "0.0015", "makerFee": "-0.0007" } ] }, "responsetime": "2019-03-19T02:15:06.055Z" }
- get_fiat_deposits(from_timestamp, *, to_timestamp=None)[source]¶
Fetch fiat deposit history.
日本円の入金履歴を取得します。
Docs: https://api.coin.z.com/docs/#fiatDepositHistory
- Parameters:
from_timestamp (str) – Start time in UTC ISO8601 format with milliseconds.
to_timestamp (str | None) – Optional end time in UTC ISO8601 format with milliseconds.
- Returns:
APIResponse containing fiat deposit history records.
- Return type:
APIResponse[list[FiatHistoryItem]]
Examples
{ "status": 0, "data": [ { "amount": "50000", "fee": "0", "status": "EXECUTED", "symbol": "JPY", "timestamp": "2021-01-01T13:47:12.791Z" } ], "responsetime": "2024-02-28T11:48:57.996Z" }
- get_fiat_withdrawals(from_timestamp, *, to_timestamp=None)[source]¶
Fetch fiat withdrawal history.
日本円の出金履歴を取得します。
Docs: https://api.coin.z.com/docs/#fiatWithdrawalHistory
- Parameters:
from_timestamp (str) – Start time in UTC ISO8601 format with milliseconds.
to_timestamp (str | None) – Optional end time in UTC ISO8601 format with milliseconds.
- Returns:
APIResponse containing fiat withdrawal history records.
- Return type:
APIResponse[list[FiatHistoryItem]]
Examples
{ "status": 0, "data": [ { "amount": "50000", "fee": "0", "status": "EXECUTED", "symbol": "JPY", "timestamp": "2021-01-01T13:47:12.791Z" } ], "responsetime": "2024-02-28T11:48:57.996Z" }
- get_crypto_deposits(symbol, from_timestamp, *, to_timestamp=None)[source]¶
Fetch cryptocurrency deposit history.
暗号資産の入金履歴を取得します。
Docs: https://api.coin.z.com/docs/#depositHistory
- Parameters:
symbol (str) – Asset symbol to filter (e.g., “BTC”).
from_timestamp (str) – Start time in UTC ISO8601 format with milliseconds.
to_timestamp (str | None) – Optional end time in UTC ISO8601 format with milliseconds.
- Returns:
APIResponse containing a list of deposit history records.
- Return type:
APIResponse[list[CryptoHistoryItem]]
Examples
{ "status": 0, "data": [ { "address": "xxx", "amount": "0.9503", "status": "EXECUTED", "symbol": "BTC", "timestamp": "2021-10-05T06:04:46.241Z", "txHash": "yyy" } ], "responsetime": "2024-02-28T12:20:07.103Z" }
- get_crypto_withdrawals(symbol, from_timestamp, *, to_timestamp=None)[source]¶
Fetch cryptocurrency withdrawal history.
暗号資産の出金履歴を取得します。
Docs: https://api.coin.z.com/docs/#withdrawalHistory
- Parameters:
symbol (str) – Asset symbol to filter (e.g., “BTC”).
from_timestamp (str) – Start time in UTC ISO8601 format with milliseconds.
to_timestamp (str | None) – Optional end time in UTC ISO8601 format with milliseconds.
- Returns:
APIResponse containing withdrawal history records.
- Return type:
APIResponse[list[CryptoHistoryItem]]
Examples
{ "status": 0, "data": [ { "address": "xxx", "amount": "0.9503", "status": "EXECUTED", "symbol": "BTC", "timestamp": "2021-10-05T06:04:46.241Z", "txHash": "yyy" } ], "responsetime": "2024-02-28T12:20:07.103Z" }
- get_orders(order_ids)[source]¶
Fetch order information by order IDs.
注文情報を取得します。
Docs: https://api.coin.z.com/docs/#orders
- Parameters:
order_ids (Iterable[Any] | str | int) – Order ID or list of order IDs (comma-separated for multiple).
- Returns:
APIResponse containing order list data.
- Return type:
Examples
{ "status": 0, "data": { "list": [ { "orderId": 223456789, "rootOrderId": 223456789, "symbol": "BTC_JPY", "side": "BUY", "orderType": "NORMAL", "executionType": "LIMIT", "settleType": "OPEN", "size": "0.02", "executedSize": "0.02", "price": "1430001", "losscutPrice": "0", "status": "EXECUTED", "timeInForce": "FAS", "timestamp": "2020-10-14T20:18:59.343Z" }, { "rootOrderId": 123456789, "orderId": 123456789, "symbol": "BTC", "side": "BUY", "orderType": "NORMAL", "executionType": "LIMIT", "settleType": "OPEN", "size": "1", "executedSize": "0", "price": "900000", "losscutPrice": "0", "status": "CANCELED", "cancelType": "USER", "timeInForce": "FAS", "timestamp": "2019-03-19T02:15:06.059Z" } ] }, "responsetime": "2019-03-19T02:15:06.059Z" }
- get_active_orders(symbol, *, page=None, count=None)[source]¶
Fetch active orders for a symbol.
注文中のオーダー一覧を取得します。
Docs: https://api.coin.z.com/docs/#active-orders
- Parameters:
symbol (str) – Target symbol (e.g., “BTC”).
page (int | None) – Optional page number.
count (int | None) – Optional page size.
- Returns:
APIResponse containing active orders data.
- Return type:
Examples
{ "status": 0, "data": { "pagination": { "currentPage": 1, "count": 30 }, "list": [ { "rootOrderId": 123456789, "orderId": 123456789, "symbol": "BTC", "side": "BUY", "orderType": "NORMAL", "executionType": "LIMIT", "settleType": "OPEN", "size": "1", "executedSize": "0", "price": "840000", "losscutPrice": "0", "status": "ORDERED", "timeInForce": "FAS", "timestamp": "2019-03-19T01:07:24.217Z" } ] }, "responsetime": "2019-03-19T01:07:24.217Z" }
- get_executions(*, order_id=None, execution_id=None)[source]¶
Fetch executions for an order or execution IDs.
約定情報を取得します。
Docs: https://api.coin.z.com/docs/#executions
- Parameters:
order_id (int | None) – Optional order ID.
execution_id (Iterable[Any] | str | int | None) – Optional execution ID or list of IDs.
- Returns:
APIResponse containing executions data.
- Return type:
Examples
{ "status": 0, "data": { "list": [ { "executionId": 92123912, "orderId": 223456789, "positionId": 1234567, "symbol": "BTC_JPY", "side": "BUY", "settleType": "OPEN", "size": "0.02", "price": "1900000", "lossGain": "0", "fee": "223", "timestamp": "2020-11-24T21:27:04.764Z" }, { "executionId": 72123911, "orderId": 123456789, "positionId": 1234567, "symbol": "BTC", "side": "BUY", "settleType": "OPEN", "size": "0.7361", "price": "877404", "lossGain": "0", "fee": "323", "timestamp": "2019-03-19T02:15:06.081Z" } ] }, "responsetime": "2019-03-19T02:15:06.081Z" }
- get_latest_executions(symbol, *, page=None, count=None)[source]¶
Fetch latest executions.
最新約定情報を取得します。
Docs: https://api.coin.z.com/docs/#latest-executions
- Parameters:
symbol (str) – Target symbol (e.g., “BTC”).
page (int | None) – Optional page number.
count (int | None) – Optional page size.
- Returns:
APIResponse containing latest executions data.
- Return type:
Examples
{ "status": 0, "data": { "pagination": { "currentPage": 1, "count": 30 }, "list": [ { "executionId": 72123911, "orderId": 123456789, "positionId": 1234567, "symbol": "BTC", "side": "BUY", "settleType": "OPEN", "size": "0.7361", "price": "877404", "lossGain": "0", "fee": "323", "timestamp": "2019-03-19T02:15:06.086Z" } ] }, "responsetime": "2019-03-19T02:15:06.086Z" }
- create_order(*, symbol, side, execution_type, size, time_in_force=None, price=None, losscut_price=None, cancel_before=None)[source]¶
Create a new order.
新規注文を発注します。
Docs: https://api.coin.z.com/docs/#order
- Parameters:
symbol (str) – Target symbol (e.g., “BTC_JPY”).
side (str) – Order side (“BUY” or “SELL”).
execution_type (str) – Order execution type (e.g., “LIMIT”).
size (str) – Order size.
time_in_force (str | None) – Optional time-in-force value.
price (str | None) – Optional price (required for LIMIT/STOP).
losscut_price (str | None) – Optional losscut price (margin only).
cancel_before (bool | None) – Optional cancel-before flag.
- Returns:
APIResponse with the new order ID.
- Return type:
Any
Examples
{ "status": 0, "data": "637000", "responsetime": "2019-03-19T02:15:06.108Z" }
- change_order(*, order_id, price, losscut_price=None)[source]¶
Change an existing order.
注文を変更します。
Docs: https://api.coin.z.com/docs/#change-order
- Parameters:
order_id (int) – Order ID to modify.
price (str) – New price.
losscut_price (str | None) – Optional losscut price.
- Returns:
APIResponse containing the status of the change request.
- Return type:
Any
Examples
{ "status": 0, "responsetime": "2019-03-19T01:07:24.557Z" }
- cancel_order(order_id)[source]¶
Cancel a single order.
注文をキャンセルします。
Docs: https://api.coin.z.com/docs/#cancel-order
- Parameters:
order_id (int) – Order ID to cancel.
- Returns:
APIResponse containing the status of the cancel request.
- Return type:
Any
Examples
{ "status": 0, "responsetime": "2019-03-19T01:07:24.557Z" }
- cancel_orders(order_ids)[source]¶
Cancel multiple orders.
複数注文をキャンセルします。
Docs: https://api.coin.z.com/docs/#cancel-orders
- Parameters:
order_ids (Iterable[Any]) – List of order IDs (max 10).
- Returns:
APIResponse containing success and failure results.
- Return type:
Any
Examples
{ "status": 0, "data": { "failed": [ { "message_code": "ERR-5122", "message_string": "The request is invalid due to the status of the specified order.", "orderId": 1 }, { "message_code": "ERR-5122", "message_string": "The request is invalid due to the status of the specified order.", "orderId": 2 } ], "success": [3,4] }, "responsetime": "2019-03-19T01:07:24.557Z" }
- cancel_bulk_order(symbols, *, side=None, settle_type=None, desc=None)[source]¶
Cancel bulk orders matching criteria.
一括キャンセルを実行します。
Docs: https://api.coin.z.com/docs/#cancel-bulk-order
- Parameters:
symbols (Iterable[str]) – Symbols to target.
side (str | None) – Optional side filter.
settle_type (str | None) – Optional settle type filter.
desc (bool | None) – Optional ordering flag for cancellation.
- Returns:
APIResponse containing canceled order IDs.
- Return type:
Any
Examples
{ "status": 0, "data": [637000,637002], "responsetime": "2019-03-19T01:07:24.557Z" }
- get_open_positions(symbol, *, page=None, count=None)[source]¶
Fetch open positions.
建玉一覧を取得します。
Docs: https://api.coin.z.com/docs/#open-positions
- Parameters:
symbol (str) – Margin trading symbol (e.g., “BTC_JPY”).
page (int | None) – Optional page number.
count (int | None) – Optional page size.
- Returns:
APIResponse containing open positions data.
- Return type:
Examples
{ "status": 0, "data": { "pagination": { "currentPage": 1, "count": 30 }, "list": [ { "positionId": 1234567, "symbol": "BTC_JPY", "side": "BUY", "size": "0.22", "orderdSize": "0", "price": "876045", "lossGain": "14", "leverage": "4", "losscutPrice": "766540", "timestamp": "2019-03-19T02:15:06.094Z" } ] }, "responsetime": "2019-03-19T02:15:06.095Z" }
- get_position_summary(symbol=None)[source]¶
Fetch position summary.
ポジションサマリーを取得します。
Docs: https://api.coin.z.com/docs/#position-summary
- Parameters:
symbol (str | None) – Optional margin symbol filter.
- Returns:
APIResponse containing position summary data.
- Return type:
Examples
{ "status": 0, "data": { "list": [ { "averagePositionRate": "715656", "positionLossGain": "250675", "side": "BUY", "sumOrderQuantity": "2", "sumPositionQuantity": "11.6999", "symbol": "BTC_JPY" } ] }, "responsetime": "2019-03-19T02:15:06.102Z" }
- transfer(*, amount, transfer_type)[source]¶
Transfer funds between accounts.
口座間振替を実行します。
Docs: https://api.coin.z.com/docs/#transfer
- Parameters:
amount (str) – Transfer amount in JPY.
transfer_type (str) – Transfer type (“WITHDRAWAL” or “DEPOSIT”).
- Returns:
APIResponse containing transferred amount.
- Return type:
Any
Examples
{ "status": 0, "data": [ { "transferredAmount": "100000" } ], "responsetime": "2019-03-19T02:15:06.055Z" }
- close_order(*, symbol, side, execution_type, settle_positions, time_in_force=None, price=None, cancel_before=None)[source]¶
Close a position with a settlement order.
建玉を決済します。
Docs: https://api.coin.z.com/docs/#close-order
- Parameters:
symbol (str) – Margin trading symbol (e.g., “BTC_JPY”).
side (str) – Order side (“BUY” or “SELL”).
execution_type (str) – Execution type (e.g., “LIMIT”).
settle_positions (Iterable[Mapping[str, Any]]) – List of position IDs and sizes to close.
time_in_force (str | None) – Optional time-in-force.
price (str | None) – Optional price (required for LIMIT/STOP).
cancel_before (bool | None) – Optional cancel-before flag.
- Returns:
APIResponse with the new closing order ID.
- Return type:
Any
Examples
{ "status": 0, "data": "637000", "responsetime": "2019-03-19T01:07:24.557Z" }
- close_bulk_order(*, symbol, side, execution_type, size, time_in_force=None, price=None)[source]¶
Close positions in bulk.
複数建玉の一括決済を行います。
Docs: https://api.coin.z.com/docs/#close-bulk-order
- Parameters:
symbol (str) – Margin trading symbol (e.g., “BTC_JPY”).
side (str) – Order side (“BUY” or “SELL”).
execution_type (str) – Execution type (e.g., “LIMIT”).
size (str) – Order size.
time_in_force (str | None) – Optional time-in-force.
price (str | None) – Optional price (required for LIMIT/STOP).
- Returns:
APIResponse with the new closing bulk order ID.
- Return type:
Any
Examples
{ "status": 0, "data": "637000", "responsetime": "2019-03-19T01:07:24.557Z" }
- change_losscut_price(*, position_id, losscut_price)[source]¶
Change losscut price for a position.
ロスカットレートを変更します。
Docs: https://api.coin.z.com/docs/#change-losscut-price
- Parameters:
position_id (int) – Position ID to update.
losscut_price (str) – New losscut price.
- Returns:
APIResponse containing status of the update.
- Return type:
Any
Examples
{ "status": 0, "responsetime": "2019-03-19T01:07:24.557Z" }
- ws_auth_create()[source]¶
Create a WebSocket access token.
WebSocketアクセストークンを発行します。
Docs: https://api.coin.z.com/docs/en/?rust#ws-auth-post
- Parameters:
None.
- Returns:
APIResponse containing the access token.
- Return type:
Any
Examples
{ "status": 0, "data": "xxxxxxxxxxxxxxxxxxxx", "responsetime": "2019-03-19T02:15:06.102Z" }
- ws_auth_extend(token)[source]¶
Extend a WebSocket access token.
WebSocketアクセストークンの期限を延長します。
Docs: https://api.coin.z.com/docs/en/?rust#ws-auth-put
- Parameters:
token (str) – Access token to extend.
- Returns:
APIResponse containing status of the update.
- Return type:
Any
Examples
{ "status": 0, "responsetime": "2019-03-19T02:15:06.102Z" }
- ws_auth_delete(token)[source]¶
Delete a WebSocket access token.
WebSocketアクセストークンを削除します。
Docs: https://api.coin.z.com/docs/en/?rust#ws-auth-delete
- Parameters:
token (str) – Access token to delete.
- Returns:
APIResponse containing status of the deletion.
- Return type:
Any
Examples
{ "status": 0, "responsetime": "2019-03-19T02:15:06.102Z" }