Categorygithub.com/mop-tracker/mop
modulepackage
0.0.0-20241230171317-298ed9b8ed39
Repository: https://github.com/mop-tracker/mop.git
Documentation: pkg.go.dev

# README

mop: track stocks the hacker way

A command-line utility that displays current information on select markets and individual stocks.

image

Installing mop from source

Ensure GO language is installed. Download from: https://go.dev/dl/ and the $GOPATH is set then:

git clone https://github.com/mop-tracker/mop
cd mop
go build ./cmd/mop
./mop

Using mop

By default, mop refreshes quotes and market data on a 5 minute (600s) interval. These values can be changed in the .moprc file.

For demonstration purposes mop comes preconfigured with a number of stock tickers. You can easily change the default list by using the following keyboard commands:

   +                  Add stocks to list
   -                  Remove stocks from list
   ? h H              Display this help screen
   f                  Set filtering expression
   F                  Unset filtering expression
   g G                Group stocks by advancing/declining issues
   o                  Change column sort order
   p P                Pause market data and stock updates
   t                  Toggle timestamp on/off
   Mouse Scroll       Scroll up/down
   PgUp/PgDn          Scroll up/down
   Up/Down arrows     Scroll up
   j J                Scroll up
   k K                Scroll down
   q esc              Quit mop

When prompted please enter comma-delimited list of stock tickers.

The list and other settings are stored in the profile file (default: .moprc in your $HOME directory).

No Timestamp

image

With Timestamp

image

Expression-based Filtering

Mop has an in realtime expression-based filtering engine that is very easy to use.

At the main screen, press f and a prompt will appear. Write an expression that uses the stock properties.

Example:

last <= 5

This expression will make Mop show only the stocks whose last values are less than $5.

The available properties are: last, change, changePercent, open, low, high, low52, high52, volume, avgVolume, pe, peX, dividend, yield, mktCap, mktCapX and advancing.

The expression must return a boolean value, otherwise it will fail.

For detailed information about the syntax, please refer to Knetic/govaluate#what-operators-and-types-does-this-support.

To clear the filter, press Shift+F.

You can specify the profile you want to use by passing -profile <filename> to the command-line.

Options and settings

In ~/.moprc:

    "RowShading": true,

will cause row shading on alternate lines.

Contributing

  • Pull requests accepted.

License

Copyright (c) 2013-2024 by Michael Dvorkin and contributors. All Rights Reserved. "mike" + "@dvorkin" + ".net" || "twitter.com/mid"

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Packages

# Functions

Initializes a color to the given string, or to the default value if the given string does not represent a supported color.
Checks if a string represents a supported color or not.
Returns new initialized ColumnEditor struct.
Returns new Filter struct.
Creates the layout and assigns the default values that stay unchanged.
Returns new initialized LineEditor struct.
Returns new initialized Market struct.
Creates markup to define tag to Termbox translation rules and store default colors and column alignments.
Creates the profile and attempts to load the settings from ~/.moprc file.
Sets the initial values and returns new Quotes struct.
Initializes Termbox, creates screen along with layout and markup, and calculates current screen dimensions.
Returns new Sorter struct.

# Structs

Column describes formatting rules for individual column within the list of stock quotes.
ColumnEditor handles column sort order.
Filter gets called to sort stock quotes by one of the columns.
Layout is used to format and display all the collected data, i.e.
LineEditor kicks in when user presses '+' or '-' to add or delete stock tickers.
Market stores current market information displayed in the top three lines of the screen.
Markup implements some minimalistic text formatting conventions that get translated to Termbox colors and attributes.
Profile manages Mop program settings as defined by user (ex.
Quotes stores relevant pointers as well as the array of stock quotes for the tickers we are tracking.
Screen is thin wrapper around Termbox library to provide basic display capabilities as required by Mop.
Sorter gets called to sort stock quotes by one of the columns.
Stock stores quote information for the particular stock ticker.