Deribit option testing policy

Author: The Little Dream, Date: 2019-12-25 13:42:25
Tags: Option

Deribit option testing policy

Testing code, testing options, placing, withdrawing orders, obtaining trades, etc. It is used in the Deribit test environment, for real-world disks, and can be removedexchange.IO("base", "https://test.deribit.com")The code is in line.

img


function CancelAll() {
    while (1) {
        var orders = exchange.GetOrders()
        for (var i = 0; i < orders.length; i++) {
            exchange.CancelOrder(orders[i].Id, orders[i])
            Sleep(500)
        }
        if (orders && orders.length == 0) {
            break
        }
        Sleep(500)
    }
    Log(exchange.GetOrders())
}

function main() {
    contract = "BTC-27DEC19-7250-P"
    exchange.IO("base", "https://test.deribit.com")    // 测试,使用deribit的模拟测试环境,如果实盘,请删除此句
    exchange.SetContractType(contract)     // 设置期权合约
    
    // 取消当前所有挂单
    CancelAll()
    
    // 获取当前账户信息
    LogStatus(exchange.GetAccount())
    Sleep(500)
    
    // 获取当前行情信息
    Log(exchange.GetTicker())
    Sleep(500)

    // 获取当前深度信息
    Log(exchange.GetDepth())
    Sleep(500)
    
    // 获取当前市场最近成交记录
    Log(exchange.GetTrades())
    Sleep(500)
    
    // 获取当前K线数据
    Log(exchange.GetRecords())
    Sleep(500)
    
    // 测试下单
    exchange.SetDirection("buy")
    var id = exchange.Buy(0.002, 0.1)   // 第一个参数指的是 权利金,第二个参数指的是标的物数量
    Log("id:", id)
    Sleep(500)
    
    // 获取订单信息
    Log(exchange.GetOrder(id))
    Sleep(500)
    
    // 获取当前所有挂单
    Log(exchange.GetOrders())
    Sleep(500)
    
    // 获取当前期权持仓
    Log(exchange.GetPosition())
    Sleep(500)
    
    // 撤销挂单
    exchange.CancelOrder(id)
    Sleep(500)
    
    // 再次获取当前挂单,检查是否撤销
    Log(exchange.GetOrders())
    Sleep(500)
    
    // 吃单成交
    exchange.SetDirection("sell")
    var ticker = exchange.GetTicker()
    var id2 = exchange.Sell(ticker.Buy, 0.1)
    Sleep(500)
    
    // 获取持仓
    Log(exchange.GetPosition())
    Sleep(500)
    
    // 平仓
    exchange.SetDirection("closesell")
    var pos = exchange.GetPosition(contract)
    Log("pos", pos)
    var id3 = exchange.Buy(ticker.Sell, pos[0].Amount)
    Log(exchange.GetPosition())
    Sleep(500)
}

Related

More

It's like water.Dream sum, the back option will support Binance?

It's like water.That's good.

The Little DreamYes, it's supported, but no updates to the host, if needed, you can telegraph the group @me, you can send a trial version.