eastmoney

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

东方财富

k 线历史

get_quote_history_single 最多支持同时查询 50 个

数据 key 与含义

EASTMONEY_KLINE_FIELDS = {
    'f51': '日期',
    'f52': '开盘',
    'f53': '收盘',
    'f54': '最高',
    'f55': '最低',
    'f56': '成交量',
    'f57': '成交额',
    'f58': '振幅',
    'f59': '涨跌幅',
    'f60': '涨跌额',
    'f61': '换手率',
}

返回数据结构

{
  "rc": 0,
  "rt": 17,
  "svr": 177617936,
  "lt": 1,
  "full": 0,
  "dlmkts": "",
  "data": {
    "code": "600036",
    "market": 1,
    "name": "招商银行",
    "decimal": 2,
    "dktotal": 5446,
    "preKPrice": 39.4,
    "prePrice": 39.48,
    "qtMiscType": 7,
    "version": 0,
    "klines": [
      "2024-12-26,39.40,39.48,39.54,39.01,539252,2125139425.00,1.35,0.20,0.08,0.26",
      "2024-12-27,39.48,39.34,39.64,38.78,700320,2742768758.00,2.18,-0.35,-0.14,0.34"
    ]
  }
}

股票基本信息接口

curl --location 'http://80.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=50000&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m%3A1%20t%3A2%2Cm%3A1%20t%3A23&fields=f11%2Cf12%2Cf13%2Cf14%2Cf15%2Cf16%2Cf19%2Cf20%2Cf21%2Cf22%2Cf23%2Cf24%2Cf25%2Cf26%2Cf30%2Cf32%2Cf33%2Cf34%2Cf35%2Cf36%2Cf37%2Cf38%2Cf39%2Cf40&_=1623833739532'

f2: 当前价格/收盘价 f3: 涨幅 0.91% f4: 涨跌额 0.25 f5: 成交量 f6: 成交额 f7: 振幅 1.85% f8: 换手率 0.30% f9: 动态市盈率 f10: 量比

f12: 证券代码 f13: 猜测-交易所 1 上海 f14: 证券名称 f15: high f16: low f17: open f18: yclose

f20: 总市值 f21: 流通市值 f23: 市净率

f31: 猜测-收盘价 f33: 猜测-委比 f34: 外盘 f35: 内盘 f37: 净资产收益率 f38: 总股本 f39: 流通股本 f40: 总营收 f41: 总营收同比

[
  {
    "f1": 2,
    "f2": 27.76,
    "f3": 0.91,
    "f4": 0.25,
    "f5": 611259,
    "f6": 1697947805.0,
    "f7": 1.85,
    "f8": 0.3,
    "f9": 4.61,
    "f10": 0.95,
    "f11": 0.04,
    "f12": "600036",
    "f13": 1,
    "f14": "招商银行",
    "f15": 27.96,
    "f16": 27.45,
    "f17": 27.56,
    "f18": 27.51,
    "f19": 2,
    "f20": 700102913884,
    "f21": 572659497349,
    "f22": 0.11,
    "f23": 0.79,
    "f24": -16.16,
    "f25": -21.85,
    "f26": 20020409,
    "f27": 1,
    "f28": "-",
    "f29": 1,
    "f30": -5485,
    "f31": 27.76,
    "f32": 27.77,
    "f33": 73.88,
    "f34": 297883,
    "f35": 313376,
    "f36": 36539.60300161,
    "f37": 13.035,
    "f38": 25219845601.0,
    "f39": 20628944429.0,
    "f40": 260279000000.0,
    "f41": -1.7195742222,
    "f42": 135233000000.0,
    "f43": 17410000000.0,
    "f44": 135185000000.0,
    "f45": 113890000000.0,
    "f46": 6.516900170218,
    "f47": 560687000000.0,
    "f48": 22.231975915736,
    "f49": 0.0,
    "f50": 10668009000000.0,
    "f51": 0.0,
    "f52": 107240000000.0,
    "f53": 7251000000.0,
    "f54": 9646670000000.0,
    "f55": 0.0,
    "f56": 0.0,
    "f57": 90.426151684,
    "f58": 1012235000000.0,
    "f59": 9.4885090554,
    "f60": 65435000000.0,
    "f61": 2.594583687594,
    "f62": 11028291.0,
    "f63": 27722064.0,
    "f64": 291811648.0,
    "f65": 238500925.0
  },
  {
    "f1": 2,
    "f2": 6.68,
    "f3": 0.91,
    "f4": 0.06,
    "f5": 55452,
    "f6": 36968387.0,
    "f7": 1.96,
    "f8": 0.83,
    "f9": 28.35,
    "f10": 0.96,
    "f11": 0.15,
    "f12": "600616",
    "f13": 1,
    "f14": "金枫酒业",
    "f15": 6.71,
    "f16": 6.58,
    "f17": 6.6,
    "f18": 6.62,
    "f19": 2,
    "f20": 4468953066,
    "f21": 4468953066,
    "f22": 0.15,
    "f23": 2.23,
    "f24": -2.2,
    "f25": -3.61,
    "f26": 19920929,
    "f27": 1,
    "f28": "-",
    "f29": 1,
    "f30": -93,
    "f31": 6.67,
    "f32": 6.68,
    "f33": -46.4,
    "f34": 28095,
    "f35": 27357,
    "f36": 10918.25162385,
    "f37": 6.03,
    "f38": 669004950.0,
    "f39": 669004950.0,
    "f40": 360425650.03,
    "f41": -13.4496583759,
    "f42": 157075358.01,
    "f43": 9364416.68,
    "f44": 156677796.81,
    "f45": 118233476.32,
    "f46": 794.897064509033,
    "f47": 892826173.62,
    "f48": 1.334558396945,
    "f49": 40.5918996991,
    "f50": 2282230780.13,
    "f51": 1673281451.13,
    "f52": 423835137.37,
    "f53": 78463731.63,
    "f54": 290907915.09,
    "f55": 223120248.59,
    "f56": 67787666.5,
    "f57": 12.7466476056,
    "f58": 2007261707.3,
    "f59": 87.9517411112,
    "f60": 375551751.38
  }
]

