All work

ENGINEERING STUDIES / 02 — EQUITYGUARD

EquityGuard / Independent project

An agent
with tools.
And boundaries.

I built a full-stack financial risk application around an AI agent. The interesting part is how the interface, APIs and tools give that agent somewhere useful to work.

APPLICATION BOUNDARYFIG. 01
01 / INTERFACEReactRequest · loading · result
02 / APIFastAPIValidate · dispatch · shape
03 / ORCHESTRATIONModel ↔ tools
One intelligent component.
A whole application around it.
My contribution
Independent full-stack development
Application
React + FastAPI
Agent
Custom Python loop · Claude API
Verification
23 automated tests · GitHub Actions

01 / THE QUESTION

What sits between a question
and a useful answer?

Price history, momentum indicators, news and company documents each tell part of a story. EquityGuard brings those inputs into a tool-driven analysis workflow.

I developed the React interface, FastAPI service, tool integrations and agent orchestration as one application. It explores financial risk analysis; it does not establish predictive accuracy or provide professional financial advice.

A real interface.
A defined request.

A watchlist and ticker search provide the entry point. React handles selection, loading and errors, then presents the API’s result.

Actual EquityGuard React watchlist with ticker search, ten stocks and NVDA selected. Prices are zero-value offline fixtures.
FIG. 02 / REACT WATCHLISTCaptured locally from the source interface with zero-value offline price fixtures. No market data or model calls.

02 / BEYOND THE CHATBOX

The model is one part
of the application.

Each layer owns a different responsibility. The browser makes a request; Python orchestrates the work; tool functions fetch or calculate context.

Useful boundaries
are software, too.

LOGICAL VIEW
SOURCE-GROUNDED / NOT A DEPLOYMENT MAP
  1. 01

    React Interaction

    Selection and ticker search → POST /analyse. Non-success responses become visible errors. The results view reads the score, explanation and tools used.

  2. 02

    FastAPI Application boundary

    RiskRequest accepts a ticker and optional query. The service normalises the ticker, applies the advice phrase filter, runs the agent and returns a RiskResponse.

  3. 03

    Python agent Orchestration

    Direct Anthropic SDK calls with six JSON input schemas. A named registry dispatches tool calls and serialises returned dictionaries for the next model call.

  4. 04

    Tools & sources Context

    yfinance data, deterministic indicators, local ticker-matched files and a separate vector-retrieval path. Their outputs become context, not verified conclusions.

RESPONSE → REACTticker · risk_score? · risk_label · explanation · tools_called

The API also serialises trace metadata. This case study focuses on observable tool contracts and does not reproduce private model reasoning.

03 / INSIDE THE AGENT

A loop, with an exit.

ReAct-style orchestration, implemented directly in Python. The reviewed loop is not built on LangChain.

  1. 01

    Receive

    FastAPI trims and uppercases the ticker, builds a query and checks advice-request phrases.

  2. 02

    Ask

    Python sends the request, conversation and six tool schemas directly to the Claude API.

  3. 03

    Dispatch

    Named tool-use blocks are looked up in the registry. Returned dictionaries become JSON tool results.

  4. 04

    Continue or stop

    Tool results return to the model. An end_turn response finishes; the loop allows up to six iterations.

  5. 05

    Respond

    The API extracts a score from text, assigns a label and returns a RiskResponse for the React results view.

Tool use returns to the model. The path depends on returned tool-use blocks; this drawing describes the source control flow, not a recorded execution.

Stopping is explicit. Other stop reasons break the loop. Exhaustion returns “Agent reached maximum iterations.” A loop limit does not guarantee successful analysis.

04 / TOOL INSPECTOR

Six tools.
Different responsibilities.

A tool name can hide a lot. Select one to see what it accepts, what it returns and where its responsibility ends.

01 / Price & volatility

External data + calculation

Price & volatility

get_price_data

Establish a market-data baseline before interpreting risk.

Input
ticker: string (required)
Returns
ticker, current_price, previous_close, day_change_pct, volume, avg_volume_10d, beta, volatility_30d_annualised_pct, 52w_high, 52w_low
Boundary
Fetches 30 days of history through yfinance. Annualises daily-return volatility using √252. Empty history or an exception returns an error dictionary; some missing fields use defaults.
Test evidence
The inspected suite does not mock or exercise this external data path.
Read this implementation
02 / Technical signals

Calculation over external data

Technical signals

get_technical_signals

Turn price history into explicit momentum indicators.

Input
ticker: string (required)
Returns
ticker, rsi_14, rsi_signal, macd_signal, bollinger_position_pct, bollinger_signal
Boundary
Fetches three months of history and requires at least 30 rows. Computes 14-period RSI, 12/26/9 MACD and 20-period Bollinger position. Empty or short history returns an error.
Test evidence
Seven tests check RSI and Bollinger examples using helpers defined inside the test file. They do not invoke this production tool or test MACD.
Read this implementation
03 / News context

