Coder Social home page Coder Social logo

achannarasappa / ticker Goto Github PK

View Code? Open in Web Editor NEW
4.8K 60.0 257.0 585 KB

Terminal stock ticker with live updates and position tracking

License: GNU General Public License v3.0

Go 99.95% Dockerfile 0.05%
terminal stocks financial-markets terminal-app tui stock-market stocks-app golang golang-application ticker

ticker's People

Contributors

1dollarsteak avatar achannarasappa avatar agrimrules avatar alexisloiselle avatar alt-romes avatar cpjolicoeur avatar deroshkin avatar enescakir avatar galmadar avatar herbygillot avatar junior avatar livioavalle avatar priyanshus avatar snksynthesis avatar tomclegg avatar viperperidot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ticker's Issues

Windows executable detected as Malware by several Antivirus engines

I was trying to try the app in a Windows environment when the browser started to cancel the download of the compressed file...
However, I managed to download it and execute the program, which resulted in the result:

โฏ ticker

Unhandled Exception: System.ComponentModel.Win32Exception: Operation did not complete successfully because the file contains a virus or potentially unwanted software
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at shim.CommandExecutor.execute(String process, String arguments, String working_directory, Boolean is_gui, Boolean wait_for_exit, Boolean requires_elevation)
   at shim.ShimProgram.Main(String[] args)

Then I uploaded the file to VirusTotal, where seven Antivirus engines interpreted it as Malware/Malicious (including Microsoft itself). You can see the report here: https://www.virustotal.com/gui/file/6a89d65b6ffab900b0a1d66ad1b49b73d8a0aa147a6a08524c4af34c6cc4626f/detection

I want to think that this is not intended, but I don't know why this is happening...

Request to toggle on/off the display the my dollar balances.

Would like the option to be able to toggle on/off the display the my dollar balances.

I'd like to be able to press a key such as T to toggle balance amount off, take a screen shot and toggle the balance back on. Displaying all the gains / loss and percentages are fine. I would just like a quick way to not show how much is actually invested.

In the yaml file, would like the ability to define if this feature is on or off by default at startup.

(feature request) show profits/loss percent based on "lots"

Hi

Thank you very much for this software. At the moment I use the Stocks.app from Apple, which unfortunately has a proprietary file format. YAML is much better. The first impression of your software has me excited.

Example config:

show-tags: true
show-fundamentals: true
show-separator: true
interval: 10
watchlist:
  - BTC-EUR
lots:
  - symbol: "BTC-EUR"
    quantity: 0.24
    unit_cost: 900

Let's suppose I bought 0.24 Bitcoin for 900 Euro in the past.
I now wish to see how much profit or loss I made (in percent) with today price.

I am absolutely new to the investing world, but this profit/loss percent interests me the most.

Feature request: edit appearance of price quote

Would it be possible to edit the appearance of the quoted price for the stock? Things like font size, bold, and font color would be nice to edit to make the price stand out more I think. It would also be nice to be able to move it to a different position on the screen closer to the center of the screen imo.

Edit: I see now why the price quote is on the far right, it is to make room for the holdings column. I still think being able to adjust the appearance would be good though.

Color Configuring

The Dark Grey is barely readable on dark terminals when there's sunlight in the room.

Best regards
ticker_cutoff_date

Edit:
This is a tricky one. ticker isn't using ANSI colors but termenv, which doesn't respect color schemes.

I patched it with fatih/color to use ANSI for most Text and it improved readability for me a lot.

I guess this is a fundamental decision everyone has to decide for themselves. I have no problem with maintaining a patch so I am fine.

ticker

