lixinger

package module
v0.0.0-...-c5a3ed1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 8 Imported by: 0

README

lixinger

Stock data fetcher base on lixinger's open API https://www.lixinger.com/open/

Examples

	id := "00700"
	token := ""YOUR TOKEN from https://www.lixinger.com/open/api/token"
	obj := New(token)

	name, err := obj.GetString(id, "latest", "stockCnName")
	if err == nil {
		fmt.Println(name)
	}

	roe, err := obj.GetFloat64(id, "2017-12-31", "q.metrics.roe.ttm")
	if err == nil {
		fmt.Println(int(roe * 100))
	}

	//pe, err := obj.GetFloat64(id, "latest", "pe_ttm")
	pe, err := obj.GetFloat64(id, "2017-12-29", "pe_ttm")
	if err == nil {
		fmt.Println(int(pe))
	}


	//output:
	//腾讯控股
	//31
	//55

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finance

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

type Lixinger

type Lixinger struct {
	Finance
	Market
	StockInfo
	// contains filtered or unexported fields
}

func New

func New(token string) *Lixinger
Example
package main

import (
	"fmt"
	"github.com/go-ini/ini"
	"github.com/txcary/goutils"
	"os"
	"runtime"
)

const (
	configFile string = "lixinger.ini"
)

func slash() string {
	var ostype = runtime.GOOS
	if ostype == "windows" {
		return "\\"
	}
	if ostype == "linux" {
		return "/"
	}
	return "/"
}

func main() {
	utils.SetLogLevel(utils.LogLevelDebug)
	id := "00700"
	gopath := os.Getenv("GOPATH")
	config, err := ini.Load(gopath + slash() + configFile)
	if err != nil {
		panic(err)
	}
	token := config.Section("").Key("token").String()
	obj := New(token)

	name, err := obj.GetString(id, "latest", "stockCnName")
	if err == nil {
		fmt.Println(name)
	}

	//roe, err := obj.GetFloat64(id, "latest", "q.metrics.roe.ttm")
	roe, err := obj.GetFloat64(id, "2017-12-31", "q.metrics.roe.ttm")
	if err == nil {
		fmt.Println(int(roe * 100))
	}

	roeArray, err := obj.FilterFloat64(id, "12-31", "q.metrics.roe.ttm")
	if err == nil {
		for idx, _ := range roeArray {
			fmt.Println(int(roeArray[idx] * 100))
		}
	}

	//pe, err := obj.GetFloat64(id, "latest", "pe_ttm")
	pe, err := obj.GetFloat64(id, "2017-12-29", "pe_ttm")
	if err == nil {
		fmt.Println(int(pe))
	}

}
Output:

腾讯控股
31
31
26
28
33
30
35
40
47
53
45
55

func (*Lixinger) FilterFloat64

func (obj *Lixinger) FilterFloat64(id string, date string, dataMetrics string) (res []float64, err error)

func (*Lixinger) GetFloat64

func (obj *Lixinger) GetFloat64(id string, date string, dataMetrics string) (res float64, err error)

func (*Lixinger) GetString

func (obj *Lixinger) GetString(id string, date string, dataMetrics string) (res string, err error)

func (*Lixinger) Init

func (obj *Lixinger) Init(token string)

type Market

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

type StockInfo

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

Jump to

Keyboard shortcuts

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