Skip to content

Commit 9e510d7

Browse files
authored
Cancel All Open Orders - Extended to support any status of orders to be sent for cancellation (#62)
* bumped to v0.2 * updated cancel all orders call * updated cancel_all_open_orders to accept status of orders to be cancelled * renamed to cancel_all_orders * renamed method * updated description --------- Co-authored-by: YameenMalik <[email protected]>
1 parent c1c7a79 commit 9e510d7

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

examples/7.cancelling_orders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
from config import TEST_ACCT_KEY, TEST_NETWORK
3-
from firefly_exchange_client import FireflyClient, Networks, MARKET_SYMBOLS, ORDER_SIDE, ORDER_TYPE
3+
from firefly_exchange_client import FireflyClient, Networks, MARKET_SYMBOLS, ORDER_SIDE, ORDER_TYPE, ORDER_STATUS
44
from pprint import pprint
55
import asyncio
66

@@ -46,7 +46,7 @@ async def main():
4646
pprint(resp)
4747

4848
# cancels all open orders, returns false if there is no open order to cancel
49-
resp = await client.cancel_all_open_orders(MARKET_SYMBOLS.ETH)
49+
resp = await client.cancel_all_orders(MARKET_SYMBOLS.ETH, [ORDER_STATUS.OPEN, ORDER_STATUS.PARTIAL_FILLED])
5050

5151
if resp == False:
5252
print('No open order to cancel')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "firefly_exchange_client"
3-
version = "0.1.3"
3+
version = "0.2.0"
44
description = "Library to interact with firefly exchange protocol including its off-chain api-gateway and on-chain contracts"
55
readme = "README.md"
66
requires-python = ">=3.8"

src/firefly_exchange_client/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,22 @@ async def post_cancel_order(self,params:OrderCancellationRequest):
264264
auth_required=True
265265
)
266266

267-
async def cancel_all_open_orders(self,symbol:MARKET_SYMBOLS, parentAddress:str=""):
267+
async def cancel_all_orders(self, symbol:MARKET_SYMBOLS, status: List[ORDER_STATUS], parentAddress:str=""):
268268
"""
269-
GETs all open orders for the specified symbol, creates a cancellation request
270-
for all orders and POSTs the cancel order request to Firefly
269+
GETs all orders of specified status for the specified symbol,
270+
and creates a cancellation request for all orders and
271+
POSTs the cancel order request to Firefly
271272
Inputs:
272273
- symbol (MARKET_SYMBOLS): Market for which orders are to be cancelled
274+
- status (List[ORDER_STATUS]): status of orders that need to be cancelled
273275
- parentAddress (str): address of parent account, only provided by sub account
274276
Returns:
275277
- dict: response from orders delete API Firefly
276278
"""
277279
orders = await self.get_orders({
278280
"symbol":symbol,
279281
"parentAddress": parentAddress,
280-
"statuses":[ORDER_STATUS.OPEN, ORDER_STATUS.PARTIAL_FILLED]
282+
"statuses":status
281283
})
282284

283285
hashes = []

0 commit comments

Comments
 (0)