Documentation

Index

Constants

View Source
const (
	EastMoney80Push2ApiBase  = "http://80.push2.eastmoney.com"
	EastMoneyPush2ApiBase    = "http://push2.eastmoney.com"
	EastMoneyPush2HisApiBase = "https://push2his.eastmoney.com"
	QuoteFQTDefault          = 0 // 不复权
	QuoteFQTFront            = 1 // 前复权
	QuoteFQTPost             = 2 // 后复权
)
View Source
const (
	EfinanceStockQuoteURL = "http://push2his.eastmoney.com/api/qt/stock/kline/get"
	// 东方财富 kline 返回数据按逗号拆分后的长度 "2023-11-14,29.87,30.20,30.20,29.86,448343,1347710790.00,1.14,1.27,0.38,0.22"
	EfinanceKlineLen      = 11
	EfinancePeriodDaily   = "daily"
	EfinancePeriodWeekly  = "weekly"
	EfinancePeriodMonthly = "monthly"
	EfinanceAdjustQfq     = "qfq" // 前复权
	EfinanceAdjustHfq     = "hfq" // 后复权
	EfinanceAdjustNone    = ""    // 不复权
)

Variables

View Source
var (
	EfinancePeriodMap = map[string]string{
		"daily":   "101",
		"weekly":  "102",
		"monthly": "103",
	}
	EfinanceAdjustMap = map[string]string{
		"qfq": "1",
		"hfq": "2",
		"":    "0",
	}
)
View Source
var ErrInvalidKLine = errors.New("invalid kline data")
View Source
var ErrSkipValue = errors.New("skip value")

Functions

This section is empty.

Types

type CurrentStockInfoData

type CurrentStockInfoData struct {
	Total int                      `json:"total"`
	Diff  []map[string]interface{} `json:"diff"`
}

type CurrentStockInfoDiff

type CurrentStockInfoDiff struct {
	F2   float64 `json:"f2"`   // 最新价格
	F3   float64 `json:"f3"`   // 涨跌幅
	F4   float64 `json:"f4"`   // 涨跌额
	F5   float64 `json:"f5"`   // 成交量
	F6   float64 `json:"f6"`   // 成交额
	F7   float64 `json:"f7"`   // 振幅
	F8   float64 `json:"f8"`   // 换手率
	F9   float64 `json:"f9"`   // 动态市盈率
	F10  float64 `json:"f10"`  // 量比
	F12  string  `json:"f12"`  // 证券代码
	F13  int     `json:"f13"`  // 市场编号 0深证 1上证
	F14  string  `json:"f14"`  // 证券名称
	F15  float64 `json:"f15"`  // high
	F16  float64 `json:"f16"`  // low
	F17  float64 `json:"f17"`  // open
	F18  float64 `json:"f18"`  // yclose
	F20  float64 `json:"f20"`  // 总市值 "-" 表示非股票
	F21  float64 `json:"f21"`  // 流通市值 "-" 表示非股票
	F23  float64 `json:"f23"`  // 市净率
	F37  float64 `json:"f37"`  // 净资产收益率
	F38  float64 `json:"f38"`  // 总股本
	F39  float64 `json:"f39"`  // 流通股本
	F124 int64   `json:"f124"` // 更新时间戳
	F297 int64   `json:"f297"` // 最新交易日 20241227
}

