stockdb

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2016 License: MIT Imports: 4 Imported by: 0

README

Golang client library for StockDB

Example

example

Instllation

$ go get github.com/miaolz123/stockdb/stockdb

Reference

Official Repos

Document

Documentation

Index

Constants

View Source
const (
	Second  int64 = 1
	Minute  int64 = 60 * Second
	Hour    int64 = 60 * Minute
	Day     int64 = 24 * Hour
	Week    int64 = 7 * Day
	Month   int64 = 30 * Day
	Quarter int64 = 3 * Month
	Year    int64 = 365 * Day
)

Period constant

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	Success bool        `json:"Success"`
	Message string      `json:"Message"`
	Data    interface{} `json:"Data"`
}

BaseResponse is base response struct

type Client

type Client struct {
	Hprose *rpc.HTTPClient

	PutOHLC      func(datum OHLC, opt Option) BaseResponse
	PutOHLCs     func(data []OHLC, opt Option) BaseResponse
	PutOrder     func(datum Order, opt Option) BaseResponse
	PutOrders    func(data []Order, opt Option) BaseResponse
	GetStats     func() StatsResponse
	GetMarkets   func() StringsResponse
	GetSymbols   func(market string) StringsResponse
	GetTimeRange func(opt Option) TimeRangeResponse
	GetOHLCs     func(opt Option) OHLCResponse
	GetDepth     func(opt Option) DepthResponse
	// contains filtered or unexported fields
}

Client of StockDB

func New

func New(uri, auth string) (client *Client)

New can create a StockDB Client

type Depth

type Depth struct {
	Bids []OrderBook `json:"Bids"`
	Asks []OrderBook `json:"Asks"`
}

Depth struct

type DepthResponse

type DepthResponse struct {
	Success bool   `json:"Success"`
	Message string `json:"Message"`
	Data    Depth  `json:"Data"`
}

DepthResponse is market depth response struct

type OHLC

type OHLC struct {
	Time   int64   `json:"Time"`
	Open   float64 `json:"Open"`
	High   float64 `json:"High"`
	Low    float64 `json:"Low"`
	Close  float64 `json:"Close"`
	Volume float64 `json:"Volume"`
}

OHLC is a candlestick struct

type OHLCResponse

type OHLCResponse struct {
	Success bool   `json:"Success"`
	Message string `json:"Message"`
	Data    []OHLC `json:"Data"`
}

OHLCResponse is OHLC response struct

type Option

type Option struct {
	Market        string `json:"Market" ini:"Market"`
	Symbol        string `json:"Symbol" ini:"Symbol"`
	Period        int64  `json:"Period" ini:"Period"`
	BeginTime     int64  `json:"BeginTime" ini:"BeginTime"`
	EndTime       int64  `json:"EndTime" ini:"EndTime"`
	InvalidPolicy string `json:"InvalidPolicy" ini:"InvalidPolicy"`
}

Option is a request option

type Order added in v0.1.4

type Order struct {
	ID     string  `json:"ID"`
	Time   int64   `json:"Time"`
	Price  float64 `json:"Price"`
	Amount float64 `json:"Amount"`
	Type   string  `json:"Type"`
}

Order is an order record struct

type OrderBook

type OrderBook struct {
	Price  float64 `json:"Price"`
	Amount float64 `json:"Amount"`
}

OrderBook struct

type Stats added in v0.1.3

type Stats struct {
	Market string `json:"Market"`
	Record int64  `json:"Record"`
	Disk   int64  `json:"Disk"`
}

Stats is stats struct

type StatsResponse added in v0.1.3

type StatsResponse struct {
	Success bool    `json:"Success"`
	Message string  `json:"Message"`
	Data    []Stats `json:"Data"`
}

StatsResponse is Stats response struct

type StringsResponse

type StringsResponse struct {
	Success bool     `json:"Success"`
	Message string   `json:"Message"`
	Data    []string `json:"Data"`
}

StringsResponse is Strings response struct

type TimeRangeResponse

type TimeRangeResponse struct {
	Success bool     `json:"Success"`
	Message string   `json:"Message"`
	Data    [2]int64 `json:"Data"`
}

TimeRangeResponse is TimeRange response struct

Jump to

Keyboard shortcuts

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