Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with developing BTCUSDT Open Interest Indicator #484739
12/07/21 13:29
12/07/21 13:29
Joined: Jul 2021
Posts: 52
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 52
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);
}

Re: Help with developing BTCUSDT Open Interest Indicator [Re: degenerate_762] #484742
12/07/21 14:07
12/07/21 14:07
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
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.

Re: Help with developing BTCUSDT Open Interest Indicator [Re: degenerate_762] #484743
12/07/21 14:17
12/07/21 14:17
Joined: Jul 2021
Posts: 52
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 52
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.

Re: Help with developing BTCUSDT Open Interest Indicator [Re: degenerate_762] #484747
12/07/21 15:08
12/07/21 15:08
Joined: Feb 2017
Posts: 1,729
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,729
Chicago
Futures and open interest are two different things.

Re: Help with developing BTCUSDT Open Interest Indicator [Re: degenerate_762] #484748
12/07/21 15:24
12/07/21 15:24
Joined: Jul 2021
Posts: 52
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 52
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.

Re: Help with developing BTCUSDT Open Interest Indicator [Re: AndrewAMD] #484749
12/07/21 15:35
12/07/21 15:35
Joined: Jul 2021
Posts: 52
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 52
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"

Re: Help with developing BTCUSDT Open Interest Indicator [Re: degenerate_762] #484750
12/07/21 16:05
12/07/21 16:05
Joined: Feb 2017
Posts: 1,729
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,729
Chicago
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.

Re: Help with developing BTCUSDT Open Interest Indicator [Re: degenerate_762] #484756
12/07/21 17:24
12/07/21 17:24
Joined: Jul 2021
Posts: 52
D
degenerate_762 Offline OP
Junior Member
degenerate_762  Offline OP
Junior Member
D

Joined: Jul 2021
Posts: 52
@AndrewAMD and @Petra. Thanks for clarifying. I 'm new to Options and seem to forget my head shape sometimes.

Attached Files pic.jpg

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1