async def get_trade_history(self, limit: int = None, ascending=False, order_id: str = None, last_id: str = None, from_timestamp: datetime.datetime = None, to_timestamp: datetime.datetime = None, pair: Pair = None) -> dict: params = CoinmateClient._clean_request_params({ "limit": limit, "orderId": order_id, "lastId": last_id }) if pair is not None: params['currencyPair'] = map_pair(pair) if ascending is True: params['sort'] = 'ASC' else: params['sort'] = 'DESC' if from_timestamp is not None: params["timestampFrom"] = from_timestamp.astimezone( pytz.utc).isoformat() if to_timestamp is not None: params["timestampTo"] = to_timestamp.astimezone( pytz.utc).isoformat() return await self._create_post("tradeHistory", params=params, signed=True)
async def get_fees(self, pair: Pair = None) -> dict: params = {} if pair is not None: params['currencyPair'] = map_pair(pair) return await self._create_post("traderFees", params=params, signed=True)
async def get_order_book(self, pair: Pair, group: bool = False) -> dict: params = CoinmateClient._clean_request_params({ "currencyPair": map_pair(pair), "groupByPriceLimit": group }) return await self._create_get("orderBook", params=params)
async def cancel_all_orders(self, pair: Pair = None) -> dict: params = {} if pair is not None: params["currencyPair"] = map_pair(pair) return await self._create_post("cancelAllOpenOrders", params=params, signed=True)
async def get_transactions(self, minutes_history: int, currency_pair: Pair = None) -> dict: params = CoinmateClient._clean_request_params( {"minutesIntoHistory": minutes_history}) if currency_pair is not None: params['currencyPair'] = map_pair(currency_pair) return await self._create_get("transactions", params=params)
async def get_order_history(self, pair: Pair, limit: int = None) -> dict: params = CoinmateClient._clean_request_params({ "currencyPair": map_pair(pair), "limit": limit }) return await self._create_post("orderHistory", params=params, signed=True)
async def create_order(self, type: enums.OrderType, pair: Pair, side: enums.OrderSide, amount: str, price: str = None, stop_price: str = None, trailing: bool = None, hidden: bool = None, time_in_force: enums.TimeInForce = None, post_only: bool = None, client_id: str = None) -> dict: params = CoinmateClient._clean_request_params({ "currencyPair": map_pair(pair), "price": price, "stopPrice": stop_price, "clientOrderId": client_id }) if type == enums.OrderType.MARKET: if side == enums.OrderSide.BUY: endpoint = "buyInstant" params["total"] = amount else: endpoint = "sellInstant" params["amount"] = amount else: if side == enums.OrderSide.BUY: endpoint = "buyLimit" else: endpoint = "sellLimit" params["amount"] = amount if trailing is True: params["trailing"] = "1" if hidden is True: params["hidden"] = "1" if post_only is True: params["postOnly"] = "1" if time_in_force == enums.TimeInForce.IMMEDIATE_OR_CANCELLED: params["immediateOrCancel"] = "1" return await self._create_post(endpoint, params=params, signed=True)
async def get_ticker(self, pair: Pair) -> dict: params = CoinmateClient._clean_request_params( {"currencyPair": map_pair(pair)}) return await self._create_get("ticker", params=params)