External retrieval

News context

get_news_sentiment

Bring recent headlines into the model’s analysis context.

Input
ticker: string (required) · company_name: string (optional)
Returns
ticker, headline_count, headlines[{title, published, summary}]
Boundary
Returns up to eight yfinance news items with summaries truncated to 200 characters. The optional company name is unused. Despite its name, this tool does not compute a numerical sentiment score.
Test evidence
The inspected suite does not test the news response or provider failures.
Read this implementation
04 / Earnings proximity

External data + date rules

Earnings proximity

get_earnings_risk

Describe proximity to an earnings event using deterministic thresholds.

Input
ticker: string (required)
Returns
ticker, next_earnings_date, days_to_earnings, earnings_risk
Boundary
Reads the first calendar value and classifies dates at 7, 21 and 42 days. Missing or unexpected calendar data yields “unknown”; it does not predict an earnings result.
Test evidence
Calendar formats, thresholds and error paths are not covered by the inspected tests.
Read this implementation
05 / Company documents

Local filename lookup

Company documents

retrieve_company_docs

Supply company-specific document context without a model-generated search.

Input
ticker: string (required)
Returns
ticker, docs_found, result (combined document text)
Boundary
Strips the exchange suffix and matches the base ticker against local filenames. A missing store or no match returns zero documents. This is distinct from semantic vector retrieval.
Test evidence
No document-retrieval tests are present in the inspected suite. File reading has no enclosing exception handler.
Read this implementation
06 / Semantic knowledge

Vector retrieval · unresolved runtime

Semantic knowledge

search_company_knowledge

Search document chunks by an embedded natural-language query.

Input
query: string (required) · ticker: string (optional)
Returns
query, ticker, chunks_found, result (source-labelled context or a readiness message)
Boundary
The retriever targets a ChromaDB collection with an optional ticker filter and three results by default. The reviewed file references chromadb without importing it; required retrieval packages are also absent from requirements.txt.
Test evidence
An isolated dependency-stub check reproduced the missing-name readiness response. No real embedding model or vector query was run.
Read this implementation

CONTRACT SUMMARIES FROM SOURCE · NO LIVE EXECUTION · OUTPUTS ARE DICTIONARIES, NOT ENFORCED TOOL-RESPONSE MODELS

05 / DETERMINISTIC EDGES

Structure helps.
It isn’t certainty.

I put application code around model behaviour: request types, a tool registry, response shaping and visible error states. Those mechanisms have specific limits.

Input
Pydantic supplies request types; the API trims and uppercases the ticker. It does not validate ticker syntax or existence. The advice filter matches phrases, so it cannot establish comprehensive safety.
Output
The API extracts an n/10 score from model text and assigns a label. The optional integer is not range-constrained. A structured response does not guarantee a correct score.
Failure
Most market tools return error dictionaries; unknown tool names also return an error. Argument errors and model-call failures have no general loop-level recovery. The price endpoint’s zero fallback can obscure a failed fetch.

06 / TESTING INTELLIGENT SOFTWARE

What do the tests
actually tell us?

23collected tests
three source files
09

Financial guardrails

test_guardrails.py

Advice phrases, permitted risk questions, case handling and a non-empty refusal message.

A phrase filter, not a comprehensive safety evaluation.

07

Calculation examples

test_technicals.py

RSI direction and range, short history, Bollinger position type and example ranges.

Test-local helpers; no production tool or provider integration.

07

Evaluation definitions

test_evaluation.py

Required case fields, unique names and refusal/non-refusal classifications.

Checks case definitions, not live agent execution or model accuracy.

23/23 passed in an isolated, network-blocked review. GitHub Actions defines separate pytest runs for these three files. That configuration is source evidence; no remote CI outcome is claimed here.

The live evaluation runner is separate and can invoke the model. It was not run. The inspected tests do not exercise FastAPI, provider integrations, retrieval or a complete agent loop.

07 / LOOKING BACK

The next work is
at the boundaries.

EquityGuard demonstrates the work of connecting an interface, API, model and external tools. It also makes the next engineering questions concrete.

The README still describes older keyword retrieval, while newer source includes ChromaDB ingestion and vector search. A missing import and undeclared retrieval dependencies leave that runtime unresolved. The separate filename lookup should not be mistaken for semantic retrieval.

My next priorities would be production-code calculation tests, mocked provider failures, API and tool-contract checks, tighter score validation and an operational retrieval check. Those are proposed improvements, not completed features.

IMPLEMENTATION CONTEXT

React / FastAPI / Python / Claude API / yfinance / ChromaDB / Docker / GitHub Actions

ChromaDB describes the source retrieval path; a working deployment has not been verified.