func ParseCurrentStockInfoDiff

func ParseCurrentStockInfoDiff(in map[string]interface{}) (out *CurrentStockInfoDiff, err error)

ParseCurrentStockInfoDiff 解析返回结果

type CurrentStockInfoResp

type CurrentStockInfoResp struct {
	Rc     int                   `json:"rc"`
	Rt     int                   `json:"rt"`
	Svr    int64                 `json:"svr"`
	Lt     int                   `json:"lt"`
	Full   int                   `json:"full"`
	Dlmkts string                `json:"dlmkts"`
	Data   *CurrentStockInfoData `json:"data"`
}

func GetCurrentStockInfo

func GetCurrentStockInfo() (resp *CurrentStockInfoResp, err error)

获取当前所有股票信息

func GetRealtimeQuotes

func GetRealtimeQuotes() (resp *CurrentStockInfoResp, err error)

获取当前所有股票信息

type EfinanceStockItem

type EfinanceStockItem struct {
	Code       string   `json:"code"`
	Market     int      `json:"market"`
	Name       string   `json:"name"`
	Decimal    int      `json:"decimal"`
	Dktotal    int      `json:"dktotal"`
	PreKPrice  float64  `json:"preKPrice"`
	PrePrice   float64  `json:"prePrice"`
	QtMiscType int      `json:"qtMiscType"`
	Klines     []string `json:"klines"`
}

type EfinanceStockResp

type EfinanceStockResp struct {
	Rc     int                `json:"rc"`
	Rt     int                `json:"rt"`
	Svr    int                `json:"svr"`
	Lt     int                `json:"lt"`
	Full   int                `json:"full"`
	Dlmkts string             `json:"dlmkts"`
	Data   *EfinanceStockItem `json:"data"`
}

type GetQuoteHistoryReq

type GetQuoteHistoryReq struct {
	Code       string
	MarketCode int    // 市场 0 深证, 1 上证
	FQT        int    // 复权类型 0不复权 1前复权 2后复权,默认不复权
	Begin      string // 开始时间 19000101 格式
	End        string // 结束时间 20500101 格式
}

type KLineQuote

type KLineQuote struct {
	Date       time.Time
	Open       float64
	Close      float64
	High       float64
	Low        float64
	Volume     int64   // 成交量
	TurnOver   float64 // 成交额
	Amplitude  float64 // 振幅
	ChangeRate float64 // 涨跌幅
	Change     float64 // 涨跌额
	Velocity   float64 // TurnOver Rate 换手率
}

KLineQuote K 线结构体

func ParseKlineItem

func ParseKlineItem(line string) (kline KLineQuote, err error)

ParseKlineItem 解析单条 k 线数据 "2024-12-26,39.40,39.48,39.54,39.01,539252,2125139425.00,1.35,0.20,0.08,0.26"

type MarketType

type MarketType int

MarketType 交易所类型

const (
	MarketTypeSzSe MarketType = 0 // 深圳证券交易所
	MarketTypeSse  MarketType = 1 // 上海证券交易所
)

type Quote

type Quote struct {
	Date       time.Time `json:"date"`        // 交易日期
	Code       string    `json:"code"`        // 证券代码
	Name       string    `json:"name"`        // 证券名称
	Market     int       `json:"market"`      // 证券市场
	Open       float64   `json:"open"`        // 开盘价
	Close      float64   `json:"close"`       // 收盘价
	High       float64   `json:"high"`        // 最高价
	Low        float64   `json:"low"`         // 最低价
	Volume     int64     `json:"volume"`      // 成交量
	TurnOver   float64   `json:"turn_over"`   // 成交额
	Amplitude  float64   `json:"amplitude"`   // 振幅
	ChangeRate float64   `json:"change_rate"` // 涨跌幅
	Change     float64   `json:"change"`      // 涨跌额
	Velocity   float64   `json:"velocity"`    // TurnOver Rate 换手率
	Fqt        int       `json:"fqt"`         // 复权类型
}

Quote 基本行情

func ParseQuoteHistoryResp

func ParseQuoteHistoryResp(resp *QuoteHistoryResp) ([]*Quote, error)

