gotrade

package module
v0.0.0-...-08b7c41 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2014 License: MIT Imports: 3 Imported by: 2

README

gotrade

Golang stock market technical analysis library

Build Status

Stories in Ready

GoTrade is in early design and development

Below is a look at the basic API so far

	csvFeed := feeds.NewCSVFileFeedWithDOHLCVFormat("../github.com/thetruetrade/gotrade/testdata/JSETOPI.2013.data",
		feeds.DashedYearDayMonthDateParserForLocation(time.Local))

	priceStream := gotrade.NewDailyDOHLCVStream()
	sma, _ := indicators.NewSMAForStream(priceStream, 20, gotrade.UseClosePrice)
	ema, _ := indicators.NewEMAForStream(priceStream, 20, gotrade.UseClosePrice)
	bb, _ := indicators.NewBollingerBandsForStream(priceStream, 20, gotrade.UseClosePrice)

	csvFeed.FillDOHLCVStream(priceStream)

	fmt.Println("price stream has data of length: ", len(priceStream.Data))
	fmt.Println("price stream has min date: ", priceStream.MinDate())
	fmt.Println("price stream has max date: ", priceStream.MaxDate())

	fmt.Println("sma has data of length: ", len(sma.Data))
	fmt.Println("sma is valid from price stream bar number: ", sma.ValidFromBar())
	fmt.Println("sma max: ", sma.MaxValue(), " sma min: ", sma.MinValue())

	fmt.Println("ema has data of length: ", len(ema.Data))
	fmt.Println("ema is valid from price stream bar number: ", ema.ValidFromBar())
	fmt.Println("ema max: ", ema.MaxValue(), " ema min: ", ema.MinValue())

	fmt.Println("bollinger bands has data of length: ", len(bb.Data))
	fmt.Println("bollinger bands is valid from price stream bar number: ", bb.ValidFromBar())
	fmt.Println("bollinger bands max: ", bb.MaxValue(), " sma min: ", bb.MinValue())

Tasks for the near future include:

  • Complete a basic set of indicators
  • Add point and figure price streams
  • Basic pattern matching
    • Candlesticks
    • Point and figure patterns
  • Visualisation in gotrade-plot
  • Operator support like Crosses etc.
  • Script engine in gotrade-script

Documentation

Overview

Package GoTrade implements

Index

Constants

View Source
const (
	MinuteBar intraDayBarType = iota
	DailyBar  interDayBarType = iota
	WeeklyBar
	MonthlyBar
)

Variables

This section is empty.

Functions

func UseClosePrice

func UseClosePrice(dataItem DOHLCV) float64

Close price DOHLCV data selector

func UseHighPrice

func UseHighPrice(dataItem DOHLCV) float64

High price DOHLCV data selector

func UseLowPrice

func UseLowPrice(dataItem DOHLCV) float64

Low price DOHLCV data selector

func UseOpenPrice

func UseOpenPrice(dataItem DOHLCV) float64

Open price DOHLCV data selector

func UseVolume

func UseVolume(dataItem DOHLCV) float64

Volume DOHLCV data selector

Types

type DOHLCV

type DOHLCV interface {
	D() time.Time
	O() float64
	H() float64
	L() float64
	C() float64
	V() float64
}

type DOHLCVDataItem

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

func NewDOHLCVDataItem

func NewDOHLCVDataItem(date time.Time, openPrice float64, highPrice float64, lowPrice float64, closePrice float64, volume float64) *DOHLCVDataItem

func (*DOHLCVDataItem) C

func (di *DOHLCVDataItem) C() float64

func (*DOHLCVDataItem) D

func (di *DOHLCVDataItem) D() time.Time

func (*DOHLCVDataItem) H

func (di *DOHLCVDataItem) H() float64

func (*DOHLCVDataItem) L

func (di *DOHLCVDataItem) L() float64

func (*DOHLCVDataItem) O

func (di *DOHLCVDataItem) O() float64

func (*DOHLCVDataItem) V

func (di *DOHLCVDataItem) V() float64

type DOHLCVDataSelectionFunc

type DOHLCVDataSelectionFunc func(dataItem DOHLCV) float64

A function that selects which data property to use from a DOHLCV data structure

type DOHLCVStream

type DOHLCVStream struct {
	Data []DOHLCV
	// contains filtered or unexported fields
}

func (*DOHLCVStream) AddTickSubscription

func (p *DOHLCVStream) AddTickSubscription(subscriber DOHLCVTickReceiver)

func (*DOHLCVStream) MaxDate

func (p *DOHLCVStream) MaxDate() time.Time

func (*DOHLCVStream) MaxValue

func (p *DOHLCVStream) MaxValue() float64

func (*DOHLCVStream) MinDate

func (p *DOHLCVStream) MinDate() time.Time

func (*DOHLCVStream) MinValue

func (p *DOHLCVStream) MinValue() float64

func (*DOHLCVStream) ReceiveTick

func (p *DOHLCVStream) ReceiveTick(tickData DOHLCV)

func (*DOHLCVStream) RemoveTickSubscription

func (p *DOHLCVStream) RemoveTickSubscription(subscriber DOHLCVTickReceiver)

type DOHLCVStreamSubscriber

type DOHLCVStreamSubscriber interface {
	AddTickSubscription(subscriber DOHLCVTickReceiver)
}

type DOHLCVStreamTickReceiver

type DOHLCVStreamTickReceiver interface {
	ReceiveTick(tickData DOHLCV)
}

type DOHLCVTickReceiver

type DOHLCVTickReceiver interface {
	ReceiveDOHLCVTick(tickData DOHLCV, streamBarIndex int)
}

Consumer of DOHLCV Ticks

type DataStreamHolder

type DataStreamHolder interface {
	MinValue() float64
	MaxValue() float64
}

type DateStreamHolder

type DateStreamHolder interface {
	MinDate() time.Time
	MaxDate() time.Time
}

type InterDayDOHLCVStream

type InterDayDOHLCVStream struct {
	*DOHLCVStream
	// contains filtered or unexported fields
}

func NewDailyDOHLCVStream

func NewDailyDOHLCVStream() *InterDayDOHLCVStream

func NewInterDayDOHLCVStream

func NewInterDayDOHLCVStream(streamBarType interDayBarType) *InterDayDOHLCVStream

func NewMonthlyDOHLCVStream

func NewMonthlyDOHLCVStream() *InterDayDOHLCVStream

func NewWeeklyDOHLCVStream

func NewWeeklyDOHLCVStream() *InterDayDOHLCVStream

type IntraDayDOHLCVStream

type IntraDayDOHLCVStream struct {
	*DOHLCVStream
	// contains filtered or unexported fields
}

func NewIntraDayDOHLCVStream

func NewIntraDayDOHLCVStream(barIntervalInMins int) *IntraDayDOHLCVStream

type OHLC

type OHLC interface {
	O() float64
	H() float64
	L() float64
	C() float64
}

type OHLCV

type OHLCV interface {
	O() float64
	H() float64
	L() float64
	C() float64
	V() float64
}

type TickReceiver

type TickReceiver interface {
	ReceiveTick(tickData float64, streamBarIndex int)
}

Consumer of a float tick

Directories

Path Synopsis
import "github.com/thetruetrade/gotrade" Package indicators provides a range of technical trading indicators.
import "github.com/thetruetrade/gotrade" Package indicators provides a range of technical trading indicators.

Jump to

Keyboard shortcuts

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