From 25f4fdc3d966765168bfca64a25480949a68fd30 Mon Sep 17 00:00:00 2001 From: Dario Moceri Date: Thu, 28 Jan 2021 21:14:47 +0100 Subject: [PATCH] added endpoint rest auth order multi op (https://docs.bitfinex.com/reference#rest-auth-order-multi) --- CHANGELOG | 1 + bfxapi/rest/bfx_rest.py | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 5e1fb20..ff2c371 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ - Implemented Keep funding endpoint (rest) - Implemented Cancel order multi endpoint (rest) - Implemented Public Stats endpoint (rest) +- Implemented Order Multi OP endpoint (rest) 1.1.8 - Adds support for websocket events pu, pn and pu diff --git a/bfxapi/rest/bfx_rest.py b/bfxapi/rest/bfx_rest.py index 92f27ed..f96d3c5 100644 --- a/bfxapi/rest/bfx_rest.py +++ b/bfxapi/rest/bfx_rest.py @@ -335,6 +335,7 @@ class BfxRest: endpoint += f"limit={limit}" message = await self.fetch(endpoint) return message + ################################################## # Authenticated Data # ################################################## @@ -808,6 +809,67 @@ class BfxRest: raw_notification = await self.post(endpoint, payload) return Notification.from_raw_notification(raw_notification) + async def submit_order_multi_op(self, orders): + """ + Send Multiple order-related operations. + Please note the sent object has only one property with a value + of an array of arrays detailing each order operation. + + https://docs.bitfinex.com/reference#rest-auth-order-multi + + Expected orders -> + [ + ["on", { // Order Submit + type: "EXCHANGE LIMIT", + symbol: "tBTCUSD", + price: "123.45", + amount: "1.2345", + flags: 0 + }], + ["oc", { ... }], + ... + ] + + @param type string + Available values -> LIMIT, EXCHANGE LIMIT, MARKET, EXCHANGE MARKET, + STOP, EXCHANGE STOP, STOP LIMIT, EXCHANGE STOP LIMIT, TRAILING STOP, + EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK, IOC, EXCHANGE IOC + + @param symbol string: symbol of order + + @param price string: price of order + + @param amount string: amount of order (positive for buy, negative for sell) + + @param flags int: (optional) see https://docs.bitfinex.com/v2/docs/flag-values + + @param lev int: set the leverage for a derivative order, supported + by derivative symbol orders only. The value should be between 1 and + 100 inclusive. The field is optional, if omitted the default leverage value of 10 will be used. + + @param price_trailing string: the trailing price for a trailing stop order + + @param price_aux_limit string: auxiliary Limit price (for STOP LIMIT) + + @param price_oco_stop string: OCO stop price + + @param gid int: group order id + + @param tif string: Time-In-Force - datetime for automatic order cancellation (YYYY-MM-DD HH:MM:SS) + + @param id int: Order ID (can be retrieved by calling the Retrieve Orders endpoint) + + @param cid int: Client Order ID + + @param cid_date string: Client Order ID Date (YYYY-MM-DD) + + @param all int: cancel all open orders if value is set to 1 + """ + payload = {"ops": orders} + endpoint = "auth/w/order/multi" + raw_notification = await self.post(endpoint, payload) + return Notification.from_raw_notification(raw_notification) + async def get_auth_pulse_hist(self, is_public=None): """ Allows you to retrieve your private pulse history or the public pulse history with an additional UID_LIKED field.