stockBase

package
v0.0.0-...-5e85403 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Config.go

Index

Constants

View Source
const (
	DEBUG = iota
	INFO
	ERROR
	WARN
)
View Source
const (
	ERROR_CODE_SUCCESS               = iota //成功,正确 	value --> 0
	ERROR_CODE_VER_SAME                     // 版本号相同 		value --> 1
	ERROR_CODE_MISS_VER                     //value --> 2
	ERROR_CODE_JSON_FORMAT_INVALID          //value --> 3
	ERROR_CODE_UNKNOWN_REQ                  //value --> 4
	ERROR_CODE_INVALID_HTTP_REQ             //value --> 5
	ERROR_CODE_UNSUPPORT_PERIOD             //value --> 6
	ERROR_CODE_MISS_DATAS                   //value --> 7
	ERROR_CODE_DATAS_NOT_OBJECT             //value --> 8
	ERROR_CODE_MISS_EI                      //value --> 9
	ERROR_CODE_MISS_PERIOD                  //value --> 10
	ERROR_CODE_MISS_QRYDAY                  //value --> 11
	ERROR_CODE_MISS_DAYNUM                  //value --> 12
	ERROR_CODE_DAYNUM_BEYOND                //value --> 13
	ERROR_CODE_NOT_FIND_DATA                //value --> 14
	ERROR_CODE_NOT_INNER_CODE               //value --> 15
	ERROR_CODE_JSON_PARAM_INVALID           //value --> 16
	ERROR_CODE_JSON_PARAM_ERROR             //value --> 17
	ERROR_CODE_CACHEDB_ERROR                //value --> 18
	ERROR_CODE_DBEXCETION                   //value --> 19
	ERROR_CODE_RELOADKLINE_MAXLIMITS        //value --> 20
)

Variables

This section is empty.

Functions

func Count

func Count(str, pos string) int

func GetDataByTradingDay

func GetDataByTradingDay(tradingDayInfo *TradingDayInfo) bool

func GetDataFromDb

func GetDataFromDb() bool

func GetStockLastestUpdateTime

func GetStockLastestUpdateTime() string

func ProcessBasicInstCode

func ProcessBasicInstCode(tradingDayInfo TradingDayInfo) []byte

func ProcessHttpFun

func ProcessHttpFun(tradingDayInfo TradingDayInfo, ftdc []FtdcInstrument) []byte

func ProcessHttpFunc

func ProcessHttpFunc(tradingDayInfo TradingDayInfo, strStockVer string, ftdc []FtdcInstrument) []byte

func QueryAdditionalInstCode

func QueryAdditionalInstCode(w http.ResponseWriter, r *http.Request)

func QueryBasicInstCode

func QueryBasicInstCode(w http.ResponseWriter, r *http.Request)

func QueryInstCode

func QueryInstCode(w http.ResponseWriter, r *http.Request)

func RemoveAll

func RemoveAll(m map[string]InstCodeInfo)

清空map里的所有数据

func ResultMsg

func ResultMsg(errorCode int, errorMsg string) (outJson string)

func SearchInstCodeByKey

func SearchInstCodeByKey(w http.ResponseWriter, r *http.Request)

func Split

func Split(s []string) string

func StringToUnxi

func StringToUnxi(str string) int64

string转unix

func Strncasecmp

func Strncasecmp(source string, compare string, n int) bool

strncasecmp忽略大小写比较字符串

func Substr

func Substr(str string, start int, length int) string

截取字符串 start 起点下标 length 需要截取的长度

func TradeTimes2TimeTs

func TradeTimes2TimeTs(exchangeTradingDay ExchangeTradingDay) string

Types

type Basic

type Basic struct {
	XmlName      xml.Name `xml:"basic"`
	Logdir       string   `xml:"logdir"`
	Logprefix    string   `xml:"logprefix"`
	Runlog       int      `xml:"runlog"`
	ListenIpPort string   `xml:"listenIpPort"`
}

func (Basic) String

func (basic Basic) String() string

type Comment

type Comment struct {
	Stock []TDInfoStock `json:"stock"`
	Data  []TDInfoData  `json:"data"`
}

type Config

type Config struct {
	XmlName  xml.Name `xml:"config"`
	Basic    Basic    `xml:"basic"`
	DBConfig DBConfig `xml:"dbconfig"`
}
var (
	SysConfig Config
)

func GetConfig

func GetConfig() (Config, bool)

读取配置文件

func (Config) MySqlSource

func (config Config) MySqlSource() string

func (Config) String

func (config Config) String() string

type DBConfig

type DBConfig struct {
	XmlName  xml.Name `xml:"dbconfig"`
	Host     string   `xml:"host"`
	Port     int      `xml:"port"`
	UserName string   `xml:"username"`
	PassWord string   `xml:"password"`
	DataBase string   `xml:"database"`
}

type ErrorCode

type ErrorCode struct {
	ErrorCode int
	ErrorMsg  string
}

type ExchangeTradingDay

type ExchangeTradingDay struct {
	TradingDay  string
	StartTime   int64
	EndTime     int64
	TradeTimes  string
	TradeTimeTs string
}

type FtdcInstrument