ParseQuoteHistoryResp 解析数据结构到标准结构体

type QuoteHistoryData

type QuoteHistoryData struct {
	Code       string   `json:"code"`
	Market     int      `json:"market"`
	Name       string   `json:"name"`
	Decimal    int      `json:"decimal"` // 小数点精确度
	Dktotal    int      `json:"dktotal"` // 总数据条数
	PreKPrice  float64  `json:"preKPrice"`
	PrePrice   float64  `json:"prePrice"`
	QtMiscType int      `json:"qtMiscType"`
	Version    int      `json:"version"`
	Klines     []string `json:"klines"`
}

QuoteHistoryData 东方财富 K 线历史接口中 data 字段结构体

type QuoteHistoryResp

type QuoteHistoryResp struct {
	Rc     int               `json:"rc"`
	Rt     int               `json:"rt"`
	Svr    int64             `json:"svr"`
	Lt     int               `json:"lt"`
	Full   int               `json:"full"`
	Dlmkts string            `json:"dlmkts"`
	Data   *QuoteHistoryData `json:"data"`
}

QuoteHistoryResp 东方财富 K 线历史接口返回数据结构

func GetQuoteHistory

func GetQuoteHistory(req *GetQuoteHistoryReq) (resp *QuoteHistoryResp, err error)

GetQuoteHistory 获取证券天级别历史行情信息 api: https://efinance.readthedocs.io/en/latest/api.html#efinance.stock.get_quote_history

type SecurityBasic

type SecurityBasic struct {
	ID       int64      `json:"id"`        // 主键
	Code     string     `json:"code"`      // 证券代码
	Name     string     `json:"name"`      // 证券简称
	ListDate time.Time  `json:"list_date"` // 上市日期
	Market   MarketType `json:"market"`    // 交易所 0深证 1上证
	Ctime    time.Time  `json:"ctime"`
	Mtime    time.Time  `json:"mtime"`
	Dtime    int64      `json:"dtime"` // 软删除标识
}

SecurityBasic 证券基本信息

func GetSecurityBasic

func GetSecurityBasic() ([]*SecurityBasic, error)

GetSecurityBasic 从东方财富接口,获取基本证券信息 这里不是全的,但是存放在 MySQL 中,可以先存部分数据

type StockQuote

type StockQuote struct {
	Date      time.Time `json:"date"`           // 交易日期 "2023-06-02"
	Code      string    `json:"code"`           // 证券代码
	Name      string    `json:"name"`           // 证券简称
	Exchange  string    `json:"exchange"`       // 交易所
	Open      float64   `json:"open"`           // 今日开盘价 单位:元
	Close     float64   `json:"close"`          // 最近成交价 单位:元,对于天级别数据来说,指收盘价
	YClose    float64   `json:"yclose"`         // 昨日收盘价 单位:元
	High      float64   `json:"high"`           // 最高成交价 单位:元
	Low       float64   `json:"low"`            // 最低成交价 单位:元
	Volume    int64     `json:"volume"`         // 成交数量 单位:股
	Amount    int64     `json:"amount"`         // 总笔数 单位:笔
	Money     float64   `json:"money"`          // 成交金额 单位:元
	PriceChg  float64   `json:"price_change"`   // 涨跌 单位:元
	PctChg    float64   `json:"percent_change"` // 涨跌幅 单位:%
	Amplitude float64   `json:"amplitude"`      // 振幅 单位:%
	Turn      float64   `json:"turn"`           // 换手率

}

func GetEfinanceStockQuote

func GetEfinanceStockQuote(code, start, end, period, adjust string) ([]*StockQuote, error)

通过 efinance 的接口获取单个股票的天级别行情

{
    "rc": 0,
    "rt": 17,
    "svr": 181669475,
    "lt": 1,
    "full": 0,
    "dlmkts": "",
    "data": {
        "code": "600036",
        "market": 1,
        "name": "招商银行",
        "decimal": 2,
        "dktotal": 5186,
        "preKPrice": 30.16,
        "prePrice": 28.79,
        "qtMiscType": 7,
        "klines": [
            "2023-11-13,30.17,29.82,30.27,29.61,634243,1891693842.00,2.19,-1.13,-0.34,0.31",
            "2023-11-14,29.87,30.20,30.20,29.86,448343,1347710790.00,1.14,1.27,0.38,0.22"
        ]
    }
}

func ParseEfinanceKline

func ParseEfinanceKline(kline string) (res *StockQuote, err error)

Jump to

Keyboard shortcuts

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