Skip to content

Plot.py ‐ Watchlists and Presets

Benny Thadikaran edited this page Aug 18, 2023 · 12 revisions

This tutorial divided into 4 sections

Make sure you read Plot.py - Basic Usage before reading this wiki.

So far we used --sym option with a single symbol. But we can provide multiple symbols as well.

py plot.py --sym tcs infy hcltech

The script will simply loop through each of the charts. When one chart is quit, the next pops up.

This is reasonable behavior for 2-3 symbols but it's difficult to terminate the script when there are 50+ symbols to loop through.

Prompt interface

If passing 5 or more symbols, the script implements a prompt interface between each chart.

plot.py prompt interface

The prompt accepts a single key input (No need to press enter):

  • n for next chart,
  • p for previous chart,
  • c to replot the current chart and
  • q to quit

You are also shown your current progress through the symbols.

Resume a watchlist

When using a watchlist, if you quit the prompt midway using q, your progress is saved.

This feature is only available when using --watch option or using a preset with --watch.

You can resume from the last chart, using the same watchlist, by adding the -r or --resume.

Using prebuilt watchlists

Since its tedious to type the symbol names, you can create your own watchlists.

For now lets use a builtin watchlist named sectors

To load charts from sectors watchlist use the --watch option providing the watchlist name.

py plot.py --watch sectors

Adding new Watchlists

To add a new watchlist, create a csv or txt file in the data folder with symbol names, one on each line.

mylist.csv

tcs
hdfcbank
m&m
reliance
tatamotors

Use the --watch-save option passing the watchlist name and the filename

py plot.py --watch-save mylist mylist.csv
# Saved watchlist 'mylist' with value 'mylist.csv'

Plot charts from watchlist

Load the watchlist with --watch

py plot.py --watch mylist

Now open defs/user.json.

{
   "WATCH": {
      "MYLIST": "mylist.csv"
   }
}

The user.json is used to override any default configuration. We will come to it later, for now all watchlists are stored in WATCH

Using --watch-save on an existing watchlist will overwrite the filename.

Organizing your watchlists

If you have many watchlists in the data folder, you can organise them in folders. Just make sure to pass the filepath relative to the data folder

py plot.py --watch-save it sectors/it.csv

py plot.py --watch-save bank sectors/bank.csv

Remove Watchlist

To remove a watchlist, use --watch-rm passing the watchlist name.

py plot.py --watch-rm mylist
# Watchlist 'mylist' removed.

This will not delete the watchlist file in the data folder.

Using Presets

Its helpful initially, to get used to all the options, by manually typing them. But if you run these commands daily or weekly, you may want to predefine these options in a preset.

Use the --preset-save passing a name.

py plot.py --watch sectors -tf weekly --sma 30 --m-rs -v --preset-save sectors-w

Next time, just use --preset option passing the preset name. It will load all the above options.

py plot.py --preset sectors-w

Remove a preset

To remove a preset, use --preset-rm passing the preset name.

py plot.py --preset-rm sectors-w

Listing presets and watchlists

In case you forgot the preset or watchlist names, use --ls

py plot.py --ls
# WatchLists: sectors
# No Presets