DEV Community

Cover image for #FOSS In Python: Using The OpenBB Terminal To Automate Processes & Research Tasks In Finance
Danglewood
Danglewood

Posted on

#FOSS In Python: Using The OpenBB Terminal To Automate Processes & Research Tasks In Finance

Support the project: GitHub Twitter Discord Documentation

OpenBB Terminal Routines With Simple Script Technology

In this one minute video, OpenBB Founder Didier Lopes, demonstrates an advanced routine. Continue reading to explore this unique technology and learn how to improve efficiency through workflow.

Routines are executed from the main menu using the command, exe. Help dialogue will be displayed for any function by attaching '-h' to the command string.

2022 Mar 27, 16:36 (✨) / $ exe -h
usage: exe [-p PATH] [-i ROUTINE_ARGS] [-h]

Execute automated routine script.

optional arguments:
  -p PATH, --path PATH  The path or .gst file to run. (default: )
  -i ROUTINE_ARGS, --input ROUTINE_ARGS
                        Select multiple inputs to be replaced in the routine and separated by commas. E.g. GME,AMC,BTC-USD (default: None)
  -h, --help            show this help message (default: False)
Enter fullscreen mode Exit fullscreen mode

The script files are located in a folder labeled routines, and have a filename extension of .GST. There is also a folder named scripts containing .GST files that test the functions of the terminal. It is recommended to store user-generated files in the routines folder.

Take a closer look at the contents of the file: example_with_inputs_saved.gst

Routines folder and a commented example file

Notice that the code within the script is merely a terminal command on each line where $ARGV is a variable for the desired ticker(s). The routines have the flexibility to be a specific or variable value for any number of tickers.

If you can operate the Terminal, you can build scripts!

The OpenBB Terminal can be launched to play a routine immediately. It's easy to make changes to the routine with any text editor. I have made modifications to example_with_inputs.gst to look like this:

stocks
load $ARGV[0]
ta
fib
../ca
add $ARGV[1],$ARGV[2],$ARGV[3],$ARGV[4]
historical -n -s 2009-03-26
hcorr
Enter fullscreen mode Exit fullscreen mode

It can be executed in this manner:

python terminal.py routines/example_with_inputs.gst --input VT,SPY,QQQ,BND,GSG
Enter fullscreen mode Exit fullscreen mode

This generates an output from the terminal that looks like this:

2022 Mar 27, 18:37 (✨) /stocks/ $ load VT

Loading Daily VT stock with starting period 2019-03-25 for analysis.

Datetime: 2022 Mar 27 18:37
Timezone: America/New_York
Currency: USD
Market:   CLOSED

2022 Mar 27, 18:37 (✨) /stocks/ $ ta
2022 Mar 27, 18:37 (✨) /stocks/ta/ $ fib

Fibonacci retracement levels
┏━━━━━━━━━━━┳━━━━━━━━┓
┃ Fib Level ┃ Price  ┃
┡━━━━━━━━━━━╇━━━━━━━━┩
│ 0.0%      │ 108.14 │
├───────────┼────────┤
│ 23.5%     │ 95.06  │
├───────────┼────────┤
│ 38.2%     │ 86.88  │
├───────────┼────────┤
│ 50.0%     │ 80.31  │
├───────────┼────────┤
│ 61.8%     │ 73.74  │
├───────────┼────────┤
│ 65.0%     │ 71.96  │
├───────────┼────────┤
│ 100.0%    │ 52.48  │
└───────────┴────────┘

2022 Mar 27, 18:37 (✨) /stocks/ $ ca
2022 Mar 27, 18:37 (✨) /stocks/ca/ $ add BND,SPY,QQQ,GSG
[Custom] Similar Companies: SPY, QQQ, BND, GSG, VT 

2022 Mar 27, 18:37 (✨) /stocks/ca/ $ historical -n -s 2009-03-26


2022 Mar 27, 18:37 (✨) /stocks/ca/ $ hcorr


2022 Mar 27, 18:37 (✨) /stocks/ca/ $
Enter fullscreen mode Exit fullscreen mode

Three charts were created by the script:

Charts created by the routine
Charts created by the routine
Charts created by the routine

Any function of the OpenBB Terminal can be automated, tables and images can be exported for any feature equipped with the '--export' flag. The possibilities are limitless here. Combine data exports with the data cache and import functionality of the economy and econometrics menu to unlock new, powerful, tools at the disposal of the open-source community.

Show us what your routine looks like!

Support the project: GitHub Twitter Discord Documentation

Top comments (0)