Skip to content

Commit

Permalink
fix(backtest): enforce QtyDecimalPrecision (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-post committed Jul 12, 2022
1 parent 502e375 commit dbae19a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions exchange/paperwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,14 @@ func (p *PaperWallet) createOrderMarket(side model.SideType, pair string, size f
}

func (p *PaperWallet) CreateOrderMarketQuote(side model.SideType, pair string,
quantity float64) (model.Order, error) {
quoteQuantity float64) (model.Order, error) {
p.Lock()
defer p.Unlock()

return p.createOrderMarket(side, pair, quantity/p.lastCandle[pair].Close)
quantity := quoteQuantity / p.lastCandle[pair].Close
places := math.Pow10(int(p.AssetsInfo(pair).QtyDecimalPrecision))
quantity = math.Floor(quantity*places) / places
return p.createOrderMarket(side, pair, quantity)
}

func (p *PaperWallet) Cancel(order model.Order) error {
Expand Down

0 comments on commit dbae19a

Please sign in to comment.