diff --git a/testing/api-sample-scripts/delete_order.py b/testing/api-sample-scripts/delete_order.py index 3bea41b96..e28a04a9e 100644 --- a/testing/api-sample-scripts/delete_order.py +++ b/testing/api-sample-scripts/delete_order.py @@ -1,7 +1,13 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'delete_order', 'params': {'order_id': 541002}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "delete_order", + "params": { + "order_id": 541002 + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message): diff --git a/testing/api-sample-scripts/enter_cover_order.py b/testing/api-sample-scripts/enter_cover_order.py index 195a96854..44bd93867 100644 --- a/testing/api-sample-scripts/enter_cover_order.py +++ b/testing/api-sample-scripts/enter_cover_order.py @@ -1,7 +1,26 @@ import json import websocket -json_payload = {'price': 1646.8, 'quantity': 1, 'order_type': 'cover', 'side': 'buy', 'account': 'main', 'user': 'bts', 'exchange_securty_name': 'ETH-31MAR23', 'venue': 'deribit', 'custom': {'hedge_ticks': 2, 'cancel_on_external_hedge_cancel': True, 'cancel_hedges_on_cancel': True, 'detach_hedges': False}} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "enter_order", + "params": { + "price": 1646.8, + "quantity": 1, + "order_type": "cover", + "side": "buy", + "account": "main", + "user": "bts", + "exchange_securty_name": "ETH-31MAR23", + "venue": "deribit", + "custom": { + "hedge_ticks": 2, + "cancel_on_external_hedge_cancel": true, + "cancel_hedges_on_cancel": true, + "detach_hedges": false + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message): diff --git a/testing/api-sample-scripts/enter_iceberg_order.py b/testing/api-sample-scripts/enter_iceberg_order.py index 114b9a896..aac6d5c3b 100644 --- a/testing/api-sample-scripts/enter_iceberg_order.py +++ b/testing/api-sample-scripts/enter_iceberg_order.py @@ -1,7 +1,23 @@ import json import websocket -json_payload = {'price': 1646.8, 'quantity': 1, 'order_type': 'iceberg', 'side': 'buy', 'account': 'main', 'user': 'bts', 'exchange_securty_name': 'ETH-31MAR23', 'venue': 'deribit', 'custom': {'showquanity': 5}} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "enter_order", + "params": { + "price": 1646.8, + "quantity": 1, + "order_type": "iceberg", + "side": "buy", + "account": "main", + "user": "bts", + "exchange_securty_name": "ETH-31MAR23", + "venue": "deribit", + "custom": { + "showquanity": 5 + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message): diff --git a/testing/api-sample-scripts/enter_limit_order.py b/testing/api-sample-scripts/enter_limit_order.py index 52a658a4e..4c2322dd4 100644 --- a/testing/api-sample-scripts/enter_limit_order.py +++ b/testing/api-sample-scripts/enter_limit_order.py @@ -1,7 +1,21 @@ import json import websocket -json_payload = {'price': 1646.8, 'quantity': 1, 'order_type': 'limit', 'side': 'buy', 'account': 'main', 'user': 'bts', 'exchange_securty_name': 'ETH-31MAR23', 'venue': 'deribit', 'custom': {}} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "enter_order", + "params": { + "price": 1646.8, + "quantity": 1, + "order_type": "limit", + "side": "buy", + "account": "main", + "user": "bts", + "exchange_securty_name": "ETH-31MAR23", + "venue": "deribit", + "custom": {} + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message): diff --git a/testing/api-sample-scripts/sample_generator.ipynb b/testing/api-sample-scripts/sample_generator.ipynb index 2cdd9badf..c73078fcd 100644 --- a/testing/api-sample-scripts/sample_generator.ipynb +++ b/testing/api-sample-scripts/sample_generator.ipynb @@ -10,9 +10,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Defaulting to user installation because normal site-packages is not writeable\n", + "Requirement already satisfied: websocket in /home/arham/.local/lib/python3.10/site-packages (0.2.1)\n", + "Requirement already satisfied: greenlet in /home/arham/.local/lib/python3.10/site-packages (from websocket) (2.0.2)\n", + "Requirement already satisfied: gevent in /home/arham/.local/lib/python3.10/site-packages (from websocket) (22.10.2)\n", + "Requirement already satisfied: zope.event in /home/arham/.local/lib/python3.10/site-packages (from gevent->websocket) (4.6)\n", + "Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from gevent->websocket) (59.6.0)\n", + "Requirement already satisfied: zope.interface in /home/arham/.local/lib/python3.10/site-packages (from gevent->websocket) (6.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ "%pip install websocket" ] @@ -27,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -53,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -107,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -138,7 +153,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -181,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -200,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -220,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -239,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -258,7 +273,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ diff --git a/testing/api-sample-scripts/subscribe_books.py b/testing/api-sample-scripts/subscribe_books.py index f814403e3..40ddee075 100644 --- a/testing/api-sample-scripts/subscribe_books.py +++ b/testing/api-sample-scripts/subscribe_books.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'books', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "books", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/subscribe_fills.py b/testing/api-sample-scripts/subscribe_fills.py index ffa22c5ee..eefa64766 100644 --- a/testing/api-sample-scripts/subscribe_fills.py +++ b/testing/api-sample-scripts/subscribe_fills.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'fills', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "fills", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/subscribe_orders.py b/testing/api-sample-scripts/subscribe_orders.py index d968a332e..40004cddb 100644 --- a/testing/api-sample-scripts/subscribe_orders.py +++ b/testing/api-sample-scripts/subscribe_orders.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'orders', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "orders", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/subscribe_price_stats.py b/testing/api-sample-scripts/subscribe_price_stats.py index 230738e09..9830f6a5c 100644 --- a/testing/api-sample-scripts/subscribe_price_stats.py +++ b/testing/api-sample-scripts/subscribe_price_stats.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'price_stats', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "price_stats", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/subscribe_price_tickets.py b/testing/api-sample-scripts/subscribe_price_tickets.py index 225d88fe5..580c7a382 100644 --- a/testing/api-sample-scripts/subscribe_price_tickets.py +++ b/testing/api-sample-scripts/subscribe_price_tickets.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'price_tickets', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "price_tickets", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/subscribe_securities.py b/testing/api-sample-scripts/subscribe_securities.py index dd0b64167..fad358945 100644 --- a/testing/api-sample-scripts/subscribe_securities.py +++ b/testing/api-sample-scripts/subscribe_securities.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'securities', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "securities", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/subscribe_trades.py b/testing/api-sample-scripts/subscribe_trades.py index 5aa548aae..7eae6af03 100644 --- a/testing/api-sample-scripts/subscribe_trades.py +++ b/testing/api-sample-scripts/subscribe_trades.py @@ -1,7 +1,25 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'subscribe', 'params': {'subscription_id': 1, 'type': 'trades', 'filter': {'symbol': ['ETH'], 'expiration': ['2023/04/28'], 'venue': ['deribit']}}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "subscribe", + "params": { + "subscription_id": 1, + "type": "trades", + "filter": { + "symbol": [ + "ETH" + ], + "expiration": [ + "2023/04/28" + ], + "venue": [ + "deribit" + ] + } + }, + "id": 1 +} ws_url = "ws://localhost:8080" message_count = [0] # Define a callback function to handle received messages diff --git a/testing/api-sample-scripts/upd_cover_order.py b/testing/api-sample-scripts/upd_cover_order.py index a0d5ca130..e9e3ae29b 100644 --- a/testing/api-sample-scripts/upd_cover_order.py +++ b/testing/api-sample-scripts/upd_cover_order.py @@ -1,7 +1,22 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'update_order', 'params': {'order_id': 538001, 'price': 1641.8, 'quantity': 2, 'order_type': {'hedge_ticks': 2, 'cancel_on_external_hedge_cancel': True, 'cancel_hedges_on_cancel': True, 'detach_hedges': False}, 'custom': 'cover'}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "update_order", + "params": { + "order_id": 538001, + "price": 1641.8, + "quantity": 2, + "order_type": { + "hedge_ticks": 2, + "cancel_on_external_hedge_cancel": true, + "cancel_hedges_on_cancel": true, + "detach_hedges": false + }, + "custom": "cover" + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message): diff --git a/testing/api-sample-scripts/upd_iceberg_order.py b/testing/api-sample-scripts/upd_iceberg_order.py index 9a0cab402..e75b2fa3a 100644 --- a/testing/api-sample-scripts/upd_iceberg_order.py +++ b/testing/api-sample-scripts/upd_iceberg_order.py @@ -1,7 +1,19 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'update_order', 'params': {'order_id': 538001, 'price': 1641.8, 'quantity': 2, 'order_type': {'showquanity': 5}, 'custom': 'iceberg'}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "update_order", + "params": { + "order_id": 538001, + "price": 1641.8, + "quantity": 2, + "order_type": { + "showquanity": 5 + }, + "custom": "iceberg" + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message): diff --git a/testing/api-sample-scripts/upd_limit_order.py b/testing/api-sample-scripts/upd_limit_order.py index 5cb505ba0..5a11444e2 100644 --- a/testing/api-sample-scripts/upd_limit_order.py +++ b/testing/api-sample-scripts/upd_limit_order.py @@ -1,7 +1,17 @@ import json import websocket -json_payload = {'jsonrpc': 2, 'method': 'update_order', 'params': {'order_id': 538001, 'price': 1641.8, 'quantity': 2, 'order_type': {}, 'custom': 'limit'}, 'id': 1} -json_string = json.dumps(json_payload) +json_string = { + "jsonrpc": 2, + "method": "update_order", + "params": { + "order_id": 538001, + "price": 1641.8, + "quantity": 2, + "order_type": {}, + "custom": "limit" + }, + "id": 1 +} ws_url = "ws://localhost:8080" # Define a callback function to handle received messages def on_message(ws, message):