#FOSS In Python: Using The OpenBB Terminal To Automate Processes & Research Tasks In Finance
Tags: opensource, python, showdev, productivity
Published: 2022-03-27 23:12:29

Support the project: <a href="https://github.com/gamestonkterminal/gamestonkterminal" class="btn">GitHub</a> <a href="https://twitter.com/gamestonkt" class="btn">Twitter</a> <a href="https://discord.com/invite/Up2QGbMKHY" class="btn">Discord</a> <a href="https://gamestonkterminal.github.io/GamestonkTerminal/" class="btn">Documentation</a>
 
**<u>OpenBB Terminal Routines With Simple Script Technology</u>**

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.

{% youtube pH0srojpv8Q %}

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)
  ```

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dpxc52n6gc701j8x64ww.png)

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.

**<u>If you can operate the Terminal, you can build scripts!</u>**

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
```

It can be executed in this manner:

```
python terminal.py routines/example_with_inputs.gst --input VT,SPY,QQQ,BND,GSG
```

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/ $
```

Three charts were created by the script:

![Charts created by the routine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p55kvk1vgwpvqzvg53nx.png)
![Charts created by the routine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yym936d3gtepyf7kmu7u.png)
![Charts created by the routine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0hael5lo9ywreoauayw4.png)
 

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: <a href="https://github.com/gamestonkterminal/gamestonkterminal" class="btn">GitHub</a> <a href="https://twitter.com/gamestonkt" class="btn">Twitter</a> <a href="https://discord.com/invite/Up2QGbMKHY" class="btn">Discord</a> <a href="https://gamestonkterminal.github.io/GamestonkTerminal/" class="btn">Documentation</a>