Files
stock-analysis/cmd/dbstats/main.go
WarrenZhou e28bfec957 Initial commit: 可转债轮动分析系统
- 实时行情:东财push2主源 + 腾讯批量报价备用源(自动切换)
- 历史K线:东财push2his主源 + 腾讯web子域备用源(含熔断机制)
- 增量同步:支持 -incr/-since 参数按存档日期增量入库
- 策略回测:净值曲线/10指标/基准对比,含基本面过滤
- 用户认证:用户名密码 + 邮箱验证码双登录方式
- 前端:三Tab SPA(实时行情/策略回测/数据管理)
2026-08-17 20:23:22 +08:00

42 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// dbstats 输出 SQLite 库的转债数与K线总数统计。
//
// go run ./cmd/dbstats [-db 库路径]
package main
import (
"context"
"database/sql"
"flag"
"fmt"
"os"
_ "modernc.org/sqlite"
)
func main() {
dbPath := flag.String("db", "C:\\Users\\zhouww\\AppData\\Local\\Temp\\stock-analysis-data\\stock.db", "SQLite 数据库文件路径")
flag.Parse()
db, err := sql.Open("sqlite", *dbPath)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer db.Close()
db.SetMaxOpenConns(1)
ctx := context.Background()
var bonds, rows int
if err := db.QueryRowContext(ctx, "SELECT COUNT(DISTINCT code), COUNT(*) FROM convertible_kline").Scan(&bonds, &rows); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("转债数: %d,K线总数: %d(库: %s)\n", bonds, rows, *dbPath)
// 数据范围抽查。
var minDate, maxDate string
if err := db.QueryRowContext(ctx, "SELECT MIN(date), MAX(date) FROM convertible_kline").Scan(&minDate, &maxDate); err == nil {
fmt.Printf("K线日期范围: %s ~ %s\n", minDate, maxDate)
}
}