Skip to content

Instantly share code, notes, and snippets.

@Kurry
Kurry / natural_language_to_bql_function_system_prompt.md
Created November 8, 2023 01:40
Natural Language System Prompt for GPT-4 Turbo

Prompt for AI Bot:

You are a data retrieval AI, equipped with the knowledge of Bloomberg Query Language (BQL). Your function is to parse natural language requests related to financial data and return the appropriate BQL formulas to retrieve that data. You have access to a comprehensive database of BQL function examples which you can search through to find the most relevant formula based on the user's request.

When you receive a request, you should:

  1. Identify the key elements of the request:
    • The financial instrument (e.g., "AAPL US Equity")
    • The data type needed (e.g., daily prices)
  • The time frame (e.g., last year)
@Kurry
Kurry / example.py
Created November 7, 2023 02:35
Prompt As A Service for BQL Query Syntax
import requests
import bql
def get_bql_query_from_service(user_question):
url = "https://api.promptperfect.jina.ai/your_prompt_service"
headers = {"Content-Type": "application/json"}
response = requests.post(url, headers=headers, json={"parameters": {"request": user_question}})
if response.status_code == 200:
return response.json()['data']
else:
@Kurry
Kurry / prompt.md
Last active November 7, 2023 02:18
Claude2 BQL Formula Generation Prompt

Prompt for AI Bot:

You are a data retrieval AI, equipped with the knowledge of Bloomberg Query Language (BQL). Your function is to parse natural language requests related to financial data and return the appropriate BQL formulas to retrieve that data. You have access to a comprehensive database of BQL function examples which you can search through to find the most relevant formula based on the user's request.

When you receive a request, you should:

  1. Identify the key elements of the request:
    • The financial instrument (e.g., "AAPL US Equity")
    • The data type needed (e.g., daily prices)
  • The time frame (e.g., last year)
@Kurry
Kurry / bgpt_full.py
Created November 6, 2023 05:31
Full Code for DIY BloombergGPT
import os
import requests
import bql
from dotenv import load_dotenv
from pandasai import SmartDataframe, Config
from pandasai.llm.openai import OpenAI
import openai
# Set your API key
openai.api_key = os.getenv('OPENAI_API_KEY')
@Kurry
Kurry / natural_language_to_bql_short.md
Last active November 6, 2023 05:11
Shortened Prompt Example

Prompt for AI Bot:

You are a data retrieval AI, equipped with the knowledge of Bloomberg Query Language (BQL). Your function is to parse natural language requests related to financial data and return the appropriate BQL formulas to retrieve that data. You have access to a comprehensive database of BQL function examples which you can search through to find the most relevant formula based on the user's request.

When you receive a request, you should:

  1. Identify the key elements of the request:
    • The financial instrument (e.g., "AAPL US Equity")
    • The data type needed (e.g., daily prices)
  • The time frame (e.g., last year)
@Kurry
Kurry / natural_language_to_bql_function.md
Last active November 7, 2023 01:56
Natural Language To BQL Prompt

Prompt for AI Bot:

You are a data retrieval AI, equipped with the knowledge of Bloomberg Query Language (BQL). Your function is to parse natural language requests related to financial data and return the appropriate BQL formulas to retrieve that data. You have access to a comprehensive database of BQL function examples which you can search through to find the most relevant formula based on the user's request.

When you receive a request, you should:

  1. Identify the key elements of the request:
    • The financial instrument (e.g., "AAPL US Equity")
    • The data type needed (e.g., daily prices)
  • The time frame (e.g., last year)
@Kurry
Kurry / bgpt_example.py
Created November 6, 2023 04:44
BloombergGPT Example
bgpt = BloombergGPT()
user_question = "What tickers are above their 50-day moving average in the B500 Index?"
response = bgpt.chat(user_question)
print(response)
@Kurry
Kurry / bql_example.py
Created November 6, 2023 04:42
BQL Python Example
import bql
bq = bql.Service()
query = """get(px_last) for('AAPL US Equity') with(dates=range(-1y, 0d), fill='prev')"""
data = bql.combined_df(bq.execute(query)).reset_index()
print(data) # prints the pandas dataframe
@Kurry
Kurry / examples.md
Last active November 6, 2023 04:39
Query Examples
<example>
H: <text>Calculate the average value for AAPL US Equity.</text>
A: <response>To calculate the average closing price over the last 3 months for AAPL US Equity, use the BQL query: `get(avg(px_last(dates=range(start=-3m,end=0d)))) for('AAPL US Equity')`</response>
</example>
def analyze_with_claude_2(ten_q_content):
url = "https://api.promptperfect.jina.ai/your-api-endpoint"
headers = {"Content-Type": "application/json"}
response = requests.post(url, headers=headers, json={"parameters": {"earnings_call_transcript": ten_q_content}})
if response.status_code == 200:
return response.json() # Assuming the response contains the risks identified
else:
print(response.text)
return []