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

Divide by zero error #5

Closed
nikhilsaraf opened this issue Aug 26, 2018 · 0 comments
Closed

Divide by zero error #5

nikhilsaraf opened this issue Aug 26, 2018 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@nikhilsaraf
Copy link
Contributor

Describe the bug

The bot tries to divide by zero in the sellSideStrategy when the price feed for ASSET_B fails, which caused the bot to crash.

Expected behavior

I think the correct behavior in this situation is for the bot to skip the update cycle if any one of the price feeds fail or if either of the price feeds return a zero value.

Frequency

The frequency is: Sometimes [when the price feeds return an invalid value]

Steps To Reproduce

Here are the steps to reproduce the issue (see attachments in section below):

  1. Run the bot with price feeds
  2. Return a zero value from the price feed (can use the "fixed" value to test this)
  3. bot will crash with the divide by 0 error

Possible Solution

See expected behavior

Your Environment

version: v1.0.0-rc1
git hash: 337f478b0e7a1dc235aef31788754bc1ab11b6a1
build date: 20180813T231816Z
GOOS: linux
GOARCH: amd64

Context

I am unable to run the bot reliably because of this bug.

Attachments

See the log here

2018/08/26 11:11:35 error: center price couldn't be loaded! | Get net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2018/08/26 11:11:35 levels couldn't be loaded: Get net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2018/08/26 11:11:43 center price: 0.0000000
2018/08/26 11:11:43 error in buying sub-strategy: Get request canceled (Client.Timeout exceeded while awaiting headers)
2018/08/26 11:11:43 created 0 operations to delete offers
2018/08/26 11:11:43 sleeping for  seconds...
2018/08/26 11:13:43 ----------------------------------------------------------------------------------------------------
2018/08/26 11:13:43 created 0 operations to prune excess offers
2018/08/26 11:13:43 sell,create,p=+Inf,a=0.0000000
2018/08/26 11:13:43 error: cannot place sell order, zero amount
2018/08/26 11:13:43 sell,create,p=+Inf,a=0.0000000
2018/08/26 11:13:43 error: cannot place sell order, zero amount
2018/08/26 11:13:43 sell,create,p=+Inf,a=0.0000000
2018/08/26 11:13:43 error: cannot place sell order, zero amount
2018/08/26 11:13:43 sell,create,p=+Inf,a=0.0000000
2018/08/26 11:13:43 error: cannot place sell order, zero amount
2018/08/26 11:13:43 sell,create,p=+Inf,a=0.0000000
2018/08/26 11:13:43 error: cannot place sell order, zero amount
2018/08/26 11:13:43 sell,create,p=+Inf,a=0.0000000
2018/08/26 11:13:43 error: cannot place sell order, zero amount
2018/08/26 11:13:43 sell,create,p=0.0000000,a=23619.2878901
panic: division by zero

goroutine 1 [running]:
math/big.(*Rat).SetFrac64(0xc42031c440, 0x0, 0x0, 0x0)
  /usr/local/Cellar/go/1.10.3/libexec/src/math/big/rat.go:311 +0xfb
math/big.NewRat(0x0, 0x0, 0xc42061f000)
  /usr/local/Cellar/go/1.10.3/libexec/src/math/big/rat.go:25 +0x4f
github.com/lightyeario/kelp/vendor/github.com/stellar/go/xdr.(*Price).String(0xc4201142a0, 0x0, 0x0)
  ~/go/src/github.com/lightyeario/kelp/vendor/github.com/stellar/go/xdr/price.go:9 +0x37
github.com/lightyeario/kelp/plugins.(*sellSideStrategy).UpdateWithOps(0xc420140a10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
  ~/go/src/github.com/lightyeario/kelp/plugins/sellSideStrategy.go:97 +0xec
github.com/lightyeario/kelp/plugins.(*composeStrategy).UpdateWithOps(0xc4202aec90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb73f58, 0x0, 0x0, ...)
  ~/go/src/github.com/lightyeario/kelp/plugins/composeStrategy.go:79 +0x107
github.com/lightyeario/kelp/trader.(*Trader).update(0xc4201f5c48)
  ~/go/src/github.com/lightyeario/kelp/trader/trader.go:120 +0x34a
github.com/lightyeario/kelp/trader.(*Trader).Start(0xc4201f5c48)
  ~/go/src/github.com/lightyeario/kelp/trader/trader.go:65 +0x6f
github.com/lightyeario/kelp/cmd.init.4.func1(0xb50e20, 0xc420069440, 0x0, 0x6)
  ~/go/src/github.com/lightyeario/kelp/cmd/trade.go:109 +0x8fa
github.com/lightyeario/kelp/vendor/github.com/spf13/cobra.(*Command).execute(0xb50e20, 0xc4200693e0, 0x6, 0x6, 0xb50e20, 0xc4200693e0)
  ~/go/src/github.com/lightyeario/kelp/vendor/github.com/spf13/cobra/command.go:702 +0x2c6
github.com/lightyeario/kelp/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xb507c0, 0x403dfc, 0xc420072058, 0x0)
  ~/go/src/github.com/lightyeario/kelp/vendor/github.com/spf13/cobra/command.go:783 +0x2e4
github.com/lightyeario/kelp/vendor/github.com/spf13/cobra.(*Command).Execute(0xb507c0, 0x0, 0x7b66a8)
  ~/go/src/github.com/lightyeario/kelp/vendor/github.com/spf13/cobra/command.go:736 +0x2b
main.main()
  ~/go/src/github.com/lightyeario/kelp/main.go:10 +0x2d
@nikhilsaraf nikhilsaraf added the bug Something isn't working label Aug 26, 2018
@nikhilsaraf nikhilsaraf added this to the v1.0.0-rc2 milestone Aug 26, 2018
@nikhilsaraf nikhilsaraf added the good first issue Good for newcomers label Sep 10, 2018
@nikhilsaraf nikhilsaraf modified the milestones: v1.0.0-rc4aa, v1.0.0-rc4 Oct 1, 2018
@nikhilsaraf nikhilsaraf modified the milestones: v1.0.0, v1.1.0 Oct 10, 2018
nikhilsaraf pushed a commit that referenced this issue Oct 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant