Set the option contract using the exchange.SetContractType()
function, the option contract codes differ from different exchanges. Cryptocurrency options exchanges supported by the FMZ Quant Trading Platform:
- Futures_Deribit
For the Deribit
exchange, just call the exchange.SetContractType()
function to set the contract to an option contract.
After setting up an option contract, when you call GetTicker()
and other ticker interfaces, all you get is the ticker data of that option contract.
Place an order using exchange.Sell()
, exchange.Buy()
function, pay attention to the direction of the transaction when placing an order, use exchange.SetDirection()
to set the direction of the transaction.
The strategy code for reference: [The Testing Strategy of Deribit Options](https://www.fmz.com/strategy/179475)
Examples of option contract codes: ```BTC-13SEP24-60000-C```, ```XRP_USDC-27SEP24-1-C```, ```BTC-CS-6SEP24-57000_57500```, ```BTC-PCAL-20SEP24_13SEP24-55000```, etc.
- Futures_OKX
Setting up contracts, placing orders, canceling orders, querying orders, and obtaining market quotes, etc. are of the same operation as ```Deribit```, and the contract code format is ```BTC-USD-200626-4500-C```.
You can query the information related to the contract through the interface ```https://www.okx.com/api/v5/public/instruments```.
For example, to query the information of BTC options contracts:
```javascript
function main() {
Log(HttpQuery("https://www.okx.com/api/v5/public/instruments?instType=OPTION&uly=BTC-USD"))
}
import json
import urllib.request
def main():
ret = json.loads(urllib.request.urlopen("https://www.okx.com/api/v5/public/instruments?instType=OPTION&uly=BTC-USD").read().decode('utf-8'))
Log(ret)
void main() {
Log(HttpQuery("https://www.okx.com/api/v5/public/instruments?instType=OPTION&uly=BTC-USD"));
}
BTC-USDT-201225-P-13000
; the contract is a BTC
contract; the exercise date is December 25, 2020; the options are Put Options (PUT); the strike price is $13,000.
For Call Options, the premium paid by the buyer is USDT, indicating the USDT in the account assets is used; the seller’s margin is currency, which is guaranteed by the currency in the assets.
For Put Options, the premium paid by the buyer is USDT, indicating the USDT in the account assets is used; the seller’s margin is USDT, which is guaranteed by the USDT in the assets.ETH_USDC
, call function exchange.SetContractType
to set the contract as an option contract.
Example of option contract code: ETH-25NOV22-1375-P
.ETH-30JUN23-1600-C
.BTC_USDT-20211130-65000-C
.