Coder Social home page Coder Social logo

ericm / stonks Goto Github PK

View Code? Open in Web Editor NEW
543.0 13.0 34.0 1.82 MB

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.

Home Page: https://stonks.icu

License: GNU General Public License v3.0

Go 98.00% Makefile 0.82% Dockerfile 1.19%
stock-market stock-data stocks stock-cli cli stock-market-data terminal-graphics go golang linux macos graphs tracker aur stock-visualizer wtfutil curl ascii-art terminal-based hacktoberfest

stonks's Issues

Cool little program! But can it display indexes?

I know i can look at the SPY ETF, and it works great! I love this little utility.

but can it display charts of indexes? I tried "^GSPC" to track the S&P 500 -- per the ticker on yahoo's website -- but it doesn't give me a graph :(

The command "Stonks" doesnt work correctly but "Stonks -d 1 spy" works fine.

When I type "Stonks" I get

stonks
SPY:

and nothing else.

When i type "Stonks -d -1 spy"
I get
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ SPY | 434.57 USD (0.81% | 3.51) on Wed 21/07/2021 14:45 | Prev: 431.06 | PCX ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃434.70│ ┃
┃434.49│ ╱ ┃
┃434.27│ ╱ ┃
┃434.06│ ╱ ────────── ╱ ┃
┃433.85│ ╱ʌ ╱ ──── ╱ ╱ ╲ ╱ ┃
┃433.63│ ʌ ╱ ╲ ▁ ╱ ʌ ╱ ╱ ╲ ╱ ┃
┃433.42│ ╱ ╲ ▔ ╱ ʌ ╱ ╱ ╲ ╱ ╲ ──── ┃
┃433.21│ ╱ ╲ ╱ ╱ ╲ ──── ┃
┃432.99│─ ╲╱ ┃
┃432.78│ ┃
┃432.57│ ┃
┃432.35│ ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 8.30am 9.15am 10.00am 10.45am 11.30am 12.15pm 1.00pm 1.45pm 2.30pm ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Do you have any idea why it will work with the flags but not without flags?

[Idea] Maybe add an example with wtfutil?

wtfutil is an awesome utility that lets you create static terminal dashboards to fit your needs.

You can place different "widgets" in a desired arrangement. You could use the "command runner" agent to display the output of stonks commands in a dashboard format!

I did the same thing here.

Errors when building using `go1.19.2 darwin/arm64` on macos 12.6

I cloned the repo and tried to install the command following the installation instructions. I got some errors when building the binary:

λ make build
go get
go build -v -o stonks
golang.org/x/sys/unix
# golang.org/x/sys/unix
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:28:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:43:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:59:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:75:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:90:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:105:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:121:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:136:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:151:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:166:3: //go:linkname must refer to declared function or variable
/Users/volmedo/go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:166:3: too many errors
make: *** [build] Error 2

Upgrading the golang.org/x/sys package solved the issue.

Type error when running stonks

$ stonks AMD
panic: interface conversion: interface {} is int, not graph.ChartTheme

goroutine 1 [running]:
main.main.func1(0xc0000eeb00, 0xc0000ad530, 0x1, 0x1)
/home/jc/Documents/finance/stonks/main.go:106 +0x1606
github.com/spf13/cobra.(*Command).execute(0xc0000eeb00, 0xc0000ba030, 0x1, 0x1, 0xc0000eeb00, 0xc0000ba030)
/home/jc/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000eeb00, 0xc0000c4bc8, 0x910edb, 0x7)
/home/jc/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
/home/jc/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
/home/jc/Documents/finance/stonks/main.go:192 +0x605

OS: linux mint 19.2
Stonks was installed using go version go1.14.3 linux/amd64

Steps to reproduce:
$ stonks -s AMD
$ stonks

Add homebrew tap

Would be nice to be able to install this via homebrew

Documentation is here

I'm happy to help setting up a tap for this

Tag Typo

The tag termial-based should be terminal-based. 😺

Intervals of 1m, 2m cause Go panic/runtime error

It appears specifying -i 1m or -i 2m falls outside an internal code/index range, but once you get to -i 3m it starts to work correctly (graceful failure for no data available). I use pikaur as my AUR helper, that's what the name of that directory in the build path output is from seen below.

$ pacman -Q stonks
stonks 1.0.8-1

1m

$ stonks -i 1m AAPL
panic: runtime error: index out of range [80] with length 80

goroutine 1 [running]:
github.com/ericm/stonks/graph.GenerateGraph(0xc00046b500, 0x50, 0xc, 0x1, 0x0, 0x0, 0x203000, 0xc00046b500)
	/home/tengel/.cache/pikaur/build/stonks/src/stonks/graph/graph.go:105 +0x1f0d
main.main.func1(0xc0000dcb00, 0xc00009bc50, 0x1, 0x3)
	/home/tengel/.cache/pikaur/build/stonks/src/stonks/main.go:167 +0x259
github.com/spf13/cobra.(*Command).execute(0xc0000dcb00, 0xc0000b6010, 0x3, 0x3, 0xc0000dcb00, 0xc0000b6010)
	/home/tengel/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000dcb00, 0xc0000aebc1, 0x911422, 0x5)
	/home/tengel/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/home/tengel/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
	/home/tengel/.cache/pikaur/build/stonks/src/stonks/main.go:184 +0x7b7

2m

$ stonks -i 2m AAPL
panic: runtime error: index out of range [80] with length 80

goroutine 1 [running]:
github.com/ericm/stonks/graph.GenerateGraph(0xc0003e01c0, 0x50, 0xc, 0x1, 0x0, 0x0, 0x203000, 0xc0003e01c0)
	/home/tengel/.cache/pikaur/build/stonks/src/stonks/graph/graph.go:105 +0x1f0d
