2 min read
Jupyter AI provides a state-of-the-art resource for data scientists, data analysts, and traders/investors, boosting their Python programming productivity and efficiency. This tool significantly enhances productivity by enabling the rapid execution of your Python codes and strategies 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 Traders/Investors can take advantage of JupyterAI
- Enhanced Analysis: Traders can utilize 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 leverage 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 invaluable. 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 straightforward steps outlined 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.
This flexibility ensures that the output is in the most appropriate format for your specific needs.
Jupyter AI is more than just a tool; it’s a comprehensive solution for traders and investors seeking to harness the power of AI in their decision-making process. Its versatility, ease of use, and powerful features make it an indispensable asset in the world of finance. As the world of trading and investing continues to evolve, Jupyter AI stands out as a beacon of innovation, driving efficiency and insight in market analysis.