Hedging Perps
Let's use the real-time streams for automated hedging.
Reacting to Trades
We'll manually place limit short orders on the ETH_USDC perpetual. Once one fills, we'll automatically buy the spot, same amount.
async def hedge_short():
async with Deribit.new() as client:
async for trades in client.subscriptions.user_trades(instrument_name='ETH_USDC-PERPETUAL'):
for trade in trades:
if trade['direction'] == 'sell':
await client.buy('ETH_USDC', {
'amount': trade['amount'],
'type': 'market',
})
And that's the kind of thing you can only do with the API.🚀🚀