There are many digital currency futures exchanges, but as a futures derivative, digital currency options trading, there are not many exchanges on the market, there are Deribit, BitMEX. In the field of quantitative trading, options trading also has several strategies, such as the options strategy mentioned in some of the information:
Types | |||||
---|---|---|---|---|---|
This is the first time I've seen this video. | Buying a put option | Selling a put option | The bull market sees the price of aluminum falling | The bull market is falling | |
– | Buy a bear option | Selling the options | The bear market sees the price of uranium falling | The bear market is falling | |
This is the first time I have seen this kind of thing. | Selling the crossover | Selling wide | Buying a crossover | Buying a broadband | |
How to hedge: | Stand by to watch | Standby and drop | Protective eyewear | Protectionist downturn | |
– | Multiple boundaries | Blank head | – | – |
Cited byConnection
Writing options trading strategies still requires a solid foundation, basic ordering, market acquisition, withdrawal, holding, etc. operations should be familiar. Writing strategies still use inventors' quantitative trading platforms, although inventors' quantitative trading platforms currently support the field of digital currency quantitative trading mainly in the field of coin trading, contract trading, leverage trading.
The API documentation:https://docs.deribit.com/v2/?javascript#public-get_last_settlements_by_instrumentThe simulation disc:https://docs.deribit.com/v2/?javascript#public-get_last_settlements_by_instrument
You can register an account on the platform, open the API KEY, and access the API KEY. Configure the inventor's quantitative trading platform as if it were a physical disk.
There are four basic concepts to understand about options trading:
A look at the API documentation of the Deribit exchange shows that Deribit's market interface is simply a pass-through to access the futures or options market.instrument_name
If the parameters are different (instrument_name is set by the SetContractType function), then you can basically use the interface to access the market.GetTicker
In addition to the above, there are also a number of other options available.
Of course, the inventor of the QT platform packs the virtual disk of the Deribit exchange by default, so we first need to switch to the analogue disk using the following code:
exchange.IO("base", "https://test.deribit.com")
And then we set the current as an option contract.BTC-27DEC19-7000-P
I'm not sure.
This is a call option with a call date of 27DEC19 and a call price of 7000.
exchange.SetContractType("BTC-27DEC19-7000-P")
Then get, we write together, let the code run, test how to get this option contract.
function main () {
exchange.IO("base", "https://test.deribit.com")
exchange.SetContractType("BTC-27DEC19-7000-P")
var ticker = exchange.GetTicker()
Log(ticker)
}
It is easy to test using the debugger tool:As you can see, the price is consistent with the price on the analogue disc.
The following are some of the most common types of interfaces used in the industry:
Options trading is not very active, and sometimes there is no bid or offer, at which point inventors quantify the bottom of the trading platform to detect a value of zero, which will return an error, which can be used.SetErrorFilter("Invalid ticker")
I'm not going to go into detail about this, but I'm going to try to figure out how to do it.GetRawJSON
The function is used to capture raw information about the market and package the data, and here I write an example to implement a similar function:
function init() {
SetErrorFilter("Invalid ticker")
}
$.GetTicker = function(e) {
var ticker = e.GetTicker()
if (!ticker) {
try {
var ret = JSON.parse(e.GetRawJSON())
return {
Info : ret,
High : ret.result.stats.high,
Low : ret.result.stats.low,
Buy : ret.result.best_bid_price,
Sell : ret.result.best_ask_price,
Last : ret.result.last_price,
Volume : ret.result.stats.volume,
OpenInterest : 0,
Time : new Date().getTime()
}
} catch (err) {
Log(err)
}
}
return ticker
}
He wrote on the call:Log($.GetTicker(exchange))
The following procedure is very simple, as compared to futures trading, only buy and sell in two directions.Sell
,Buy
The functions are listed here.
function main () {
exchange.IO("base", "https://test.deribit.com")
exchange.SetContractType("BTC-27DEC19-7000-P")
var id = exchange.Buy(0.017, 1)
Log(exchange.GetOrder(id))
}
The simulation displays the orders that have just been placed.
andexchange.GetOrder(id)
You can check the order information here.
Withdrawals are also used.CancelOrder
The function is the same as withdrawal in futures trading.
Acquire an account with the same available assets as when trading futures, directly callGetAccount
Let's say the function is.
Display on the simulated exchange page
Running code obtained:
The packaging cannot be used directly for storage.GetPosition
This function is used only to access futures holdings, since Deribit is a futures trading, not an options trading, by default.
So that's where we have to start wrapping up the option holding function ourselves.
Interface of the API documentation to obtain the hold function:
$.GetPosition = function(e) {
// /private/get_positions
// currency , kind
var positions = []
var currency = e.GetCurrency()
var arr = currency.split("_")
var baseCurrency = arr[0]
try {
var ret = e.IO("api", "GET", "/api/v2/private/get_positions", "currency=" + baseCurrency + "&kind=option")
for (var i in ret.result) {
if (ret.result[i].size == 0 || ret.result[i].direction == "zero") {
continue
}
var pos = {
Info : ret.result[i],
Amount : ret.result[i].size,
FrozenAmount : 0,
Price : ret.result[i].average_price,
Profit : ret.result[i].floating_profit_loss,
MarginLevel : 0,
Margin : 0,
ContractType : ret.result[i].instrument_name,
Type : ret.result[i].direction == "buy" ? ORDER_TYPE_BUY : ORDER_TYPE_SELL,
}
positions.push(pos)
}
} catch (err) {
Log(err)
positions = null
}
return positions
}
CallingLog($.GetPosition(exchange))
You can print out the information you have stored.
In this way, the basic operations can be implemented, and the rest can be studied in options trading strategies.