names wkng in subs, examples working
This commit is contained in:
1 parent
ce9880a9b1
commit
bb321926bc
21 files changed
+163
-71
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "delete_order",
|
||||
"params": {
|
||||
@@ -8,6 +8,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "enter_order",
|
||||
"params": {
|
||||
@@ -21,6 +21,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "enter_order",
|
||||
"params": {
|
||||
@@ -18,6 +18,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "enter_order",
|
||||
"params": {
|
||||
@@ -16,6 +16,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
@@ -18,18 +18,13 @@
|
||||
"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",
|
||||
"Requirement already satisfied: websocket-client in /home/arham/.local/lib/python3.10/site-packages (1.5.1)\n",
|
||||
"Note: you may need to restart the kernel to use updated packages.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%pip install websocket"
|
||||
"%pip install websocket-client"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -42,7 +37,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -68,7 +63,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 40,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -89,7 +84,7 @@
|
||||
" \"venue\":\"deribit\",\n",
|
||||
" \"custom\":custom\n",
|
||||
"}\n",
|
||||
"upd_order_params=lambda custom,type:{\n",
|
||||
"upd_order_params=lambda type,custom:{\n",
|
||||
" \"order_id\":538001,\n",
|
||||
" \"price\":1641.8,\n",
|
||||
" \"quantity\":2,\n",
|
||||
@@ -99,7 +94,7 @@
|
||||
"simple_filter={\n",
|
||||
" \"symbol\":[\"ETH\"],\n",
|
||||
" \"expiration\":[\"2023/04/28\"],\n",
|
||||
" \"venue\":[\"deribit\"],\n",
|
||||
" \"venue\":[\"deribit\"]\n",
|
||||
"}\n",
|
||||
"order_customs = {\n",
|
||||
" \"limit\":{},\n",
|
||||
@@ -122,13 +117,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 41,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"REST_code=lambda payload :f'''import json\n",
|
||||
"import websocket\n",
|
||||
"json_string = {json.dumps(payload,indent=4)}\n",
|
||||
"json_payload = {json.dumps(payload,indent=4)}\n",
|
||||
"json_string = json.dumps(json_payload)\n",
|
||||
"ws_url = \"ws://localhost:8080\"\n",
|
||||
"# Define a callback function to handle received messages\n",
|
||||
"def on_message(ws, message):\n",
|
||||
@@ -153,13 +149,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 42,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sub_code=lambda payload :f'''import json\n",
|
||||
"import websocket\n",
|
||||
"json_string = {json.dumps(payload,indent=4)}\n",
|
||||
"json_payload = {json.dumps(payload,indent=4)}\n",
|
||||
"json_string = json.dumps(json_payload)\n",
|
||||
"ws_url = \"ws://localhost:8080\"\n",
|
||||
"message_count = [0]\n",
|
||||
"# Define a callback function to handle received messages\n",
|
||||
@@ -196,7 +193,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 43,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -215,12 +212,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 44,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"get_sub = lambda typ,filter: outer(\"subscribe\",{\"subscription_id\":1,\"type\":typ,\"filter\":filter})\n",
|
||||
"subscriptions={key:get_sub(key,simple_filter) for key in [\"books\",\"orders\",\"fills\",\"trades\",\"securities\",\"price_stats\",\"price_tickets\"]}\n",
|
||||
"subscriptions={key:get_sub(key,simple_filter) for key in [\"books\",\"orders\",\"fills\",\"trades\",\"securities\",\"price_stats\",\"price_tickers\"]}\n",
|
||||
"for key, value in subscriptions.items():\n",
|
||||
" file_writer(f\"subscribe_{key}.py\",sub_code(value))"
|
||||
]
|
||||
@@ -235,7 +232,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 45,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -254,7 +251,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 46,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -273,7 +270,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 47,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -285,6 +282,32 @@
|
||||
"metadata": {},
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### Run Examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 51,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"WebSocket connection opened\n",
|
||||
"Received message: {\"jsonrpc\":2.0,\"id\":\"1\",\"status\":\"1\",\"result\":{\"subscription_id\":\"1\"}}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%run subscribe_price_stats.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
|
||||
+3
-2
@@ -1,11 +1,11 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
"subscription_id": 1,
|
||||
"type": "price_tickets",
|
||||
"type": "price_tickers",
|
||||
"filter": {
|
||||
"symbol": [
|
||||
"ETH"
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "subscribe",
|
||||
"params": {
|
||||
@@ -20,6 +20,7 @@ json_string = {
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
message_count = [0]
|
||||
# Define a callback function to handle received messages
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "update_order",
|
||||
"params": {
|
||||
"order_id": 538001,
|
||||
"price": 1641.8,
|
||||
"quantity": 2,
|
||||
"order_type": {
|
||||
"order_type": "cover",
|
||||
"custom": {
|
||||
"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)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "update_order",
|
||||
"params": {
|
||||
"order_id": 538001,
|
||||
"price": 1641.8,
|
||||
"quantity": 2,
|
||||
"order_type": {
|
||||
"order_type": "iceberg",
|
||||
"custom": {
|
||||
"showquanity": 5
|
||||
},
|
||||
"custom": "iceberg"
|
||||
}
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import json
|
||||
import websocket
|
||||
json_string = {
|
||||
json_payload = {
|
||||
"jsonrpc": 2,
|
||||
"method": "update_order",
|
||||
"params": {
|
||||
"order_id": 538001,
|
||||
"price": 1641.8,
|
||||
"quantity": 2,
|
||||
"order_type": {},
|
||||
"custom": "limit"
|
||||
"order_type": "limit",
|
||||
"custom": {}
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
json_string = json.dumps(json_payload)
|
||||
ws_url = "ws://localhost:8080"
|
||||
# Define a callback function to handle received messages
|
||||
def on_message(ws, message):
|
||||
|
||||
Reference in new issue
Block a user