data

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 2 Imported by: 0

README

data

量化交易必备的数据集合

1. 概要

2. 第一次使用, 获取日K线

第一次运行时, 连接池会探测服务器网络速度会慢一些, 网络测速后会缓存到本地。

package main

import (
	"fmt"
	"github.com/quant1x/data/level1"
	"github.com/quant1x/data/level1/proto"
)

func main() {
	api := level1.GetApi()
	klines, err := api.GetKLine("sh600600", proto.KLINE_TYPE_RI_K, 0, 1)
	fmt.Println(err)
	fmt.Println(klines)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	Kline map[string]bool `yaml:"kline"` // K线配置
	Chips ChipsConfig     `yaml:"chips"` // 筹码配置
}

CacheConfig 缓存配置

type ChipsConfig

type ChipsConfig struct {
	IndexEnabled bool `yaml:"index_enabled"` // 是否启用指数筹码
}

ChipsConfig 筹码配置

type Config

type Config struct {
	BaseDir string  `yaml:"basedir"` // 数据根目录
	Debug   bool    `yaml:"debug"`   // 是否调试模式运行
	Trader  Trader  `yaml:"trader"`  // 交易配置
	Runtime Runtime `yaml:"runtime"` // 运行时配置
	Data    Data    `yaml:"data"`    // 数据配置
}

Config 配置结构体

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 默认配置

func ParseConfig

func ParseConfig(filename string) (*Config, error)

type CrontabItem

type CrontabItem struct {
	Enable  bool   `yaml:"enable"`            // 是否启用
	Trigger string `yaml:"trigger,omitempty"` // 触发器表达式
}

CrontabItem 定时任务

type Data

type Data struct {
	Concurrency map[string]int `yaml:"concurrency"` // 并发控制
	Cache       CacheConfig    `yaml:"cache"`       // 缓存配置
	Trans       TransConfig    `yaml:"trans"`       // 成交数据配置
	Feature     FeatureConfig  `yaml:"feature"`     // 特征配置
	Snapshot    SnapshotConfig `yaml:"snapshot"`    // 快照配置
}

Data 数据配置

type FeatureConfig

type FeatureConfig struct {
	Tendency int        `yaml:"tendency"` // 策略是趋势主导还是股价主导
	Wave     WaveConfig `yaml:"wave"`     // 波浪配置
}

FeatureConfig 特征配置

type Rules

type Rules struct {
	SectorsFilter     bool   `yaml:"sectors_filter"`                // 是否启用板块过滤
	SectorsTopN       int    `yaml:"sectors_top_n"`                 // 板块数量
	StockTopNInSector int    `yaml:"stock_top_n_in_sector"`         // 每个板块选股数量
	GapDown           bool   `yaml:"gap_down"`                      // 是否跳空低开
	IgnoreRuleGroup   []int  `yaml:"ignore_rule_group"`             // 忽略规则组
	Capital           string `yaml:"capital"`                       // 资金流入
	Price             string `yaml:"price"`                         // 价格
	OpenTurnZ         string `yaml:"open_turn_z,omitempty"`         // 开盘换手率Z值
	OpenChangeRate    string `yaml:"open_change_rate,omitempty"`    // 开盘涨跌幅
	OpenQuantityRatio string `yaml:"open_quantity_ratio,omitempty"` // 开盘量比
	VolumeRatio       string `yaml:"volume_ratio,omitempty"`        // 量比
	CheckSafetyScore  bool   `yaml:"check_safety_score"`            // 是否检查安全评分
	ChangeRate        string `yaml:"change_rate,omitempty"`         // 涨跌幅
	SafetyScore       string `yaml:"safety_score,omitempty"`        // 安全评分
}

Rules 选股规则

type Runtime

type Runtime struct {
	Crontab map[string]CrontabItem `yaml:"crontab"` // 定时任务
}

Runtime 运行时配置

type SnapshotConfig