diff --git a/go.mod b/go.mod
index d546e43..7b48c24 100644
--- a/go.mod
+++ b/go.mod
@@ -7,6 +7,7 @@ require (
        github.com/adrg/xdg v0.3.0
        github.com/charmbracelet/bubbles v0.7.5
        github.com/charmbracelet/bubbletea v0.12.2
+       github.com/fatih/color v1.7.0
        github.com/go-resty/resty/v2 v2.3.0
        github.com/jarcoal/httpmock v1.0.7
        github.com/lucasb-eyer/go-colorful v1.0.3
diff --git a/go.sum b/go.sum
index e79c0f2..d970abb 100644
--- a/go.sum
+++ b/go.sum
@@ -50,6 +50,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
 github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
@@ -145,6 +146,7 @@ github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tW
 github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
 github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
 github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
 github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
 github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
diff --git a/internal/ui/ui.go b/internal/ui/ui.go
index 4c03fd5..08fdb8e 100644
--- a/internal/ui/ui.go
+++ b/internal/ui/ui.go
@@ -10,19 +10,21 @@ import (
        "ticker/internal/ui/component/watchlist"
        "time"
 
-       . "ticker/internal/ui/util"
+       // . "ticker/internal/ui/util"
        . "ticker/internal/ui/util/text"
 
        "github.com/charmbracelet/bubbles/viewport"
        tea "github.com/charmbracelet/bubbletea"
        "github.com/go-resty/resty/v2"
+       "github.com/fatih/color"
 )
 
 var (
-       styleLogo = NewStyle("#ffc27d", "#f37329", true)
-       styleHelp = NewStyle("#4e4e4e", "", true)
+       styleLogo = color.New(color.FgBlack, color.BgYellow).SprintFunc()
+       styleHelp = color.New(color.FgHiBlack).SprintFunc()
 )
 
+
 const (
        footerHeight = 1
 )
diff --git a/internal/ui/util/style.go b/internal/ui/util/style.go
index 813d84f..c0659a7 100644
--- a/internal/ui/util/style.go
+++ b/internal/ui/util/style.go
@@ -5,6 +5,7 @@ import (
 
        "github.com/lucasb-eyer/go-colorful"
        te "github.com/muesli/termenv"
+       "github.com/fatih/color"
 )
 
 const (
@@ -12,12 +13,12 @@ const (
 )
 
 var (
-       StyleNeutral       = NewStyle("#d4d4d4", "", false)
-       StyleNeutralBold   = NewStyle("#d4d4d4", "", true)
-       StyleNeutralFaded  = NewStyle("#616161", "", false)
-       StyleLine          = NewStyle("#3a3a3a", "", false)
-       StyleTag           = NewStyle("#d4d4d4", "#3a3a3a", false)
-       StyleTagEnd        = NewStyle("#3a3a3a", "#3a3a3a", false)
+       StyleNeutral       = color.New(color.FgWhite).SprintFunc()
+       StyleNeutralBold   = color.New(color.FgWhite, color.Bold).SprintFunc()
+       StyleNeutralFaded  = color.New(color.FgHiBlack).SprintFunc()
+       StyleLine          = color.New(color.FgBlack).SprintFunc()
+       StyleTag           = color.New(color.FgWhite, color.BgBlack).SprintFunc()
+       StyleTagEnd        = color.New(color.FgWhite, color.BgBlack).SprintFunc()
        StylePricePositive = NewStyleFromGradient("#C6FF40", "#779929")
        StylePriceNegative = NewStyleFromGradient("#FF7940", "#994926")
 )

Flickering on updates in tmux

Hi, I was wondering if I am the only one experiencing flickering on updates of the tickers list.
I've just installed the package, and for demo purpose added AAPL,NET,TSLA tickers.
I use tmux, could be this the source of the problem?
I tested it on simple terminal, it works ok.

My os is ubuntu 20.04.

Add a changelog

Can we get a CHANGELOG.md appended to when new versions are released?

HTTP response errors are not reported to user

Describe the bug
When there is an unexpected response with making the HTTP request retrieve quotes, the UI shows blank content with no indication as to what the problem is.

To Reproduce
Steps to reproduce the behavior:

  1. Start ticker with ticker -w AAPL --proxy "http://localhost:9999" (assuming no proxy exists at this port/host)
  2. See empty UI with no error message

Expected behavior
UI to be populated with data or an error message indicating what the problem is

Proposed solution
When there is a HTTP error response, display message in UI or exit application with error

See #59 for more information and workaround

Module path should include repository hostname / path

To follow Go conventions and to make this package go get-able, the module path should be github.com/achannarasappa/ticker and the package import paths should be github.com/achannarasappa/ticker/{package}.

Currently, attempting to go get github.com/achannarasappa/ticker (my preferred way of installing go executable programs) fails with:

package ticker/cmd: unrecognized import path "ticker/cmd": import path does not begin with hostname

Not all securities have a `PostMarketPrice`

quote.go uses responseQuote.PostMarketPrice if responseQuote.MarketState == "POST", however, some securities do not have a post market price. E.g. the latest price for https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US&region=US&corsDomain=finance.yahoo.com&symbols=LUS.DE after the market has closed will still be RegularMarketPrice. ticker wil therefore display 0.0 as latest price.

Price Alarm

Would be nice to be able to set a price alarm with notification ๐Ÿš€

Add a thousands separator

Large position numbers would be easier to read with a thousands separator, or even better make the number format string configurable.

Start ticker with default ~/.ticker.yml

Problem Statement

As a user, I want to start ticker to monitor my watchlist and existing lots in the default config ~/.ticker.yml

Proposed Solution

Running ticker without any options starts ticker using the default ~/.ticker.yml.

This would tie in with well with a command to add a lot.

Example usage:

ticker # starts a new ticker environment with fresh ~/.ticker.yml
# quit ticker

ticker lots add abnb --quantity 100 --unit-cost 147.00 # adds this lot to ~/.ticker.yml
ticker watch estc # add estc to watchlist

ticker # starts ticker with abnb lot and estc in the watchlist

Show totals in the status bar

Enhancement request: show the totals in the statusbar, aligned on the same column with the total values for each rows.

Cannot find config file

The config file is not in the default directly as mentioned here and I do not see it anywhere.

Positioning of Update Datetime

The positioning of the update datetime in the lower right corner is cut off on two terminals I tested.
Is it possible to to align it with the current value (which isn't cut off).

Best Regards
ticker_cutoff_date

No information displayed

Ticker is not showing any stock data at all.
Here is the result for ticker -w NET,AAPL,TSLA
image

Here is ticker -w NET,AAPL,TSLA --show-tags --show-fundamentals --show-separator --show-summary
image

Installed via brew. No internet filtering/firewalls are enabled. Here is the computer's information:
image

Summary mixes up currencies

First off, thanks for a cool little utility.

The new summary feature --show-summary seems to add up all values without taking into account the currencies.

That is, they are all summed up even though the currencies are not the same, here is an example with a stock in USD and a crypto in EUR
Screenshot 2021-02-04 at 12 05 29

Add a command to print portfolio values to stdout for unix style piping

Background
Currently ticker only provides the data in a graphical user interface. To track portfolios over time or use the collected data in other ways the quotes and summaries should be printed to the stdout in a predefined format like json.

Request
In order to pipe asset and portfolio values into other tools in a CLI context, there should a command to print those values in different formats to the stdout.

Technical Details

  • there should be a specific (sub)command to trigger printing to stdout
  • flags for this command define which data to export and in what format
  • executed with this command, ticker doesn't show the graphical interface, it only prints the collected quotes and summaries

Additional context

An example how this could look like is the "holdings" command in cointop which enables users output only the total value of a portfolio or get the current values in different format like json or csv.

screenshot-cointop

Ticker command to add lot

Problem Statement

As a user, I want to add a lot at any time from the command line without having to edit ~/.ticker.yml

Proposed Solution

Running a command such as ticker lots add abnb --quantity 100 --unit-cost 147.00 adds this to the lots in ~/.ticker.yml

This would tie in with well with a command to start ticker without any flag.

Example usage:

ticker lots add abnb --quantity 100 --unit-cost 147.00 # adds this lot to ~/.ticker.yml

ticker # starts ticker with abnb lot

dynamic region

There isn't an option for changing the region. Would be nice to use an argument in the ticker.yaml

image

Currency support

As mentioned in the issue #6 I'd like to ask for currency support.

My suggestion is to add this by just watching the exchange value between the Euro and USD. You can watch the Dollar just like a usual quote, maybe you can add this.

Unfortunately If I try this on the Yahoo API it doesn't work.

Total for lots?

May be displaying totals for lots (in the status line?) could be worth considering? :)

Otherwise, seems like a great app, already using it.

Allow empty watchlist

First of all, this is awesome! I actually wanted to write something very similar myself but did not get around to doing it. Thank you!

Additionally, it would be nice to allow an empty watchlist.

Redundant/alternate data sources

Background
Currently, data is pulled from Yahoo finance's unofficial API. Given the API is not officially supported, it could be shut down, limited, or changed in some way that makes ticker unusable which presents a serious risk.

Additionally, there are data sources that may not be covered by Yahoo finance that users may find value in using with ticker's interface.

Request
In order to add redundancy and extensibility, it would be ideal to have the option to pull from different, configurable data sources.

Technical Details

  • Implement of adapters (i.e. anti-corruption layer) for each data source
  • Implement Yahoo finance adapter
  • Define normalized internal data structures for quotes responses

using a ticker.yaml does not explain what will be the command to run it

Hi,

thank you for this great useful code I will daily use but ...
Even if I used the recommended yaml file I can not display this content by using even "ticker" or "ticker -w".
Then I read back twice the explanation but did not found how to run it correctly. I even moved the yaml file from /usr/local/bin to /home or /home/ and did not get it workable.

Please tell me how to use it properly with yaml.

Have a nice day and take care.

XDG compliance

It would be great if by default check for the configuration file in XDG_CONFIG_HOME (this is ~/.config for 90% of people), and maybe also XDG_CONFIG_HOME/ticker as well as in ~ for a configuration file, so as not to pollute the home directory with dotfiles.

Normally I'd have just submitted a pull request but I don't know Go, but I'm happy to help with any details or clarifications about it.

Cool project!

Docker support

Proposed Solution
Create Dockerfile and publish to Docker hub for easy usage without need to install the cli

Use Cases
Run Docker command to run Ticker

Additional context
Pull request already created with the solution. PR #75

When looking in XDG_CONFIG_HOME YAML config file shouldn't have dot prefix

When storing configuration files in XDG_CONFIG_HOME, it's not typical to also have the configuration file be a hidden file.

e.g.

~/.ticker.yaml
~/.config/ticker/ticker.yaml

This issue is just a placeholder to make the config file loader a bit more robust in how it search/loads the config file to allow for a bit more leeway. The README does note the file being called .ticker.yaml in both cases, but it would also be nice (perhaps) to allow for both styles.

Auto-reload config file

Describe the solution you'd like
Automatically reload the configuration file when it changes.

Describe alternatives you've considered
Using inotifywait or entr.

Additional context
Using inotify on linux should be relatively easy?

Contract tests

It would be great to have a consumer-driven contract test run on a daily schedule with a GitHub action and a corresponding indicator badge to signal pass or failure to get ahead of any breaking API changes

Interval is ignored

As far as I can tell the interval flag and the corresponding option in the yaml configuration file is ignored thus always refreshing every 5 seconds.
Using Windows amd64 v2.2.0.

Also a version flag would be nice.

Bottom status bar covering information

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Start ticker with show-fundamentals: false show-tag: false
  2. Scroll to the very bottom

Expected behavior
What should happen: See the price of the last stock
What actually happens: Last stock price is covered by bottom bar

Screenshots
2021-02-05_12-11_126560005_scrot

Environment (please complete the following information):

  • OS: Linux
  • Terminal: alacritty
  • Terminal Version: 0.6.0
  • ticker Version: b2eb144

Sorting?

As for now, as I understand, it sorts tickers by their growth. This leads to tickers constantly changing their positions. Can sorting by name be implemented?

Or, better, sort according to the order in the configuration file if one's present (this could allow custom sorting, visually separating a group of unrelated tickers, and also other things, like putting "lots" on top, and the rest of the watchlist below).

Unable to pipe

Describe the bug
I'm unable to pipe the output of ticker, for example to less.

To Reproduce
Steps to reproduce the behavior:

  1. ticker -w BOWL.L | less
  2. See error: Unable to start UI: inappropriate ioctl for device

Expected behavior
I'd expect to see output similar to top | less

Environment (please complete the following information):

  • OS: Linux - Ubuntu 20.04
  • Terminal: Konsole (fish shell)
  • Terminal Version: Konsole: 20.12.1, Fish: 3.1.2
  • ticker Version: v3.0.2

Feature Request: Export data

One of my everyday routines is to update a spreadsheet with the current values of the tickers I have invested.
This system is great for that! Instead of going to a bunch of websites, I just run the terminal and it's done.

An export to JSON feature for example would be great because I could just put a script to run on the cronjob to update my spreadsheet using its data.

Thank you for the app :)

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.