mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
backtest: adjust best bid/ask price with tick size
This commit is contained in:
parent
fded41b0ea
commit
0482ade44a
|
@ -12,18 +12,18 @@ for each kline, the backtest engine:
|
||||||
|
|
||||||
There are 2 ways that a strategy could work with backtest engine:
|
There are 2 ways that a strategy could work with backtest engine:
|
||||||
|
|
||||||
1. the strategy receives kline from the market data stream, and then it submits the order by the given market data to the backtest engine.
|
1. the strategy receives kline from the market data stream, and then it submits the order by the given market data to the backtest engine.
|
||||||
backtest engine receives the order and then pushes the trade and order updates to the user data stream.
|
backtest engine receives the order and then pushes the trade and order updates to the user data stream.
|
||||||
|
|
||||||
the strategy receives the trade and update its position.
|
the strategy receives the trade and update its position.
|
||||||
|
|
||||||
2. the strategy places the orders when it starts. (like grid) the strategy then receives the order updates and then submit a new order
|
2. the strategy places the orders when it starts. (like grid) the strategy then receives the order updates and then submit a new order
|
||||||
by its order update message.
|
by its order update message.
|
||||||
|
|
||||||
We need to ensure that:
|
We need to ensure that:
|
||||||
|
|
||||||
1. if the strategy submits the order from the market data stream, since it's a separate goroutine, the strategy should block the backtest engine
|
1. if the strategy submits the order from the market data stream, since it's a separate goroutine, the strategy should block the backtest engine
|
||||||
to process the trades before the next kline is published.
|
to process the trades before the next kline is published.
|
||||||
*/
|
*/
|
||||||
package backtest
|
package backtest
|
||||||
|
|
||||||
|
@ -270,8 +270,8 @@ func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticke
|
||||||
Open: kline.Open,
|
Open: kline.Open,
|
||||||
High: kline.High,
|
High: kline.High,
|
||||||
Low: kline.Low,
|
Low: kline.Low,
|
||||||
Buy: kline.Close,
|
Buy: kline.Close.Sub(matching.Market.TickSize),
|
||||||
Sell: kline.Close,
|
Sell: kline.Close.Add(matching.Market.TickSize),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user