type FtdcInstrument struct {
	Id              int64   `orm:"column(ID)"`
	SecurityCode    string  `orm:"column(SecurityCode)"`    //股票代码
	SecurityName    string  `orm:"column(SecurityName)"`    // 股票中文名称
	SecurityType    string  `orm:"column(SecurityType)"`    // 股票类型
	ShortName       string  `orm:"column(ShortName)"`       // 合约名称
	EPS             float64 `orm:"column(EPS)"`             // 最近年度摊薄每股收益(eps)
	NAV             float64 `orm:"column(NAV)"`             // 每股净资产
	TotalShare      float64 `orm:"column(TotalShare)"`      // 总股本 (万股)
	CirculatedShare float64 `orm:"column(CirculatedShare)"` // 流通股本(万股)
	PriceUnit       string  `orm:"column(PriceUnit)"`       // 计价单位(CNY,US,HK)
	LaunchPrice     float64 `orm:"column(LaunchPrice)"`     // 发行价
	Status          int     `orm:"column(Status)"`          // 状态【0-无该记录 1-上市正常交易 2-未上市 3-退市】
	DecimalNum      int     `orm:"column(DecimalNum)"`      // 价格小数点后有效位数
	DbInsertTime    string  `orm:"column(DbInsertTime)"`    // 数据库插入时间
	RZRQ            int     `orm:"column(RZRQ)"`            // 融资融券标志
	SGT             int     `orm:"column(SGT)"`             // 深港通标志
	HGT             int     `orm:"column(HGT)"`             // 沪港通标志
	GT              int     `orm:"column(GT)"`              // 沪深港通标志
	ExchangeID      string  `orm:"column(ExchangeID)"`      // 交易所ID
	UsedName        string  `orm:"column(UsedName)"`        // 曾用名
	UsedShortName   string  `orm:"column(UsedShortName)"`   // 曾用名拼音

}

/合约 t_stcode

func GetInstrumentByTradingDay

func GetInstrumentByTradingDay() (int64, []FtdcInstrument)

type FtdcTradingDay

type FtdcTradingDay struct {
	ID         int64  `orm:"column(ID)"`
	TradingDay string `orm:"column(TradingDay)"`
	StartTime  string `orm:"column(StartTime)"`
	EndTime    string `orm:"column(EndTime)"`
	TradeTimes string `orm:"column(TradeTimes)"`
}

/合约交易日 t_ftdctradingday

func GetCurrentTradingDay

func GetCurrentTradingDay() (int64, []FtdcTradingDay)

type IcCodeInfo

type IcCodeInfo struct {
	ErrorCode int        `json:"errorCode"`
	ErrorMsg  string     `json:"errorMsg"`
	Comm      string     `json:"Comm"`
	Data      []InstInfo `json:"data"`
}

type InCodeInfo

type InCodeInfo struct {
	ErrorCode int                `json:"errorCode"`
	ErrorMsg  string             `json:"errorMsg"`
	Data      []InstCodeInfoData `json:"data"`
}

type InstCodeInfo

type InstCodeInfo struct {
	Id            int64  `json:"Ei"`
	SecurityCode  string `json:"Inst"`
	SecurityName  string `json:"SecNm"`
	SecurityType  string `json:"Type"`
	ShortName     string `json:"Py"`
	ExchID        string `json:"ExchID"`
	CurrentName   bool   `json:"Current"`
	UsedName      string `json:"UsedName"`
	UsedShortName string `json:"UsedShortName"`
}

func SearchByPrefix

func SearchByPrefix(prefix string, map_result map[string]InstCodeInfo, max_result_size int64) (ret bool, ICInfo []InstCodeInfo)

type InstCodeInfoData

type InstCodeInfoData struct {
	Type      string
	TraDate   string
	TraTimes  string
	TraTimeTs string
	Decm      int
	PriUnit   string
}

type InstInfo

type InstInfo struct {
	Ei      uint64
	Inst    string
	SecNm   string
	Type    string
	Py      string
	ExchID  string
	Current bool
}

type LogInfo

type LogInfo struct {
	// contains filtered or unexported fields
}

type LogWriter

type LogWriter struct {
	// contains filtered or unexported fields
}

func (*LogWriter) Info

func (l *LogWriter) Info(format string, v ...interface{})

func (*LogWriter) WriteInfo

func (_self *LogWriter) WriteInfo()

type ReqInstCode

type ReqInstCode struct {
	Ver string `json:"Ver"`
	Num int    `json:"num"`
	Key string `json:"key"`
}

type TDInfo

type TDInfo struct {
	ErrorCode int     `json:"errorCode"`
	ErrorMsg  string  `json:"errorMsg"`
	Ver       string  `json:"Ver"`
	Comm      Comment `json:"Comm"`
}

type TDInfoData

type TDInfoData struct {
	Id              int64
	SecurityCode    string  //股票代码
	SecurityName    string  // 股票中文名称
	SecurityType    string  // 股票类型
	ShortName       string  // 合约名称
	EPS             float64 // 最近年度摊薄每股收益(eps)
	NAV             float64 // 每股净资产
	TotalShare      float64 // 总股本 (万股)
	CirculatedShare float64 // 流通股本(万股)
	PriceUnit       string  // 计价单位(CNY,US,HK)
	LaunchPrice     float64 // 发行价
	Status          int     // 状态【0-无该记录 1-上市正常交易 2-未上市 3-退市】
	DecimalNum      int     // 价格小数点后有效位数
	DbInsertTime    string  // 数据库插入时间
	RZRQ            int     // 融资融券标志
	SGT             int     // 深港通标志
	HGT             int     // 沪港通标志
	GT              int     // 沪深港通标志
	ExchangeID      string  // 交易所ID
	UsedName        string  // 曾用名
	UsedShortName   string  // 曾用名拼音
}

type TDInfoStock

type TDInfoStock struct {
	Type      string
	TraDate   string
	TraTimes  string
	TraTimeTs string
	Decm      int
	PriUnit   string
}

type TradingDayInfo

type TradingDayInfo struct {
	StrStockVer        string
	StrStockCodeInfo   string
	StrBasicCodeInfo   string
	ExchangeTradingDay ExchangeTradingDay
}

func GetTradingDayInfo

func GetTradingDayInfo() TradingDayInfo

Jump to

Keyboard shortcuts

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