Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Y-Research-SBU/QuantAgent/llms.txt

Use this file to discover all available pages before exploring further.

TechnicalTools is a class in graph_util.py that exposes all indicator computations and chart generation functions as LangChain @tool-decorated static methods. The agents call these tools directly by name during their execution loop.

kline_data format

All methods accept a kline_data argument. This must be a dictionary where each key maps to a list of numeric (or datetime string) values with the same length:
kline_data = {
    "Datetime": ["2024-01-01 09:00:00", "2024-01-01 09:15:00", ...],
    "Open":  [100.5, 101.2, ...],
    "High":  [102.0, 103.1, ...],
    "Low":   [99.8,  100.5, ...],
    "Close": [101.3, 102.4, ...],
}
Methods that only use closing prices (compute_rsi, compute_macd, compute_roc) require at minimum a Close key. Methods that compute range-based indicators (compute_stoch, compute_willr, generate_trend_image) also require High and Low.

Indicator tools

compute_rsi

TechnicalTools.compute_rsi(kline_data, period=14)
Computes the Relative Strength Index (RSI) using TA-Lib.
kline_data
dict
required
OHLCV dictionary. Only the Close key is used.
period
int
default:"14"
Lookback period for the RSI calculation.
Returns
rsi
List[float]
Last 28 RSI values, rounded to 2 decimal places. NaN values are filled with 0.

compute_macd

TechnicalTools.compute_macd(kline_data, fastperiod=12, slowperiod=26, signalperiod=9)
Computes the Moving Average Convergence Divergence (MACD) using TA-Lib.
kline_data
dict
required
OHLCV dictionary. Only the Close key is used.
fastperiod
int
default:"12"
Fast EMA period.
slowperiod
int
default:"26"
Slow EMA period.
signalperiod
int
default:"9"
Signal line EMA period.
Returns
macd
List[float]
Full MACD line series, rounded to 2 decimal places.
macd_signal
List[float]
Last 28 signal line values, rounded to 2 decimal places.
macd_hist
List[float]
Last 28 histogram values (MACD minus signal), rounded to 2 decimal places.

compute_stoch

TechnicalTools.compute_stoch(kline_data)
Computes the Stochastic Oscillator %K and %D using TA-Lib with fixed parameters: fastk_period=14, slowk_period=3, slowd_period=3.
kline_data
dict
required
OHLCV dictionary. Uses High, Low, and Close keys.
Returns
stoch_k
List[float]
Last 28 slow %K values, rounded to 2 decimal places.
stoch_d
List[float]
Last 28 slow %D values, rounded to 2 decimal places.

compute_roc

TechnicalTools.compute_roc(kline_data, period=10)
Computes the Rate of Change (ROC) indicator using TA-Lib.
kline_data
dict
required
OHLCV dictionary. Only the Close key is used.
period
int
default:"10"
Number of periods over which to calculate ROC.
Returns
roc
List[float]
Last 28 ROC values, rounded to 2 decimal places.

compute_willr

TechnicalTools.compute_willr(kline_data, period=14)
Computes the Williams %R indicator using TA-Lib.
kline_data
dict
required
OHLCV dictionary. Uses High, Low, and Close keys.
period
int
default:"14"
Lookback period for the Williams %R calculation.
Returns
willr
List[float]
Last 28 Williams %R values, rounded to 2 decimal places. Values range from −100 to 0.

Chart generation tools

generate_kline_image

TechnicalTools.generate_kline_image(kline_data)
Generates a candlestick (K-line) chart from the most recent 40 candles in kline_data. Saves the chart locally as kline_chart.png and returns it as a base64-encoded PNG string.
kline_data
dict
required
OHLCV dictionary with keys Datetime, Open, High, Low, and Close.
Returns
pattern_image
str
Base64-encoded PNG string of the candlestick chart. Pass this directly as a data:image/png;base64,... URL to a vision LLM.
pattern_image_description
str
Fixed description string: "Candlestick chart saved locally and returned as base64 string.".

generate_trend_image

TechnicalTools.generate_trend_image(kline_data)
Generates a candlestick chart of the most recent 50 candles overlaid with four fitted trendlines: close-based support (blue) and resistance (red), plus high/low-based support and resistance (white). Saves the chart as trend_graph.png and returns it as a base64-encoded PNG.
kline_data
dict
required
OHLCV dictionary with keys Datetime, Open, High, Low, and Close.
Returns
trend_image
str
Base64-encoded PNG string of the trendline-annotated candlestick chart.
trend_image_description
str
Fixed description string: "Trend-enhanced candlestick chart with support/resistance lines.".

Usage example

You can call the tools directly outside of an agent for testing or preprocessing:
import pandas as pd
import json
from graph_util import TechnicalTools

# Load your OHLCV data
df = pd.read_csv("btc_15min.csv")
kline_data = df[["Datetime", "Open", "High", "Low", "Close"]].to_dict(orient="list")

# Compute RSI
rsi_result = TechnicalTools.compute_rsi.invoke({"kline_data": kline_data})
print(rsi_result["rsi"])  # last 28 RSI values

# Compute MACD
macd_result = TechnicalTools.compute_macd.invoke({"kline_data": kline_data})
print(macd_result["macd_hist"])  # last 28 histogram values

# Generate a kline chart
chart_result = TechnicalTools.generate_kline_image.invoke({"kline_data": kline_data})
# Write to disk for inspection
import base64
with open("preview.png", "wb") as f:
    f.write(base64.b64decode(chart_result["pattern_image"]))
Because these methods are decorated with @tool, you must call them via .invoke(args_dict) rather than calling them directly as regular functions.