types

package
v0.0.0-...-252c1c9 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEBUG_OFF     DebugLevel = 0
	DEBUG_NORMAL             = 1
	DEBUG_VERBOSE            = 2
	DEBUG_TRACE              = 3
)
View Source
const (
	NonOption PutOrCall = ""
	Put                 = "PUT"
	Call                = "CALL"
)

Variables

View Source
var (
	ErrSymbolNotFound = ErrorWithCode{errors.New("symbol not found"), http.StatusNotFound}
	ErrDisconnected   = errors.New("broker disconnected")
)
View Source
var ERR_PLUGIN_NOT_IMPLEMENTED = errors.New("Not implemented for this broker")

Functions

This section is empty.

Types

type Account

type Account struct {
	ID     string `json:"id"`
	Broker string `json:"broker"`

	Type           string `json:"type"`
	NetLiquidation string `json:"net_liquidation"`
	BuyingPower    string `json:"buying_power"`
	MarginReq      string `json:"margin_req"`
	AvailableFunds string `json:"available_funds"`
	RealizedPnL    string `json:"realized_pnl"`
	UnrealizedPnL  string `json:"unrealized_pnl"`
}

type BrokerageServerPluginLatest

type BrokerageServerPluginLatest = BrokerageServerPluginV1

type BrokerageServerPluginV1

type BrokerageServerPluginV1 interface {
	Connect() error
	Close() error
	Status() *ConnectionStatus
	Error() error
	SetDebugLevel(level DebugLevel)

	AccountList(ctx context.Context) ([]*Account, error)
	GetStockQuote(ctx context.Context, symbol string) (*Quote, error)
	GetOptionsChain(ctx context.Context, symbol string) (OptionChain, error)
	GetOptionsQuotes(ctx context.Context, params OptionsQuoteParams) ([]*OptionQuote, error)
	GetHistoricalData(ctx context.Context, params HistoricalDataParams) ([]*Quote, error)
	GetPositions(ctx context.Context) ([]*Position, error)
	GetTrades(ctx context.Context, startDate time.Time) ([]*Trade, error)
}

type ConnectionStatus

type ConnectionStatus struct {
	Connected bool
	Error     error
}

type DebugLevel

type DebugLevel int

type ErrorWithCode

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

func ArgError

func ArgError(message string) ErrorWithCode

func (ErrorWithCode) Code

func (ec ErrorWithCode) Code() int

type Execution

type Execution struct {
	ExecutionId string  `json:"id"`
	OptionType  string  `json:"type,omitempty"`
	Strike      float64 `json:"strike,omitempty"`
	Expiration  string  `json:"expiration,omitempty"`
	Multiplier  int     `json:"multiplier,omitempty"`

	Exchange    string  `json:"exchange"`
	Size        int     `json:"size"`
	Price       float64 `json:"price"`
	Commissions float64 `json:"commissions"`
	RealizedPnL float64 `json:"realized_pnl,omitempty"`

	Time    time.Time   `json:"time"`
	RawData interface{} `json:"raw_data,omitempty"`
}

type HistoricalDataParams

type HistoricalDataParams struct {
	// Either Symbol or Option should be set
	Symbol string
	Option Option

	Which     HistoricalDataType
	BarWidth  time.Duration
	EndTime   time.Time
	Duration  time.Duration // Time to go back from EndTime
	IncludeAH bool          // Include afterhours data
}

type HistoricalDataType

type HistoricalDataType int
const (
	HistoricalDataTypePrice HistoricalDataType = iota
	HistoricalDataTypeIv
	HistoricalDataTypeHv
)

type Option

type Option struct {
	Underlying string
	Strike     float64
	Expiration string
	Type       PutOrCall
}

type OptionChain

type OptionChain struct {
	Underlying  string    `json:"underlying"`
	Multiplier  string    `json:"multiplier,omitempty"`
	Exchanges   []string  `json:"exchanges,omitempty"`
	Strikes     []float64 `json:"strikes"`
	Expirations []string  `json:"expirations"`
}

type OptionCombo

type OptionCombo struct {
	Legs []Option
}

type OptionQuote