main.main.func1(0xc0000dcb00, 0xc00009bc50, 0x1, 0x3)
	/home/tengel/.cache/pikaur/build/stonks/src/stonks/main.go:167 +0x259
github.com/spf13/cobra.(*Command).execute(0xc0000dcb00, 0xc0000b6010, 0x3, 0x3, 0xc0000dcb00, 0xc0000b6010)
	/home/tengel/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000dcb00, 0xc0000aebc1, 0x911422, 0x5)
	/home/tengel/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/home/tengel/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
	/home/tengel/.cache/pikaur/build/stonks/src/stonks/main.go:184 +0x7b7

3m

$ stonks -i 3m AAPL
No bars were found for this time period for AAPL

My stonks was compiled about a week or so ago, no edits to the PKGBUILD made.

[Feature] Squeeze into 80 columns output (currently 89)

I will make the statement "pretty much every terminal in Linux defaults to 80x24 when opened" and hope that's agreeable. :) (I've even tested good old xterm for this request, it's the same). Is there any way we can shave off 9 columns from the output so that it displays nicely in a standard 80x24 by default?

I used xterm for this screenshot as it does not resize the previous output like modern terminals do, at the top is where it opened in 80x24 and the display is wrapped, then I increased the window to 89 wide to get it nicely formatted. For example maybe 8,30a (losing the 'm' off 'am' and 'pm') could do it perhaps? (or even convert to 24H but that uses the same number as dropping 'm', it's a wash).

Screenshot at 2020-08-12 08-22-35

panic: decimal division by 0

$ stonks -s FSELX
$ stonks
FSELX:
panic: decimal division by 0

goroutine 1 [running]:
github.com/shopspring/decimal.Decimal.QuoRem(0xc0003c7280, 0xc0fffffff1, 0xc0003c7260, 0xfffffff1, 0x10, 0x0, 0x0, 0xc000484b58, 0x1)
        /home/harleypig/go/pkg/mod/github.com/shopspring/[email protected]/decimal.go:500 +0x375
github.com/shopspring/decimal.Decimal.DivRound(0xc0003c7280, 0xc0fffffff1, 0xc0003c7260, 0xfffffff1, 0xc000000010, 0xc0fffffff1, 0x282)
        /home/harleypig/go/pkg/mod/github.com/shopspring/[email protected]/decimal.go:542 +0x6e
github.com/shopspring/decimal.Decimal.Div(...)
        /home/harleypig/go/pkg/mod/github.com/shopspring/[email protected]/decimal.go:487
github.com/ericm/stonks/graph.GenerateGraph(0xc000382000, 0x50, 0xc, 0x0, 0x0, 0x0, 0xc000382000, 0x0)
        /tmp/trizen-harleypig/stonks/src/stonks/graph/graph.go:97 +0xc28
main.main.func1(0xc00015cb00, 0xd0e4f8, 0x0, 0x0)
        /tmp/trizen-harleypig/stonks/src/stonks/main.go:149 +0x906
github.com/spf13/cobra.(*Command).execute(0xc00015cb00, 0xc0001181b0, 0x0, 0x0, 0xc00015cb00, 0xc0001181b0)
        /home/harleypig/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc00015cb00, 0xc000130be0, 0x911f80, 0x7)
        /home/harleypig/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /home/harleypig/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
        /tmp/trizen-harleypig/stonks/src/stonks/main.go:177 +0x70b

panic: decimal division by 0 for BLIAQ

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/[email protected]/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/[email protected]/decimal.go:542 +0x6e
github.com/shopspring/decimal.Decimal.Div(...)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/shopspring/[email protected]/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/[email protected]/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/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/leereilly/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
        /private/tmp/stonks-20200630-96058-dp47eq/main.go:184 +0x7b7

Some flags not working

Neither --days 10 nor --week work.

stonks --days 10                                                                                                                                                                      at  13:10:50
Mercadolibre inc:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ MELI | 824.99 USD (1.26%) on Fri 22/05/2020 13:11 GMT | Prev: 814.71 | NMS            ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃827.44│                                                                                ┃
┃825.56│                ╱ ▁    ╱ʌ   ╱ ʌ                                                 ┃
┃823.67│   ▁    ╱───────   ╲  ╱  ╲ ╱   ╲ ╲                                              ┃
┃821.79│    ╲  ╱            ╲╱                                                          ┃
┃819.91│     ╲╱                                                                         ┃
┃818.03│                                                                                ┃
┃816.14│                                                                                ┃
┃814.26│  ╱                                                                             ┃
┃812.38│ ╱                                                                              ┃
┃810.50│─                                                                               ┃
┃808.61│                                                                                ┃
┃806.73│                                                                                ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃       10.30am  11.15am  12.00pm  12.45pm                                              ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

brew build issues

I am so bold and link in the main repo to a problem with build (homebrew).

I'm not quite sure if an upstream problem or my config / my machine.

ericm/homebrew-stonks#1

thank you very much

Stonks: command not found

I'm running into this issue where I'm attempted to use this program but I get no command found. I cloned the repo. I ran make and make install. However, when I run i.e. stonks -s AMD -n "Advanced Micro Devices" I get command not found. Also, I tried to run make and make install as sudo but I get this message

go get
go build -v -o stonks
go install -v
make: go: Command not found
Makefile:12: recipe for target 'install' failed
make: *** [install] Error 127 (which looks like it can't find a complier)

I have go installed, with a set GO PATH and gcc and c++ in the $PATH(along with go) so I'm not sure the problem could be. I am on WSL if that makes a differences

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.