type SnapshotConfig struct {
	Concurrency int `yaml:"concurrency"` // 快照-并发数
}

SnapshotConfig 快照配置

type Strategy

type Strategy struct {
	Id                          int64    `yaml:"id"`                             // 策略ID
	Name                        string   `yaml:"name"`                           // 策略名称
	Auto                        bool     `yaml:"auto"`                           // 是否自动交易
	Flag                        string   `yaml:"flag"`                           // 策略标识
	Time                        string   `yaml:"time"`                           // 策略运行时间
	Weight                      float64  `yaml:"weight"`                         // 策略权重
	Total                       int      `yaml:"total"`                          // 策略总仓位数
	PriceCageRatio              float64  `yaml:"price_cage_ratio"`               // 价格笼比例
	MinimumPriceFluctuationUnit float64  `yaml:"minimum_price_fluctuation_unit"` // 最小价格变动单位
	FeeMax                      float64  `yaml:"fee_max"`                        // 手续费封顶
	FeeMin                      float64  `yaml:"fee_min"`                        // 手续费最低
	Sectors                     []string `yaml:"sectors"`                        // 选股板块
	IgnoreMarginTrading         bool     `yaml:"ignore_margin_trading"`          // 忽略两融标的
	HoldingPeriod               int      `yaml:"holding_period"`                 // 持有周期(交易日)
	SellStrategy                int64    `yaml:"sell_strategy"`                  // 卖出策略
	Rules                       Rules    `yaml:"rules"`                          // 选股规则
	TakeProfitRatio             float64  `yaml:"take_profit_ratio,omitempty"`    // 止盈比例
	StopLossRatio               float64  `yaml:"stop_loss_ratio,omitempty"`      // 止损比例
}

Strategy 策略配置

type Trader

type Trader struct {
	AccountId            int64      `yaml:"account_id"`               // 账户ID
	ProxyUrl             string     `yaml:"proxy_url"`                // 代理地址
	OrderPath            string     `yaml:"order_path"`               // 委托单保存路径
	StampDutyRateForBuy  float64    `yaml:"stamp_duty_rate_for_buy"`  // 买入印花税率
	StampDutyRateForSell float64    `yaml:"stamp_duty_rate_for_sell"` // 卖出印花税率
	TransferRate         float64    `yaml:"transfer_rate"`            // 过户费
	CommissionRate       float64    `yaml:"commission_rate"`          // 佣金率
	CommissionMin        float64    `yaml:"commission_min"`           // 佣金最低
	PositionRatio        float64    `yaml:"position_ratio"`           // 买入总占比
	KeepCash             float64    `yaml:"keep_cash"`                // 预留备用金
	BuyAmountMax         float64    `yaml:"buy_amount_max"`           // 最大可买金额
	BuyAmountMin         float64    `yaml:"buy_amount_min"`           // 最小可买金额
	Strategies           []Strategy `yaml:"strategies"`               // 策略列表
	AskTime              string     `yaml:"ask_time"`                 // 卖出时段
	TickTime             string     `yaml:"tick_time"`                // 盘中买入时段
}

Trader 交易配置

type TransConfig

type TransConfig struct {
	BeginDate string `yaml:"begin_date"` // 开始日期
}

TransConfig 成交数据配置

type WaveConfig

type WaveConfig struct {
	Fields  WaveFields `yaml:"fields"`  // 波浪-字段
	Periods int        `yaml:"periods"` // 波浪-K线周期
}

WaveConfig 波浪配置

type WaveFields

type WaveFields struct {
	Peak   string `yaml:"peak"`   // 波浪-字段-波峰
	Valley string `yaml:"valley"` // 波浪-字段-波谷
}

WaveFields 波浪-字段

Directories

Path Synopsis
Package trading 包含交易中的日历和时段相关的功能函数
Package trading 包含交易中的日历和时段相关的功能函数
proto/ext
扩展协议包的定义
扩展协议包的定义
proto/std
标准协议包的定义
标准协议包的定义

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL