satyapravin / Deribit-Option-Arb

Tool to identify option arbitrage opportunities across different expiries.
MIT License
8 stars 6 forks source link

Option arb test #1

Open mlgmat opened 1 year ago

mlgmat commented 1 year ago

The tool looks very interesting and I have tested it by adding/changing information on margin with Deribit's public API (results are different from private api). In the end, I noticed that orders have a better chance of being executed if long orders are placed first, followed by short orders, with the difficulty being to keep the IM below 100%.

If I understood correctly, one of the trading strategies with this tool is to find a portfolio with the highest net income, theta and gamma >0, with the lowest possible MM, and collect premium with delta hedging. I would be interested in understanding in more detail how this strategy can generate P&L and if you have tested with historical data ?

satyapravin commented 1 year ago

That's great. Ideally execution should consider both long trades and short trades so that required capital is minimized.

The maximize theta strategy waits for theta to decay and earns the premium. Setting gamma positive at the same time ensures that the other delta hedging tool (which is supposed to be running) will buy low and sell high when delta hedging.

On Tue, Apr 25, 2023, 21:07 mlgmat @.***> wrote:

The tool looks very interesting and I have tested it by adding/changing information on margin with Deribit's public API (results are different from private api). In the end, I noticed that orders have a better chance of being executed if long orders are placed first, followed by short orders, with the difficulty being to keep the IM below 100%.

If I understood correctly, one of the trading strategies with this tool is to find a portfolio with the highest net income, theta and gamma >0, with the lowest possible MM, and collect premium with delta hedging. I would be interested in understanding in more detail how this strategy can generate P&L ?

— Reply to this email directly, view it on GitHub https://github.com/satyapravin/Deribit-Option-Arb/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANOUFGC3COMQ43W4D64I4KTXC7EAFANCNFSM6AAAAAAXK7MZCI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mlgmat commented 1 year ago

Thanks for your answear. Here I selected an option portfolio minimizing cost with gamma >100bps and theta > 5 and vega >0 with a low margin :

image

Is there any way to estimate income of this portfolio at expiration (with scenaries like deribit margin matrix) ? To manage each expiration, should I maintain a balanced portfolio with high theta and gamma at low cost. This means continuously adjusting options positions to maintain the desired greeks exposure as expiration approaches. The interest in doing this in crypto instruments lies in the potential for high volatility and liquidity ? Does it make sens to do this on equity ?

Regards

satyapravin commented 1 year ago

Hi @mlgmat. Apologies I could not answer earlier. I haven't yet studied how to estimate income of this portfolio but would be happy to hear your thoughts and maybe incorporate that into this tool.

Regarding your other question about managing expiries, there is a check box "include positions", that is created for this. It is supposed to be used at expiry to rollover portfolio into another portfolio with remaining positions.

It will work in equity as well if you are able to identify positive gamma portfolio with no cost (ofcourse taking into account delta hedging transaction costs).

mlgmat commented 6 months ago

Based on your notebook, I simulated this options portfolio with Monte Carlo and Black&Scholes and found best R:R with this configurations (with data as of today):

for i in range(0, N): deltas[i] = option_data[i].delta gammas[i] = option_data[i].gamma vegas[i] = option_data[i].vega thetas[i] = option_data[i].theta ask_fees[i] = min(0.0003, option_data[i].ask 0.125) + (option_data[i].ask-option_data[i].mark_price) bid_fees[i] =- min(0.0003, option_data[i].bid 0.125) - (option_data[i].mark_price-option_data[i].bid) bids[i] = option_data[i].bid + bid_fees[i] asks[i] = option_data[i].ask +ask_fees[i] calls[i] = max(option_data[i].kind, 0) puts[i] = min(option_data[i].kind, 0) strikes[i] = option_data[i].strike

obj = cvx.Minimize(x @(ask_fees) + y @(bid_fees))

cons = [#(x+y)@deltas <= .01,

(x+y)@deltas >= -.01,

    (x+y)@vegas >= 0, 
    (x+y)@puts == 0,
    (x+y)@calls == 0,
    x <= 3, x >= 0,
    y <= 0, y >= -3,
    cvx.sum(x) <= 10,
    cvx.sum(y) >= -10,
    (x+y)@thetas >= 5,
    (x+y)@gammas >= 0,
    x @asks + y @bids <=0,
    cvx.multiply(y[0, :] + x[0, :], puts)@strikes <= 0,
    cvx.multiply(y[0, :] + x[0, :], calls)@strikes >= 0,
   ]

Here optimisation result : ETH-2MAR24-3050-P size= -1.0 theta= 0.8776 gamma= -0.00024 cost= -0.0003 ETH-2MAR24-3250-P size= 2.0 theta= -17.07676 gamma= 0.00376 cost= 0.006 ETH-2MAR24-3350-P size= -1.0 theta= 21.67571 gamma= -0.00348 cost= -0.0095

theta= 5.47 gamma= 3.99e-05 vega= 0.03

Using realized volat at 40% for inverse delta hedging, here is 80% confidence p&l envelope:

image

Let me know if you think we can have a better configuration for this portfolio ?

satyapravin commented 4 months ago

That looks very interesting. The purpose of the tool is to identify personalized arb opportunities based on market inefficiencies and not necessary theoretical prices.