Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix backtest errors; enforce QtyDecimalPrecision #170

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions exchange/paperwallet.go
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