Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

go-activetick

A Go library for accessing the ActiveTick HTTP API.

GoDoc Build Status Coverage Status

go-activetick is a library to access the ActiveTick HTTP API from Go.

ActiveTick is not affiliated and does not endorse or recommend this library.

Usage

atclient CLI

$ atclient -symbol SPY -begin_time 2016-10-04T14:30:00Z -end_time 2016-10-04T14:40:00Z -type tick

Fetch historical minute bars

package main

import (
    "fmt"
    "net/http"
    "time"

    "github.com/timpalpant/go-activetick"
)

func main() {
    endpoint := "http://localhost:5000"
    client := activetick.NewPagingClient(activetick.NewClient(&http.Client{}, endpoint))

	req := &activetick.BarDataRequest{
		Symbol:          "SPY",
		HistoryType:     activetick.HistoryTypeIntraday,
		IntradayMinutes: 1,
		BeginTime:       time.Now().Add(-48 * time.Hour),
		EndTime:         time.Now().Add(-47 * time.Hour),
	}

	resp, err := client.GetBarData(req)
	if err != nil {
		log.Fatal(err)
	}

	for _, record := range resp.Records {
		fmt.Printf("%v,%v,%v,%v,%v,%v\n", record.Time, record.Open,
			record.High, record.Low, record.Close, record.Volume)
	}
}

Fetch historical ticks

package main

import (
    "fmt"
    "net/http"

    "github.com/timpalpant/go-activetick"
)

func main() {
    endpoint := "http://localhost:5000"
    client := activetick.NewPagingClient(activetick.NewClient(&http.Client{}, endpoint))

	req := &activetick.TickDataRequest{
		Symbol:    "SPY",
		BeginTime: time.Now().Add(-48 * time.Hour),
		EndTime:   time.Now().Add(-47 * time.Hour),
		Trades:    true,
		Quotes:    true,
	}

	resp, err := client.GetTickData(req)
	if err != nil {
		log.Fatal(err)
	}

	for _, record := range resp.Records {
		if record.Type == activetick.TickTypeQuote {
			fmt.Printf("%v,%v,%v,%v,%v,%v,%v\n", record.Time,
				record.BidPrice, record.BidSize, record.BidExchange,
				record.AskPrice, record.AskSize, record.AskExchange)
		} else {
			fmt.Printf("%v,%v,%v,%v\n", record.Time,
				record.LastPrice, record.LastSize, record.LastExchange)
		}
	}
}

Contributing

Pull requests and issues are welcomed!

License

go-activetick is released under the GNU Lesser General Public License, Version 3.0

About

A Go library for accessing the ActiveTick HTTP API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages