Other Examples
Less than 1 minute
Option Calculation Tool
Option calculation tools are available for option Greek value calculation, option prediction price, and implied volatility calculation. The related algorithms are based on the jquantlib
library.
The tool does not support price forecasting for doomsday options.
Usage
FDAmericanDividendOptionHelper
is American Option Calculation Tool.
import com.tigerbrokers.stock.openapi.client.struct.OptionFundamentals;
import com.tigerbrokers.stock.openapi.client.struct.enums.Right;
import com.tigerbrokers.stock.openapi.client.util.OptionCalcUtils;
import java.time.LocalDate;
public class Test {
public static void main(String[] args) {
OptionFundamentals optionIndex = OptionCalcUtils.calcOptionIndex(
Right.CALL,
243.35, //stock price
240, //option strike price
0.0241, //risk free rate
0, //dividend rate
0.4648, // Implied Volatility
LocalDate.of(2022, 8, 12), //settlement date
LocalDate.of(2022, 8, 19)); //option expiration date
System.out.println("value: " + optionIndex.getPredictedValue()); //predicted option price
System.out.println("delta: " + optionIndex.getDelta());
System.out.println("gamma " + optionIndex.getGamma());
System.out.println("theta " + optionIndex.getTheta());
System.out.println("vega: " + optionIndex.getVega());
System.out.println("rho: " + optionIndex.getRho());
}
}
example result:
value: 8.09628869758489
delta: 0.6005809882595446
gamma 0.024620648675961896
theta -0.4429512650168838
vega: 0.13035018339603335
rho: 0.026470369092588868
In addition to the examples provided in this documentation, we have also provided examples involving the use of other Open API features for your reference. We have updated this part of the code to the Github repository. https://github.com/tigerfintech/openapi-java-sdk-demo