- Square
- The derbit option retest test
The derbit option retest test
Author:
Inventors quantified, Date: 2020-08-06 17:41:45
Tags:
Option
- Simulating the option buying and selling logic of derbit
- Support for buy and sell options
- Since the wallet needs to be combined with the futures price, it does not support wallets at the moment, the physical drive can be walled through the IO interface.
/*backtest
start: 2020-06-08 00:00:00
end: 2020-08-05 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Deribit","currency":"BTC_USD"}]
*/
function main() {
exchange.SetContractType('BTC-7AUG20-12750-C');
var ticker = exchange.GetTicker();
Log(ticker);
exchange.SetDirection("sell");
var orderId = exchange.Sell(ticker.Sell, 10);
Log(exchange.GetAccount());
Log(exchange.GetOrders());
exchange.CancelOrder(orderId);
Log(exchange.GetAccount());
exchange.Sell(ticker.Buy, 10);
Log(exchange.GetAccount());
Log(exchange.GetPosition());
ticker = exchange.GetTicker();
exchange.SetDirection("closesell");
exchange.Buy(ticker.Sell, 10);
Log(exchange.GetAccount());
Log(exchange.GetPosition());
ticker = exchange.GetTicker();
Log(ticker);
exchange.SetDirection("buy");
orderId = exchange.Buy(ticker.Buy, 10);
Log(exchange.GetAccount());
exchange.CancelOrder(orderId);
Log(exchange.GetAccount());
exchange.Buy(ticker.Sell, 10);
Log(exchange.GetAccount());
Log(exchange.GetPosition());
ticker = exchange.GetTicker();
exchange.SetDirection("closebuy");
exchange.Sell(ticker.Buy, 10);
Log(exchange.GetAccount());
Log(exchange.GetPosition());
}
Related
More