stockfighter

package module
v0.0.0-...-9a35ac1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2015 License: MIT Imports: 9 Imported by: 0

README

Stockfighter

Go wrapper for the stockfighter API.

GoDoc Build Status

Documentation

Overview

Package stockfighter provides a simple wrapper for the Stockfighter API:

https://www.stockfighter.io/

https://starfighter.readme.io/

Index

Constants

This section is empty.

Variables

View Source
var URL_BASE = "api.stockfighter.io"

Domain which hosts the API servers

Functions

This section is empty.

Types

type Evidence

type Evidence struct {
	Account          string `json:"account"`
	ExplanationLink  string `json:"explanation_link"`
	ExecutiveSummary string `json:"executive_summary"`
}

type Execution

type Execution struct {
	Account          string
	Venue            string
	Symbol           string
	Order            OrderState
	StandingId       uint64
	IncomingId       uint64
	Price            uint64
	Filled           uint64
	FilledAt         time.Time
	StandingComplete bool
	IncomingComplete bool
}

func (Execution) String

func (e Execution) String() string

type Fill

type Fill struct {
	Price     uint64
	Quantity  uint64    `json:"qty"`
	TimeStamp time.Time `json:"ts"`
}

type Game

type Game struct {
	Account              string
	InstanceId           uint64
	Instructions         map[string]string
	SecondsPerTradingDay uint64
	Balances             map[string]int64
	Tickers              []string
	Venues               []string
}

func (Game) String

func (g Game) String() string

type GameState

type GameState struct {
	Details struct {
		EndOfTheWorldDay uint64
		TradingDay       uint64
	}
	Flash struct {
		Info    string
		Warning string
		Danger  string
	}
	Done  bool
	Id    uint64
	State string
}

type Order

type Order struct {
	Account   string    `json:"account"`
	Venue     string    `json:"venue"`
	Stock     string    `json:"stock"`
	Price     uint64    `json:"price"`
	Quantity  uint64    `json:"qty"`
	Direction string    `json:"direction"`
	OrderType OrderType `json:"orderType"`
}

type OrderBook

type OrderBook struct {
	Venue     string
	Symbol    string
	Asks      StandingOrderSlice
	Bids      StandingOrderSlice
	TimeStamp time.Time `json:"ts"`
}

type OrderState

type OrderState struct {
	Venue            string
	Symbol           string
	Price            uint64
	OriginalQuantity uint64 `json:"originalQty"`
	Quantity         uint64 `json:"qty"`
	Direction        string
	OrderType        OrderType
	Id               uint64
	Account          string
	Timestamp        time.Time `json:"ts"`
	Fills            []Fill
	TotalFilled      uint64
	Open             bool
}

func (OrderState) String

func (os OrderState) String() string

type OrderType

type OrderType int
const (
	Limit OrderType = iota
	Market
	FillOrKill
	ImmediateOrCancel
)

func (OrderType) MarshalText

func (o OrderType) MarshalText() ([]byte, error)

func (OrderType) String

func (o OrderType) String() string

func (*OrderType) UnmarshalText

func (o *OrderType) UnmarshalText(text []byte) error

type Quote

type Quote struct {
	Venue     string
	Symbol    string
	Bid       uint64
	BidSize   uint64
	BidDepth  uint64
	Ask       uint64
	AskSize   uint64
	AskDepth  uint64
	Last      uint64
	LastSize  uint64
	LastTrade time.Time
	QuoteTime time.Time
}

func (Quote) String

func (q Quote) String() string

type StandingOrder

type StandingOrder struct {
	Price    uint64
	Quantity uint64 `json:"qty"`
	IsBuy    bool
}

type StandingOrderSlice

type StandingOrderSlice []StandingOrder

func (StandingOrderSlice) Depth

func (s StandingOrderSlice) Depth() uint64

Total depth of offers

type Stockfighter

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

func NewStockfighter

func NewStockfighter(apiKey string, debug bool) *Stockfighter

Create new Stockfighter API instance. If debug is true, log all HTTP requests and responses.

func (*Stockfighter) Cancel

func (sf *Stockfighter) Cancel(venue, stock string, id uint64) (*OrderState, error)

Cancel an existing order.

func (*Stockfighter) Executions

func (sf *Stockfighter) Executions(account, venue, stock string) (chan *Execution, error)

Subscribe to a stream of executions for a venue. If stock is a non-empy string, only executions for that stock are returned.

func (*Stockfighter) GameStatus

func (sf *Stockfighter) GameStatus(id uint64) (*GameState, error)

Get the GameState using the instance id from a previously started Game.

func (*Stockfighter) Heartbeat

func (sf *Stockfighter) Heartbeat(venue string) error

Check the API Is Up. If venue is a non-empty string, then check that venue. Returns nil if ok, otherwise the error indicates the problem.

func (*Stockfighter) Judge

func (sf *Stockfighter) Judge(id uint64, evidence *Evidence) (*GameState, error)

func (*Stockfighter) OrderBook

func (sf *Stockfighter) OrderBook(venue, stock string) (*OrderBook, error)

Get the orderbook for a particular stock.

func (*Stockfighter) Place

func (sf *Stockfighter) Place(order *Order) (*OrderState, error)

Place an order

func (*Stockfighter) Quote

func (sf *Stockfighter) Quote(venue, stock string) (*Quote, error)

Get a quick look at the most recent trade information for a stock.

func (*Stockfighter) Quotes

func (sf *Stockfighter) Quotes(account, venue, stock string) (chan *Quote, error)

Subscribe to a stream of quotes for a venue. If stock is a non-empy string, only quotes for that stock are returned.

func (*Stockfighter) Restart

func (sf *Stockfighter) Restart(id uint64) error

Restart a level using the instance id from a previously started Game.

func (*Stockfighter) Resume

func (sf *Stockfighter) Resume(id uint64) error

Resume a level using the instance id from a previously started Game.

func (*Stockfighter) Start

func (sf *Stockfighter) Start(level string) (*Game, error)

Start a new level.

func (*Stockfighter) Status

func (sf *Stockfighter) Status(venue, stock string, id uint64) (*OrderState, error)

Get the status for an existing order.

func (*Stockfighter) StockStatus

func (sf *Stockfighter) StockStatus(account, venue, stock string) ([]OrderState, error)

Get the statuses for all an account's orders of a stock on a venue. If stock is a non-empty string, only statuses for that stock are returned

func (*Stockfighter) Stocks

func (sf *Stockfighter) Stocks(venue string) ([]Symbol, error)

Get the stocks available for trading on a venue.

func (*Stockfighter) Stop

func (sf *Stockfighter) Stop(id uint64) error

Stop a level using the instance id from a previously started Game.

type Symbol

type Symbol struct {
	Symbol string
	Name   string
}

Jump to

Keyboard shortcuts

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