Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Fix divide by zero error #22

Merged
merged 6 commits into from
Oct 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions plugins/sellSideStrategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ func (s *sellSideStrategy) UpdateWithOps(offers []horizon.Offer) (ops []build.Tr
// hitCapacityLimit can be updated below
targetPrice := s.currentLevels[i].Price
targetAmount := s.currentLevels[i].Amount
if targetPrice.AsFloat() == 0 {
return nil, nil, fmt.Errorf("targetPrice is 0")
}
if targetAmount.AsFloat() == 0 {
return nil, nil, fmt.Errorf("targetAmount is 0")
}

if s.divideAmountByPrice {
targetAmount = *model.NumberFromFloat(targetAmount.AsFloat()/targetPrice.AsFloat(), targetAmount.Precision())
}
Expand Down