Gateston Johns
first real commit
9041389
NER_TAGGING_PROMPT = '''
You are an expert in finance who will be performing Named Entity Recognition (NER)
with the high-level objective of analyzing financial documents. The output should
be formatted as a JSON object, where the JSON object has a key "entities" that
contains a list of the extracted entities. If no entities are found, return an
empty JSON object.
- Finacial Markets (Grouping of financial securities)
- Finacial Securities
- Finacial Indicators
Now, given a text chunk, extract the relevant entities and format the output as a JSON object.
Examples of entities:
- Financial Markets: "US Stock Market", "US Bond Market", "US Real Estate Market", "Tech Stocks", "Energy Stocks"
- Financial Securities: "Apple", "Tesla", "Microsoft", "USD", "Bitcoin", "Gold", "Oil"
- Economic Indicators: "Consumer Price Index (CPI)", "Unemployment Rate", "GDP Growth Rate", "Federal Deficit"
Input:
Scores on the Doors: crypto 65.3%, gold 10.1%, stocks 7.7%, HY bonds 4.3%, IG bonds 4.3%, govt bonds 3.4%,
oil 3.7%, cash 1.2%, commodities -0.1%, US dollar -2.0% YTD.
The Biggest Picture: everyone's new favorite theme...US dollar debasement; US$ -11%
since Sept, gold >$2k, bitcoin >$30k; right secular theme (deficits, debt, geopolitics),
US$ in 4th bear market of past 50 years, bullish gold, bearish Euro, bullish international
stocks; but pessimism so high right now, and 200bps Fed cuts priced in from June to election,
look for US$ trading bounce after Fed ends hiking cycle May 3rd (Chart 2).
2024 Tale of the Tape: inflation slowing, Fed hiking cycle over, recession
expectations universal, yet UST 30-year can't break below 3.6% (200-dma) because we've already traded 8% to 4% CPI,
labor market yet to crack, US govt deficit growing too quickly. The Price is Right: next 6 months it's
“recession vs Fed cuts”; best tells who's winning...HY bonds, homebuilders, semiconductors...HYG <73, XHB <70,
SOX <2900 recessionary, and if levels hold...it's a no/soft landing.
Output:
{
"entities": [
{
"name": "crypto",
"type": "Financial Securities",
},
{
"name": "gold",
"type": "Financial Securities",
},
{
"name": "stocks",
"type": "Financial Securities",
},
{
"name": "HY bonds",
"type": "Financial Securities",
},
{
"name": "IG bonds",
"type": "Financial Securities",
},
{
"name": "govt bonds",
"type": "Financial Securities",
},
{
"name": "oil",
"type": "Financial Securities",
},
{
"name": "cash",
"type": "Financial Securities",
},
{
"name": "commodities",
"type": "Financial Securities",
},
{
"name": "US dollar",
"type": "Financial Securities",
},
{
"name": "US$",
"type": "Financial Securities",
},
{
"name": "gold",
"type": "Financial Securities",
},
{
"name": "bitcoin",
"type": "Financial Securities",
},
{
"name": "UST 30-year",
"type": "Financial Securities",
},
{
"name": "CPI",
"type": "Economic Indicators",
},
{
"name": "labor market",
"type": "Economic Indicators",
},
{
"name": "US govt deficit",
"type": "Economic Indicators",
},
{
"name": "HY bonds",
"type": "Financial Securities",
},
{
"name": "homebuilders",
"type": "Financial Markets",
},
{
"name": "semiconductors",
"type": "Financial Markets",
},
{
"name": "HYG",
"type": "Financial Securities",
},
{
"name": "XHB",
"type": "Financial Securities",
},
{
"name": "SOX",
"type": "Financial Securities",
}
]
}
Input:
the latest tech stock resurgence of 2024; NASDAQ +15% since January, Apple >$180, Tesla >$250;
driven by strong earnings, innovation, and AI advancements, NASDAQ in its 3rd bull market of the past decade,
bullish on semiconductors, cloud computing, and cybersecurity stocks; however, optimism
is soaring, and 150bps rate hikes anticipated from July to year-end, expect a potential
pullback in tech stocks after the next earnings season concludes in August (Chart 3).
Anyway, the bipartisan agreement to suspend the US debt ceiling until 2025 with only limited
fiscal restraint (roughly 0.1-0.2% of GDP yoy in 2024 and 2025 compared with the baseline)
means that we have avoided another potential significant negative shock to demand.
On the brightside, the boost to funding that Congress approved late last year for FY23
was so large (nearly 10% yoy) that overall discretionary spending is likely to be slightly
higher in real terms next year despite the new caps.
Output:
{
"entities": [
{
"name": "NASDAQ",
"type": "Financial Securities",
},
{
"name": "Apple",
"type": "Financial Securities",
},
{
"name": "Tesla",
"type": "Financial Securities",
},
{
"name": "semiconductors",
"type": "Financial Market",
},
{
"name": "cloud computing",
"type": "Financial Market",
},
{
"name": "cybersecurity stocks",
"type": "Financial Market",
},
{
"name": "tech stocks",
"type": "Financial Marker",
},
{
"name": "GDP",
"type": "Economic Indicators",
},
{
"name": "FY23",,
"type": "Economic Indiciators",
}
]
}
'''
EXTRACT_RELATIONSHIPS_PROMPT = '''
As a finance expert, your role is to extract relationships between a set of entities.
You will receive an excerpt from a financial report, the name of the analyst who authored
it, the date the report was published, and a list of entities that have already been extracted.
Your task is to identify and output relationships between these entities to construct a
knowledge graph for financial document analysis.
Your output should be a JSON object containing a single key, "relationships,"
which maps to a list of the extracted relationships. These relationships should be
formatted as structured JSON objects. Each relationship type must include "from_entity"
and "to_entity" attributes, using previously extracted entities as guidance,
to denote the source and target of the relationship, respectively. Additionally, all
relationship types should have "start_date" and "end_date" attributes, formatted as
"YYYY-MM-DD". The "source_text" attribute within a relationship should directly quote
the description of the relationship from the financial report excerpt.
The relationship types you need to extract include:
[Relationship Type 1: "PREDICTION"]: This relationship captures any forecasts or predictions the analyst makes
regarding trends in financial securities, indicators, or market entities. Search for phrases such as "we forecast,"
"is likely that," or "expect the market to." You must also assess the sentiment of the prediction—whether it is neutral,
positive (increase), or negative (decrease)—and include this in the relationship. Map the sentiment to one of the following
- PREDICTED_MOVEMENT_NEUTRAL (neutral sentiment)
- PREDICTED_MOVEMENT_INCREASE (positive sentiment)
- PREDICTED_MOVEMENT_DECREASE (negative sentiment)
The "from_entity" should be the analyst's name(s), while the "to_entity" should be the entity the prediction concerns (utilize the previously extracted entities as guidance).
Each prediction must have a defined "start_date" and "end_date" indicating the expected timeframe of the prediction. If
the prediction is not explicitly time-bound, omit this relationship. Use the report's publishing date as the "start_date"
unless the author specifies a different date. The "end_date" should correspond to when the prediction is anticipated to conclude.
Be sure to include the source excerpt you used to derive each relationship in the "source_text" attribute of the corresponding relationship.
Realize that predictions are about the future. Lastly, note that sometimes you will need to infer what entity is being referred to,
even if it is not explicitly named in the source sentence.
Example Input:
Analyst: Helen Brooks
Publish Date: 2024-06-12
Text Chunk: Labor markets are showing signs of normalization to end 2024; unemployment could drift higher in 2024 while remaining low in historical context.
Momentum in the job market is starting to wane with slowing payroll growth and modestly rising unemployment, as well as declining quit rates and temporary help.
Increased labor force participation and elevated immigration patterns over the past year have added labor supply, while a shortening work week indicates moderating demand for labor.
Considering the challenges to add and retain workers coming out of the pandemic, businesses could be more reluctant than normal to shed workers in a slowing economic environment.
Even so, less hiring activity could be enough to cause the unemployment rate to tick up to the mid-4% area by the end of next year due to worker churn.
Already slowing wage gains should slow further in the context of a softer labor market.
Anyway, the bipartisan agreement to suspend the US debt ceiling until 2025 with only limited
fiscal restraint (roughly 0.1-0.2% of GDP yoy in 2024 and 2025 compared with the baseline)
means that we have avoided another potential significant negative shock to demand.
On the brightside, the boost to funding that Congress approved late last year for FY23
was so large (nearly 10% yoy) that overall discretionary spending is likely to be slightly
higher in real terms next year despite the new caps.
{
"entities": [
{
"name": "labor markets",
"type": "Economic Market",
},
{
"name": "unemployment",
"type": "Economic Indicators",
},
{
"name": "job market",
"type": "Economic Market",
},
{
"name": "payroll growth",
"type": "Economic Indicators",
},
{
"name": "labor force participation",
"type": "Economic Indicators",
},
{
"name": "rising unemployment",
"type": "Economic Indicators",
}
{
"name": "immigration patterns",
"type": "Economic Indicators",
},
{
"name": "hiring activity",
"type": "Economic Indicators",
},
{
"name": "worker churn",
"type": "Economic Indicators",
},
{
"name": "unemployment rate",
"type": "Economic Indicators",
},
{
"name": "discretionary spending",
"type": "Economic Indicators",
},
{
"name": "GDP",
"type": "Economic Indicators",
}
]
}
Example Output:
{
"relationships": [
{
"PREDICTION": {
"from_entity": "Helen Brooks",
"to_entity": "labor market",
"start_date": "2024-06-12",
"end_date": "2024-12-31",
"predicted_movement": "PREDICTED_MOVEMENT_NEUTRAL",
"source_text": "Labor markets are showing signs of normalization to end 2024;"
}
},
{
"PREDICTION": {
"from_entity": "Helen Brooks",
"to_entity": "unemployment",
"startDate": "2024-06-12",
"endDate": "2024-12-31",
"predicted_movement": "PREDICTED_MOVEMENT_INCREASE",
"source_text": "unemployment could drift higher in 2024 while remaining low in historical context."
}
},
{
"PREDICTION": {
"from_entity": "Helen Brooks",
"to_entity": "unemployment rate",
"start_date": "2024-06-12",
"end_date": "2025-12-31",
"predicted_movement": "PREDICTED_MOVEMENT_INCREASE",
"source_text": "Even so, less hiring activity could be enough to cause the unemployment rate to tick up to the mid-4% area by the end of next year due to worker churn."
}
},
{
"PREDICTION": {
"from_entity": "Helen Brooks",
"to_entity": "discretionary spending",
"start_date": "2024-06-12",
"end_date": "2025-12-31",
"predicted_movement": "PREDICTED_MOVEMENT_INCREASE",
"source_text": "On the brightside, the boost to funding that Congress approved late last year for FY23 was so large (nearly 10% yoy) that overall discretionary spending is likely to be slightly higher in real terms next year despite the new caps."
}
},
]
}
Example Input:
Analyst: John Doe, Herb Johnson, Taylor Mason
Publish Date: 2024-01-02
Text Chunk: Scores on the Doors: crypto 65.3%, gold 10.1%, stocks 7.7%, HY bonds 4.3%, IG bonds 4.3%, govt bonds 3.4%,
oil 3.7%, cash 1.2%, commodities -0.1%, US dollar -2.0% YTD. The Biggest Picture: everyone’s new favorite
theme...US dollar debasement; US$ -11% since Sept, gold >$2k, bitcoin >$30k; right secular theme (deficits,
debt, geopolitics), US$ in 4th bear market of past 50 years, bullish gold, oil, Euro, international stocks; but pessimism
so high right now, and 200bps Fed cuts priced in from June to election, look for US$ trading bounce after Fed
ends hiking cycle May 3rd (Chart 2). Tale of the Tape: inflation slowing, Fed hiking cycle over, recession
expectations universal, yet UST 30-year can’t break below 3.6% (200-dma) because we’ve already traded 8% to 4% CPI,
labor market yet to crack, US govt deficit growing too quickly. The Price is Right: next 6 months it’s
“recession vs Fed cuts”; best tells who’s winning...HY bonds, homebuilders, semiconductors...HYG <73, XHB <70,
SOX <2900 recessionary, and if levels hold...it’s a no/soft landing.
{
"entities": [
{
"name": "crypto",
"type": "Financial Securities",
},
{
"name": "gold",
"type": "Financial Securities",
},
{
"name": "stocks",
"type": "Financial Securities",
},
{
"name": "HY bonds",
"type": "Financial Securities",
},
{
"name": "IG bonds",
"type": "Financial Securities",
},
{
"name": "govt bonds",
"type": "Financial Securities",
},
{
"name": "oil",
"type": "Financial Securities",
},
{
"name": "cash",
"type": "Financial Securities",
},
{
"name": "commodities",
"type": "Financial Securities",
},
{
"name": "US dollar",
"type": "Financial Securities",
},
{
"name": "US$",
"type": "Financial Securities",
},
{
"name": "gold",
"type": "Financial Securities",
},
{
"name": "bitcoin",
"type": "Financial Securities",
},
{
"name": "UST 30-year",
"type": "Financial Securities",
},
{
"name": "CPI",
"type": "Economic Indicators",
},
{
"name": "labor market",
"type": "Economic Indicators",
},
{
"name": "US govt deficit",
"type": "Economic Indicators",
},
{
"name": "HY bonds",
"type": "Financial Securities",
},
{
"name": "homebuilders",
"type": "Financial Markets",
},
{
"name": "semiconductors",
"type": "Financial Markets",
},
{
"name": "HYG",
"type": "Financial Securities",
},
{
"name": "XHB",
"type": "Financial Securities",
},
{
"name": "SOX",
"type": "Financial Securities",
}
]
}
Example Output:
{
"relationships": [
{
"PREDICTION": {
"from_entity": "John Doe, Herb Johnson, Taylor Mason",
"to_entity": "US$",
"start_date": "2024-06-12",
"end_date": "2024-11-05",
"predicted_movement": "PREDICTED_MOVEMENT_INCREASE",
"source_text": "200bps Fed cuts priced in from June to election, look for US$ trading bounce after Fed ends hiking cycle May 3rd."
}
"PREDICTION": {
"from_entity": "John Doe, Herb Johnson, Taylor Mason",
"to_entity": "Fed cuts",
"start_date": "2024-06-12",
"end_date": "2024-11-05",
"predicted_movement": "PREDICTED_MOVEMENT_DECREASE",
"source_text": "200bps Fed cuts priced in from June to election, look for US$ trading bounce after Fed ends hiking cycle May 3rd."
}
},
]
}
'''