type OptionQuote struct {
	Quote
	Strike        float64   `json:"strike"`
	Underlying    string    `json:"underlying"`
	Expiration    string    `json:"expiration"`
	Type          PutOrCall `json:"type"`
	MinPriceDelta float64   `json:"min_price_delta"`
	FullSymbol    string    `json:"full_symbol"` // The full symbol for the option
	OpenInterest  int64     `json:"open_interest"`

	ModelPrice float64 `json:"model_price"`
	Delta      float64 `json:"delta"`
	Gamma      float64 `json:"gamma"`
	Theta      float64 `json:"theta"`
	Vega       float64 `json:"vega"`
	Rho        float64 `json:"rho"` // Not always supported
}

type OptionsQuoteParams

type OptionsQuoteParams struct {
	Underlying  string
	Expirations []string
	Strikes     []float64
	Puts        bool
	Calls       bool
}

type Position

type Position struct {
	Symbol     string    `json:"symbol"`
	Strike     float64   `json:"strike,omitempty"`
	Multiplier string    `json:"multiplier,omitempty"`
	Expiration string    `json:"expiration,omitempty"`
	PutOrCall  PutOrCall `json:"option_type,omitempty"`

	Position      int     `json:"position"`
	MarketPrice   float64 `json:"mkt_price"`
	MarketValue   float64 `json:"mkt_value"`
	AvgPrice      float64 `json:"avg_price"`
	UnrealizedPnL float64 `json:"unrealized_pnl"`
	RealizedPnL   float64 `json:"realized_pnl"`

	RawData interface{} `json:"raw,omitempty"`

	Broker  string `json:"broker"`
	Account string `json:"account"`
}

type PutOrCall

type PutOrCall string

type Quote

type Quote struct {
	High   float64 `json:"high,omitempty"`
	Low    float64 `json:"low,omitempty"`
	Open   float64 `json:"open,omitempty"`
	Close  float64 `json:"close,omitempty"`
	Mark   float64 `json:"mark,omitempty"`
	Volume int64   `json:"volume,omitempty"`

	Bid     float64 `json:"bid,omitempty"`
	BidSize int64   `json:"bid_size,omitempty"`
	BidExch string  `json:"bid_exch,omitempty"`

	Ask     float64 `json:"ask,omitempty"`
	AskSize int64   `json:"ask_size,omitempty"`
	AskExch string  `json:"ask_exch,omitempty"`

	LastTime *time.Time `json:"last_time,omitempty"`
	Last     float64    `json:"last,omitempty"`
	LastSize int64      `json:"last_size,omitempty"`
	LastExch string     `json:"last_exch,omitempty"`

	OptionHistoricalVolatility float64 `json:"option_hv,omitempty"`
	OptionImpliedVolatility    float64 `json:"option_iv,omitempty"`
	OptionCallOpenInt          int64   `json:"option_call_open_int,omitempty"`
	OptionCallVolume           int64   `json:"option_call_vol,omitempty"`
	OptionPutOpenInt           int64   `json:"option_put_open_int,omitempty"`
	OptionPutVolume            int64   `json:"option_put_vol,omitempty"`

	AvgVol float64 `json:"avg_vol,omitempty"` // Not supported by all brokers

	Time       time.Time `json:"time,omitempty"`
	Incomplete bool      `json:"incomplete,omitempty"`
}

type SymbolDetails

type SymbolDetails struct {
	Symbol      string
	Description string
	Vendor      VendorSpecific
}

type SymbolType

type SymbolType int
const (
	SymbolEquity SymbolType = iota
	SymbolOption
)

type Trade

type Trade struct {
	Account string `json:"account"`
	Broker  string `json:"broker"`
	OrderId string `json:"id"`
	Symbol  string `json:"symbol"`

	Size  int     `json:"size"`
	Price float64 `json:"price"`

	Executions []*Execution `json:"executions"`

	Time    time.Time   `json:"time"`
	RawData interface{} `json:"raw_data,omitempty"`
}

type Tristate

type Tristate int
const (
	Yes Tristate = iota
	No
	Maybe
)

type VendorSpecific

type VendorSpecific struct {
	Data map[string]string `json:"data"`
	// Keys defines a preferred order to print the keys.
	Keys []string `json:"keys"`
}

VendorSpecific holds information that isn't common to the supported platforms, and isn't vital, but might be interesting to use when it's present.

Jump to

Keyboard shortcuts

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