uniVocity / univocity-trader

open-source trading framework for java, supports backtesting and live trading with exchanges
577 stars 140 forks source link

Emulate order fills using forward history #3

Closed jbax closed 4 years ago

jbax commented 4 years ago

Right now any buy/sell on a simulation simply considers the closing price of the candle. It's not realistic enough and each order should be "filled" based on the candlesticks that come up AFTER the order is placed. That should use volume, high/low and close prices of every tick until the order fills or expires).

jbax commented 4 years ago

Done:

Binance.Simulator simulator = Binance.simulator();
Simulation simulation = simulator.configure().simulation();
simulation.emulateSlippage();

Or roll your own:

simulation.orderFillEmulator(new OrderFillEmulator() {
    @Override
    public void fillOrder(DefaultOrder order, Candle candle) {
        // have fun
    }
});

If using a configuration file, add property:

simulation.order.fill=slippage

Accepted values are: immediateFill, priceMatch and slippage. Or the class name of your custom OrderFillEmulator implementation. (case insensitive)