Open Willstar44 opened 5 years ago
Hi,
Thanks for using. Sounds like it’s working. The script doesn’t show anything. It subscribes to the trade websocket and responds only to filled orders. So you have to set up limit orders manually on your exchange. When these get filled your bot should respond with an opposite order the other side of your spread.
Best,
Alexander
From: Willstar44 Sent: Tuesday, 22 October 2019 09:25 To: sandybradley/pyMarketMaker Cc: Subscribed Subject: [sandybradley/pyMarketMaker] help setting up (#1)
Hi , could you please help me out setting up the bot , installed the reqiuments , but just freeze on python3 pyMarketMaker.py — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
is this correct ?
`# Simplified Deribit Market Maker. Please adjust for your own use.
import asyncio import websockets import json
spread = 50 #dollar spread
refresh_token = "" expires_in = 0 access_token = ""
msg = \ { "jsonrpc" : "2.0", "id" : 42, "method" : "auth", "params" : { "grant_type" : "client_credentials", "client_id" : "###############", "client_secret" : "#########" } `
thanks for the fast reply , :)
import asyncio
import websockets
import json
spread = 50 #dollar spread
refresh_token = ""
expires_in = 0
access_token = ""
msg = \
{
"jsonrpc" : "2.0",
"id" : 42,
"method" : "public/auth",
"params" : {
"grant_type" : "client_credentials",
"client_id" : "deribit-api-key",
"client_secret" : "deribit-api-secret"
}
}
async def call_api(msg):
async with websockets.connect('wss://www.deribit.com/ws/api/v2') as websocket:
await websocket.send(msg)
while websocket.open:
response = json.loads(await websocket.recv())
print(response)
if "result" in response:
result = response["result"]
#print(result)
if "access_token" in result:
access_token = result["access_token"]
print(access_token)
msg1 = {"jsonrpc": "2.0","method": "private/subscribe", "id": 42, "params": {"access_token":access_token, "channels": ["user.orders.BTC-PERPETUAL.raw"]} }
await websocket.send(json.dumps(msg1))
if "params" in response:
params = response["params"]
if "data" in params:
data = params["data"]
print(data)
order_state = data["order_state"]
order_type = data["order_type"]
if order_state == "filled" and order_type != "stop_limit":
price = data["price"]
direction = data["direction"]
qty = data["amount"]
msg2=msg1
if direction == "buy":
sellprice = price + spread
msg2 = {"jsonrpc": "2.0","method": "private/sell", "id": 42, "params": {"access_token":access_token, "instrument_name" : "BTC-PERPETUAL", "amount" : qty, "type" : "limit","price":sellprice,"post_only":True} }
if direction == "sell":
buyprice = price - spread
msg2 = {"jsonrpc": "2.0","method": "private/buy", "id": 42, "params": {"access_token":access_token, "instrument_name" : "BTC-PERPETUAL", "amount" : qty, "type" : "limit","price":buyprice,"post_only":True} }
await websocket.send(json.dumps(msg2))
loop = asyncio.get_event_loop()
loop.run_until_complete(call_api(json.dumps(msg)))
loop.run_forever()
From: Willstar44 Sent: Tuesday, 22 October 2019 09:39 To: sandybradley/pyMarketMaker Cc: Sandy Bradley; Comment Subject: Re: [sandybradley/pyMarketMaker] help setting up (#1)
is this correct ?
# Simplified Deribit Market Maker. Please adjust for your own use. import asyncio import websockets import json spread = 50 #dollar spread refresh_token = "" expires_in = 0 access_token = "" msg = { "jsonrpc" : "2.0", "id" : 42, "method" : "auth", "params" : { "grant_type" : "client_credentials", "client_id" : "###############", "client_secret" : "#########" }
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
When I change the spread to 5 when I place an ordder @ 8262 it places a short 8391 = differents of $129
is this $ or % because if it 5% it too low and $5 is way to much
Seems strange. It should just be the dollar value.
if direction == "buy": sellprice = price + spread
Do you have multiple scripts running at the same time?
From: Willstar44 Sent: Tuesday, 22 October 2019 11:14 To: sandybradley/pyMarketMaker Cc: Sandy Bradley; Comment Subject: Re: [sandybradley/pyMarketMaker] help setting up (#1)
When I change the spread to 5 when I place an ordder @ 8262 it places a short 8391 = differents of $129 is this $ or % because if it 5% it too low and $5 is way to much — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
nope, just the one, I tried it with 50 and int was even worst,
Perhaps there is an id conflict. Try changing the id from 42 to a different number in all the messages
From: Willstar44 Sent: Tuesday, 22 October 2019 11:42 To: sandybradley/pyMarketMaker Cc: Sandy Bradley; Comment Subject: Re: [sandybradley/pyMarketMaker] help setting up (#1)
nope, just the one, I tried it with 50 and int was even worst, — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Hi , could you please help me out setting up the bot , installed the reqiuments , but just freeze on python3 pyMarketMaker.py