Skip to content

Latest commit

 

History

History
361 lines (298 loc) · 12 KB

File metadata and controls

361 lines (298 loc) · 12 KB

Kronos-Report-Java

AI Quantitative Prediction Report Generation Tool Based on Kronos Financial Large Model (Java Edition)

License: AGPL v3 Java

📖 Introduction

Kronos-Report-Java is a Java quantitative prediction tool based on the Kronos financial time-series large model, supporting stocks, funds, futures, indices and other instruments. It automatically generates multi-format analysis reports and daily briefings, and supports multiple inference backends (HTTP, ONNX Runtime, DJL).

✨ Features

Prediction & Reporting

  • ✅ Automatic instrument type identification (stock/fund/futures/index)
  • ✅ Automatic exchange detection
  • ✅ Automatic filtering of futures index contracts (codes ending with 00, e.g., RB00, M00)
  • ✅ Multiple model combinations (2k/base tokenizer + mini/small/base model)
  • ✅ Forward/backward adjustment support
  • ✅ Multi-format report output (TXT, HTML, PNG, PDF, CSV, charts, JSON)
  • ✅ Rolling backtest validation (direction accuracy, MAPE)
  • ✅ Quick backtest (validate model with recent N trading days)
  • ✅ Backtest CSV export (record predicted vs actual OHLCV data)
  • ✅ Retail-friendly report format

Daily Briefing

  • ✅ Daily briefing generation (watchlist + hot stocks ranking)
  • ✅ Watchlist priority display (watchlist items shown before hot stocks)
  • ✅ Global model reuse (single instance, improved performance)
  • ✅ Scheduled tasks (automatic daily briefing generation)
  • ✅ WeChat public account promotion (QR code, subscription info, like/share buttons)

Model Inference

  • ✅ Multi-model management (up to 3 models concurrently)
  • ✅ Parameterized prediction (support lookback, pred_len, t, top_p, sample_count)
  • ✅ Hot model switching (switch models without restarting service)
  • ✅ Three inference backends: HTTP, ONNX Runtime, DJL
  • ✅ Auto device selection (default auto, no manual specification needed)

Data Service

  • ✅ Unified data service interface (support local files and HTTP gateway)
  • ✅ Data source auto-switching (configure DATA_SOURCE to switch)
  • ✅ Name mapping (stock, fund, futures, index names)
  • ✅ Last trading day data (hot rankings, query by code)
  • ✅ Forward adjustment calculation (based on dividend JSON files)
  • ✅ Trading calendar (holidays, trading day judgment)
  • ✅ Futures code case auto-correction

📦 Requirements

  • JDK 17+
  • Maven 3.6+

🔧 Build & Install

# Clone repository
git clone https://gitee.com/liebin/kronos-report.git
cd kronos-report

# Build
mvn clean package

# Install to local repository
mvn install

🚀 Usage

Single Prediction (Full Report)

# Stock
java -jar target/kronos-report-1.0.0.jar --code 000001

# Futures (automatically excludes index contracts)
java -jar target/kronos-report-1.0.0.jar --code RB2505

# Index
java -jar target/kronos-report-1.0.0.jar --code zs_000001

# Custom parameters
java -jar target/kronos-report-1.0.0.jar --code 000001 --lookback 256 --pred-len 10 --model small

# No forward adjustment
java -jar target/kronos-report-1.0.0.jar --code 000001 --no-adjusted

JSON Data Report (Pure Data Format)

# Generate JSON report (no charts or backtest)
java -jar target/kronos-report-1.0.0.jar --code 000001 --json

# Print JSON to console only, don't save file
java -jar target/kronos-report-1.0.0.jar --code 000001 --json --no-save

# With custom parameters
java -jar target/kronos-report-1.0.0.jar --code 000001 --json --lookback 256 --pred-len 10 --verbose

# JSON report without forward adjustment
java -jar target/kronos-report-1.0.0.jar --code 000001 --json --no-adjusted

Daily Briefing

# Generate briefing (quiet mode)
java -jar target/kronos-report-1.0.0.jar --briefing

# Generate briefing (verbose mode)
java -jar target/kronos-report-1.0.0.jar --briefing -v

Scheduled Task

# Start scheduler (daily at 19:30)
java -jar target/kronos-report-1.0.0.jar --scheduler

# Custom time
java -jar target/kronos-report-1.0.0.jar --scheduler --scheduler-hour 20 --scheduler-minute 0

# Stop scheduler
java -jar target/kronos-report-1.0.0.jar --scheduler-stop

📁 Project Structure

kronos-report/
├── pom.xml
├── README.md
├── README.en.md
├── LICENSE
└── src/main/java/cn/tsquant/invest/util/kronos/
    ├── KronosPredictor.java              # Main entry
    ├── config/                           # Configuration module
    │   └── KronosConfig.java
    ├── core/                             # Model inference core
    │   ├── ModelPredictor.java
    │   ├── ModelPredictorFactory.java
    │   ├── HttpModelPredictor.java
    │   ├── OnnxModelPredictor.java
    │   ├── DjlModelPredictor.java
    │   ├── PredictorWrapper.java
    │   ├── ModelConfig.java
    │   ├── ModelManager.java
    │   ├── ModelInstance.java
    │   ├── PredictRequest.java
    │   └── PredictResponse.java
    ├── data/                             # Data service module
    │   ├── DataService.java
    │   ├── DataServiceFactory.java
    │   ├── bo/                           # Business objects
    │   │   ├── AssetInfo.java
    │   │   ├── EquityItem.java
    │   │   ├── FuturesInfo.java
    │   │   ├── FuturesParsed.java
    │   │   ├── KLine.java
    │   │   └── TradeDates.java
    │   ├── gateway/                      # HTTP gateway implementation
    │   │   └── GatewayDataService.java
    │   └── local/                        # Local file implementation
    │       ├── LocalDataService.java
    │       ├── LastDayDataLoader.java
    │       ├── Mappings.java
    │       └── ForwardAdjusted.java
    ├── report/                           # Report generation module
    │   ├── Backtest.java
    │   ├── ChartGenerator.java
    │   ├── TxtReport.java
    │   ├── HtmlReport.java
    │   ├── ImageReport.java
    │   └── JsonReport.java
    ├── briefing/                         # Daily briefing module
    │   ├── BriefingConfig.java
    │   ├── BriefingGenerator.java
    │   ├── HtmlBriefing.java
    │   └── TxtBriefing.java
    └── utils/                            # Utilities
        ├── TradeDateUtils.java
        ├── TradeCalendar.java
        ├── CodeUtils.java
        ├── CsvLoader.java
        ├── AdjustedUtils.java
        ├── FileUtils.java
        └── TypeUtils.java

