ericm / stonks

Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal. See how fast your stonks will crash.
https://stonks.icu
GNU General Public License v3.0
544 stars 35 forks source link

panic: decimal division by 0 for BLIAQ #15

Closed leereilly closed 4 years ago

leereilly commented 4 years ago

Bit of an edge case for sure, but BLIAQ (Blockbuster Liquidated Stock) throws a division by zero error:

$ stonks BLIAQ

image

OS: macOS High Sierra v 10.13.6

Stacktrace:

panic: decimal division by 0

goroutine 1 [running]:
github.com/shopspring/decimal.Decimal.QuoRem(0xc00044b520, 0xc0ffffffed, 0xc00044b500, 0xffffffed, 0x10, 0x0, 0x0, 0xc000026348, 0x1)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/shopspring/decimal@v1.2.0/decimal.go:500 +0x375
github.com/shopspring/decimal.Decimal.DivRound(0xc00044b520, 0xc0ffffffed, 0xc00044b500, 0xffffffed, 0xc000000010, 0xc0ffffffed, 0x27b)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/shopspring/decimal@v1.2.0/decimal.go:542 +0x6e
github.com/shopspring/decimal.Decimal.Div(...)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/shopspring/decimal@v1.2.0/decimal.go:487
github.com/ericm/stonks/graph.GenerateGraph(0xc0000e4000, 0x50, 0xc, 0x0, 0x0, 0x0, 0x203000, 0xc0000e4000)
        /private/tmp/stonks-20200630-96058-dp47eq/graph/graph.go:96 +0xc28
main.main.func1(0xc000160b00, 0xc000119610, 0x1, 0x1)
        /private/tmp/stonks-20200630-96058-dp47eq/main.go:167 +0x259
github.com/spf13/cobra.(*Command).execute(0xc000160b00, 0xc000128030, 0x1, 0x1, 0xc000160b00, 0xc000128030)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc000160b00, 0xc000132bb9, 0x151311d, 0x5)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
        /private/tmp/stonks-20200630-96058-dp47eq/main.go:184 +0x7b7
ericm commented 4 years ago

Works fine for me. Make sure you're on version 1.0.8 by typing stonks -v. Also if the issue persists let me know because it might be time sensitive.

leereilly commented 4 years ago
[~] stonks -v                                                                  
1.0.8
[~] stonks BLIAQ                                                                                                            
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ BLIAQ | 0.00 USD (-30.23% | 0.00) on Mon 06/07/2020 08:15 | Prev: 0.00 | PNK        ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃0.01│                                                                                ┃
┃0.01│                                                                                ┃
┃0.01│                                                                                ┃
┃0.01│                                                                                ┃
┃0.01│                                                                                ┃
┃0.01│                                  ╱ ʌ                                           ┃
┃0.01│                                 ╱   ╲                                          ┃
┃0.00│─             ╱ ─────────     ╱ ╱     ╲                                         ┃
┃0.00│ ╲           ╱           ╲   ╱         ╲                 ╱  ─────               ┃
┃0.00│  ╲ ─────────             ╲ ╱           ▁     ╱ ʌ    ╱  ╱        ╲  ─────────   ┃
┃0.00│                                         ╲   ╱   ╲  ╱                           ┃
┃0.00│                                          ╲ ╱                                   ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃     8 Jun          12 Jun          18 Jun          24 Jun          30 Jun           ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

It was 1.0.8, but I think you're right about it being time-sensitive. Works now 🤘