from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX def close_position( self, client_order_id: str, product_id: str, size: Optional[str] = None, **kwargs ) -> Dict[str, Any]: """ **Close Position** _________________ [POST] https://api.coinbase.com/api/v3/brokerage/orders/close_position __________ **Description:** Places an order to close any open positions for a specified ``product_id``. __________ **Read more on the official documentation:** `Close Position `_ """ endpoint = f"{API_PREFIX}/orders/close_position" data = {"client_order_id": client_order_id, "product_id": product_id, "size": size} return self.post(endpoint, data=data, **kwargs) def get_futures_balance_summary(self, **kwargs) -> Dict[str, Any]: """ **Get Futures Balance Summary** _______________________________ [GET] https://api.coinbase.com/api/v3/brokerage/cfm/balance_summary __________ **Description:** Get information on your balances related to `Coinbase Financial Markets `_ (CFM) futures trading. __________ **Read more on the official documentation:** `Get Futures Balance Summary `_ """ endpoint = f"{API_PREFIX}/cfm/balance_summary" return self.get(endpoint, **kwargs) def list_futures_positions(self, **kwargs) -> Dict[str, Any]: """ **List Futures Positions** __________________________ [GET] https://api.coinbase.com/api/v3/brokerage/cfm/positions __________ **Description:** Get a list of all open positions in CFM futures products. __________ **Read more on the official documentation:** `List Futures Positions `_ """ endpoint = f"{API_PREFIX}/cfm/positions" return self.get(endpoint, **kwargs) def get_futures_position(self, product_id: str, **kwargs) -> Dict[str, Any]: """ **Get Futures Position** _________________________ [GET] https://api.coinbase.com/api/v3/brokerage/cfm/positions/{product_id} __________ **Description:** Get the position of a specific CFM futures product. __________ **Read more on the official documentation:** `Get Futures Position `_ """ endpoint = f"{API_PREFIX}/cfm/positions/{product_id}" return self.get(endpoint, **kwargs) def schedule_futures_sweep(self, usd_amount: str, **kwargs) -> Dict[str, Any]: """ **Schedule Futures Sweep** __________________________ [POST] https://api.coinbase.com/api/v3/brokerage/cfm/sweeps/schedule __________ **Description:** Schedule a sweep of funds from your CFTC-regulated futures account to your Coinbase Inc. USD Spot wallet. __________ **Read more on the official documentation:** `Schedule Futures Sweep `_ """ endpoint = f"{API_PREFIX}/cfm/sweeps/schedule" data = {"usd_amount": usd_amount} return self.post(endpoint, data=data, **kwargs) def list_futures_sweeps(self, **kwargs) -> Dict[str, Any]: """ **List Futures Sweeps** _______________________ [GET] https://api.coinbase.com/api/v3/brokerage/cfm/sweeps __________ **Description:** Get information on your pending and/or processing requests to sweep funds from your CFTC-regulated futures account to your Coinbase Inc. USD Spot wallet. __________ **Read more on the official documentation:** `List Futures Sweeps `_ """ endpoint = f"{API_PREFIX}/cfm/sweeps" return self.get(endpoint, **kwargs) def cancel_pending_futures_sweep(self, **kwargs) -> Dict[str, Any]: """ **Cancel Pending Futures Sweep** ________________________________ [DELETE] https://api.coinbase.com/api/v3/brokerage/cfm/sweeps __________ **Description:** Cancel your pending sweep of funds from your CFTC-regulated futures account to your Coinbase Inc. USD Spot wallet. __________ **Read more on the official documentation:** `Cancel Pending Futures Sweep `_ """ endpoint = f"{API_PREFIX}/cfm/sweeps" return self.delete(endpoint, **kwargs)