📝 Command Line Parameters

Parameter Default Description
--code, -c Required Instrument code
--start-date, -s None Start date YYYYMMDD
--end-date, -e None End date YYYYMMDD
--pred-len, -p 5 Prediction steps
--lookback, -l 512 Lookback window
--t 0.6 Temperature parameter
--top-p 0.8 Top-p sampling parameter
--sample-count 5 Sample count
--tokenizer 2k Tokenizer type
--model, -m mini Model type
--device, -d auto Device type
--no-save false Don't save files
--adjusted true Forward adjustment (enabled by default)
--no-adjusted false No forward adjustment
--json false Generate JSON data report
--briefing false Generate daily briefing
--verbose, -v false Verbose output
--scheduler false Start scheduler
--scheduler-stop false Stop scheduler

📂 Output Directory Structure

/home/liebin/dev/data/report/
├── AI预测/                           # Prediction reports
│   └── {date}/{name}/{tokenizer}_{model}_{lookback}/
│       ├── AI预测报告_{name}_{date}.html
│       ├── AI预测报告_{name}_{date}.txt
│       ├── AI预测报告_{name}_{date}.png
│       ├── AI预测报告_{name}_{date}.pdf
│       ├── AI预测报告_{name}_{date}.json
│       ├── {name}_chart_{date}.png
│       ├── {name}_trend_{date}.png
│       ├── {name}_backtest_{date}.png
│       ├── {name}_backtest_data_{date}.csv
│       └── {name}_predictions_{date}.csv
└── AI简报/                           # Daily briefings
    └── {date}/
        ├── AI量化简报_{date}.html
        ├── AI量化简报_{date}.txt
        └── AI量化简报_{date}.png

📊 JSON Report Format

{
  "code": "000001",
  "name": "Ping An Bank",
  "timestamp": "2026-06-11T15:30:00",
  "last_trade_date": "2026-06-10",
  "model": "2k_mini",
  "lookback": 512,
  "pred_len": 5,
  "adjusted": true,
  "summary": {
    "current_price": 11.20,
    "predicted_price": 11.35,
    "change_pct": 1.34,
    "trend": "Bullish 📈",
    "low": 11.10,
    "high": 11.50
  },
  "recent": [
    {
      "d": "2026-06-04",
      "o": 11.05,
      "h": 11.15,
      "l": 11.00,
      "c": 11.10,
      "v": 1000000,
      "a": 11100000
    }
  ],
  "predicted": [
    {
      "d": "2026-06-11",
      "o": 11.22,
      "h": 11.38,
      "l": 11.15,
      "c": 11.30,
      "v": 1020000,
      "a": 11500000
    }
  ]
}

Field Description

Field Type Description
code string Instrument code
name string Instrument name
timestamp string Report generation time
last_trade_date string Last trading date
model string Model identifier used
lookback int Lookback window length
pred_len int Prediction steps
adjusted boolean Whether forward adjustment is applied
summary object Prediction summary
recent array Last 30 trading days K-lines
predicted array Next N trading days predicted K-lines

K-line Field Abbreviation Mapping

Abbr Full Name Description
d date Date
o open Open price
h high High price
l low Low price
c close Close price
v volume Volume
a amount Amount

🔌 Inference Backends

Backend Description Priority
HTTP Remote Python model service 1
ONNX Runtime Local ONNX model inference 2
DJL Local PyTorch model inference 3

⚙️ Configuration

Edit KronosConfig.java to modify settings:

// Data source configuration
public static final String DATA_SOURCE = "local";  // local / http

// Model inference configuration
public static final boolean USE_HTTP_FIRST = true;
public static final String MODEL_HTTP_HOST = "http://localhost";
public static final int MODEL_HTTP_PORT = 16888;

// Model management
public static final int MAX_MODELS = 3;

// Default model
public static final String DEFAULT_TOKENIZER = "2k";
public static final String DEFAULT_MODEL = "mini";

📄 License

This project is licensed under the AGPL-3.0 License.

💬 Technical Support & Services

If you encounter any issues or need technical services, feel free to contact the author:

  • 🤖 AI Customer Service Development: Intelligent Q&A, auto-reply, multi-channel integration
  • 🧠 LLM Application Development: Model fine-tuning, Prompt engineering, RAG systems
  • 💻 Software Development: Java&Python backend, quantitative systems, data processing
  • 📈 Quantitative Strategy Development: Factor mining, backtesting systems, live trading integration
  • 🔧 Custom Development: Tailored AI quantitative solutions

Author WeChat QR Code

Scan WeChat to add the author, please state your purpose

⚠️ Disclaimer

Prediction results are generated by AI models and are for reference only. They do not constitute investment advice.