Initial commit: 可转债轮动分析系统
- 实时行情:东财push2主源 + 腾讯批量报价备用源(自动切换) - 历史K线:东财push2his主源 + 腾讯web子域备用源(含熔断机制) - 增量同步:支持 -incr/-since 参数按存档日期增量入库 - 策略回测:净值曲线/10指标/基准对比,含基本面过滤 - 用户认证:用户名密码 + 邮箱验证码双登录方式 - 前端:三Tab SPA(实时行情/策略回测/数据管理)
This commit is contained in:
27
internal/storage/kline.go
Normal file
27
internal/storage/kline.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Package storage 定义持久化接口(MVC Model 层),与具体数据库实现解耦。
|
||||
// SQL 语句遵循通用标准语法(ANSI SQL),便于在 SQLite / PostgreSQL 之间迁移。
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"stock-analysis/internal/model"
|
||||
)
|
||||
|
||||
// KlineStore 日K线存储接口。
|
||||
type KlineStore interface {
|
||||
// SaveKlines 幂等批量写入指定标的的K线(已存在的记录跳过)。
|
||||
SaveKlines(ctx context.Context, code string, klines []model.Kline) error
|
||||
// GetKlines 按时间升序返回指定标的的全部K线。
|
||||
GetKlines(ctx context.Context, code string) ([]model.Kline, error)
|
||||
// CountKlines 返回指定标的的K线条数。
|
||||
CountKlines(ctx context.Context, code string) (int, error)
|
||||
// LastKlineDate 返回指定标的的最新K线日期(YYYY-MM-DD),无记录返回空串。
|
||||
LastKlineDate(ctx context.Context, code string) (string, error)
|
||||
// ListCodes 返回库中全部标的代码。
|
||||
ListCodes(ctx context.Context) ([]string, error)
|
||||
// LoadAllKlines 一次性加载全部标的的K线(map 键为标的代码)。
|
||||
LoadAllKlines(ctx context.Context) (map[string][]model.Kline, error)
|
||||
// Close 关闭存储。
|
||||
Close() error
|
||||
}
|
||||
Reference in New Issue
Block a user