Help with developing BTCUSDT Open Interest Indicator

Posted By: degenerate_762

Help with developing BTCUSDT Open Interest Indicator - 12/07/21 13:29

Hi,
I trade Crypto currency futures on binance futures exchange. I am trying to program an open interest indicator. I have found this sample code from the zorro forum and can see that contractVal and contractVol have been scripted. I have changed the BarPeriod to 1. Could you please provide directions on how i can complete this simple task?

Code
#include <r.h>
#include <contract.c>

void run() 
{
	BarPeriod = 1;
	Multiplier = 100;
	contractUpdate("BTCUSDT",1,CALL|PUT);	
	int Type = PUT; // Then change to CALL to see difference ******
	var delta_check = 0;
	var strike_price = 0; 
	var con_value;
	var current_IV;
	var Dividend = 0.02;
	var HistVolOV = VolatilityOV(20);
	var InterestV = 0.01*yield();

	strike_price = priceClose();
	CONTRACT* dtest = contract(Type,30,strike_price); 
	con_value = contractVal(dtest,priceClose(),HistVolOV,Dividend,InterestV,&delta_check);
	current_IV = contractVol(dtest,priceClose(),HistVolOV,con_value,Dividend,InterestV);
}
Posted By: Petra

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 14:07

If BinanceFutures supports OI then it's in the ContractVal variable. But it is not mentioned in the documentation, so you probably get no OI for binance futures.
Posted By: degenerate_762

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 14:17

Perpetual Futures: AAABBB, e.g. "BTCUSDT"
Futures: AAABBB-FUT-YYYYMMDD, e.g. "BTCUSDT-FUT-20210326"
Alternatively, use the contract functions for futures, using the currency pair "BTCUSDT" as the underlying.

From the documentation. it looks like contract features are supported.
Posted By: AndrewAMD

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 15:08

Futures and open interest are two different things.
Posted By: degenerate_762

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 15:24

From the Online Manual

Code
contractVol (CONTRACT*, var Price, var HistVol, var Value, var Dividend, var RiskFree): var


Returns the implied volatility (IV) of the given option contract with the given Value. For the parameters, see contractVal. The function uses R and the RQuantLib package; both must be installed on the trading PC (see remarks below). Source code in contract.c. The implied volatility is an estimate of the future volatility of the underlying, based on the current option parameters. If the contract has no value or if the strike price is too far or on the wrong side of the asset price, the function returns 0.

Fine and good that the implied volatility or open interest is a variable. It means that it can be easily plotted using the plot function.


Code
contract (int Type, int Expiry, var Strike): CONTRACT*
var Price = priceClose();
var HistVol = VolatilityOV(20);
var Value = ?
var Dividend = 0.02;
var RiskFree = 0.01*yield();


Need further directions please.
Posted By: degenerate_762

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 15:35

Hi @AndrewAMD. Futures is the Asset class while open interest is the implied volatility of the given option contract with the given Value. Could you please explain what the manual means by Value ? Furthermore, if you could kindly explain how to define the contract.

Perpetual Futures: AAABBB, e.g. "BTCUSDT"
Futures: AAABBB-FUT-YYYYMMDD, e.g. "BTCUSDT-FUT-20210326"
Posted By: AndrewAMD

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 16:05

What option contract? Those are futures contracts, not option contracts.

Also, Petra is correct:
Originally Posted by Petra
If BinanceFutures supports OI then it's in the ContractVal variable. But it is not mentioned in the documentation, so you probably get no OI for binance futures.
Posted By: degenerate_762

Re: Help with developing BTCUSDT Open Interest Indicator - 12/07/21 17:24

@AndrewAMD and @Petra. Thanks for clarifying. I 'm new to Options and seem to forget my head shape sometimes.


Attached picture pic.jpg
© 2024 lite-C Forums