Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI4Finance Foundation FinGPT get all prompts

From Leeroopedia
Knowledge Sources
Domains NLP, Prompt_Engineering, Finance
Last Updated 2026-10-18 00:00 GMT

Overview

Concrete tool for constructing training prompts from historical market data provided by the FinGPT Forecaster pipeline.

Description

The get_all_prompts function builds a list of training prompts from per-symbol CSV data. Each prompt combines: a company/crypto introduction, historical price movements (1-3 weeks lookback), sampled news headlines, optional basic financials, optional market sentiment, and a task instruction asking for positive developments, potential concerns, and a prediction. The prediction target is included in training prompts (teacher-forcing).

For inference, the related `get_all_prompts_online` function (in `app.py`) constructs a single live prompt without the prediction target.

Usage

Import this function when you need to construct prompts from historical data:

  • Training prompt construction: Building prompts for GPT-4 labeling and LoRA training.
  • Sliding window context: Creating prompts with configurable lookback windows.

Code Reference

Source Location

  • Repository: FinGPT
  • File: fingpt/FinGPT_Forecaster/prompt.py
  • Lines: L110-189 (get_all_prompts), L15-100 (helpers: get_company_prompt, get_prompt_by_row, map_bin_label)

Signature

def get_all_prompts(
    symbol: str,
    data_dir: str,
    start_date: str,
    end_date: str,
    min_past_weeks: int = 1,
    max_past_weeks: int = 3,
    with_basics: bool = True,
    with_market_sentiment: bool = False,
) -> list[str]

Import

from prompt import get_all_prompts

I/O Contract

Inputs

Name Type Required Description
symbol str Yes Ticker symbol
data_dir str Yes Directory containing per-symbol CSV files
start_date str Yes Start date YYYY-MM-DD
end_date str Yes End date YYYY-MM-DD
min_past_weeks int No Min lookback weeks (default 1)
max_past_weeks int No Max lookback weeks (default 3)
with_basics bool No Include basic financials (default True)
with_market_sentiment bool No Include market sentiment (default False)

Outputs

Name Type Description
return value list[str] List of constructed prompts (one per data row with sufficient history)

Usage Examples

Construct Training Prompts

from prompt import get_all_prompts

# Build prompts for AAPL with 2-week lookback
prompts = get_all_prompts(
    symbol="AAPL",
    data_dir="./data",
    start_date="2023-01-01",
    end_date="2023-12-31",
    min_past_weeks=1,
    max_past_weeks=3,
    with_basics=True,
)
print(f"Generated {len(prompts)} prompts")
print(prompts[0][:200])  # Preview first prompt

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment