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

Commit

Permalink
Fix divide by zero error (#22), closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Reidmcc authored and nikhilsaraf committed Oct 11, 2018
1 parent 567d16c commit fa7d7c4
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit fa7d7c4

Please sign in to comment.