eniu

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

eniu

亿牛网接口封装

实现功能

  • 获取历史股价信息
  • 计算股价历史波动率

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Eniu

type Eniu struct {
	// http 客户端
	HTTPClient *http.Client
}

Eniu 亿牛网数据源

func NewEniu

func NewEniu() Eniu

NewEniu 创建 Eniu 实例

func (Eniu) GetPathCode

func (e Eniu) GetPathCode(ctx context.Context, secuCode string) string

GetPathCode 返回接口 url path 中的股票代码

func (Eniu) QueryHistoricalStockPrice

func (e Eniu) QueryHistoricalStockPrice(ctx context.Context, secuCode string) (RespHistoricalStockPrice, error)

QueryHistoricalStockPrice 获取历史股价,最新数据在最后,有一天的延迟

type RespHistoricalStockPrice

type RespHistoricalStockPrice struct {
	Date  []string  `json:"date"`
	Price []float64 `json:"price"`
}

RespHistoricalStockPrice 历史股价接口返回结构

func (RespHistoricalStockPrice) HistoricalVolatility

func (p RespHistoricalStockPrice) HistoricalVolatility(ctx context.Context, period string) (float64, error)

HistoricalVolatility 计算历史波动率 历史波动率计算方法:https://goodcalculators.com/historical-volatility-calculator/ 1、从市场上获得标的股票在固定时间间隔(如每天DAY、每周WEEK或每月MONTH等)上的价格。 2、对于每个时间段,求出该时间段末的股价与该时段初的股价之比的自然对数。 3、求出这些对数值的标准差即为历史波动率的估计值 4、若将日、周等标准差转化为年标准差,需要再乘以一年中包含的时段数量的平方根(如,选取时间间隔为每天,则若扣除闭市,每年中有250个交易日,应乘以根号250)

func (RespHistoricalStockPrice) LastYearFinalPrice

func (p RespHistoricalStockPrice) LastYearFinalPrice() float64

LastYearFinalPrice 获取去年12月份最后一个交易日的股价

Jump to

Keyboard shortcuts

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