Jupyter AI is a tool for data scientists, data analysts, and traders/investors that improves Python programming productivity. It helps you write and run your Python code and strategies faster within a Jupyter notebook. With this tool, you now have the ability to interact through chat with leading Large Language Models (LLMs) such as AI21, Anthropic, Cohere, Hugging Face, OpenAI, and SageMaker, among others.

JupyterAI runs on most operating systems and integrates with various platforms like Google Colab and VSCode.
How to Use Jupyter AI for Traders and Investors
- Enhanced Analysis: Traders can use Jupyter AI to analyze complex financial data, generate predictive models, and even simulate market scenarios. The ability to quickly generate and test hypotheses can significantly improve decision-making.
- Automated Research: Investors can use Jupyter AI to automate parts of their research. By feeding prompts into the system, they can generate comprehensive market reports, summaries, and even predictive insights about market trends.
- Code Generation and Error Fixing: Jupyter AI’s ability to generate code snippets and fix errors is very useful. Traders can use this feature to develop custom algorithms, back-test trading strategies, or even automate parts of their trading systems.
- Interactive Learning: The platform can act as an educational tool, helping users understand complex financial concepts and algorithms through interactive examples and explanations.
Prerequisites
Jupyter AI is compatible with any system capable of running Python versions ranging from 3.8 to 3.11.
Install VS Code with Python preferably less than 3.11 with Jupyter Extensions (remember at the time of writing the latest version is 3.12)
Installation
Install jupyterAI using the pip command
pip install jupyter_ai
Get the API Key from OpenAI
To integrate OpenAI with PandasAI, an API token is necessary. Follow the steps below to create your API_TOKEN with OpenAI.
- Go to https://platform.openai.com/apps and signup with your email address or connect your Google Account.
- Go to View API Keys on the left side of your Personal Account Settings
- Select Create New Secret key

The API access to openai is a paid service. You have to set up billing. Read the Pricing information before experimenting.
Load the JupyterAI extension
- Launch Visual Studio Code and Open a Jupyter Notebook
- Activate the Extension Using This Command in a Jupyter Cell:
%load_ext jupyter_ai
Set the Environmental Variable
import os
os.environ['OPENAI_API_KEY'] = 'sk-your-openai-api-key'
List of Supported AI LLM Models

The %%ai Magic Command
The %%ai cell magic allows the invocation of a chosen model with a prompt. This flexibility lets users tailor their experience, whether they require complex data analysis, natural language processing, or even image generation models.
%%ai chatgpt --format code
Write a Python Code to Fetch the data from yfinance and plot the line charts using plotly for the ticker HDFCBANK.NS

Get the Latex Math Formulas
%%ai chatgpt --format math
Write the Black Sholes Formula for Computing implied volatility

Create Automated Markdown with Brief Instructions
%%ai chatgpt --format markdown
Explain Pandas Dataframe

List of Supported Format Types
Jupyter AI is programmed to anticipate markdown as the default output format from a model. Consequently, the results of an %%ai command are typically presented in markdown. However, this can be altered with the -f or --format option in your magic command, allowing for a variety of output formats. These formats include:
code: For output that is primarily code-centric.image: This is exclusive to text-to-image models from Hugging Face Hub.markdown: The default format, suitable for general text and formatting.math: Ideal for mathematical expressions and equations.html: Useful for outputs that should be in HTML format.json: For outputs that are best represented in JSON format.text: A simple, unformatted text output.
Pick the format that suits the output you need.
Jupyter AI for traders and investors is a practical way to bring AI models into their Python workflow. It is easy to set up, supports many models and output formats, and saves time when writing and testing analysis code.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

