rest

package
v0.0.0-...-0a4bc02 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// fasthhtp Maximum number of connections per each host which may be established.
	MaxConnsPerHost = 100
	//  fasthhtp Maximum number of attempts for idempotent calls
	MaxIdemponentCallAttempts = 10

	// Error returned by Tradier if we make too big of a request.
	ErrBodyBufferOverflow = "protocol.http.TooBigBody"
)
View Source
const (
	SandboxEndpoint = "https://sandbox.tradier.com"
	APIEndpoint     = "https://api.tradier.com"
	StreamEndpoint  = "https://stream.tradier.com"
)

Variables

View Source
var (
	// ErrNoAccountSelected is returned if account-specific methods
	// are attempted to be used without selecting an account first.
	ErrNoAccountSelected = errors.New("no account selected")
)
View Source
var OldestDailyDate = time.Date(1980, time.January, 1, 0, 0, 0, 0, time.UTC)

Functions

func MyTradierProductionPosition

func MyTradierProductionPosition()

func MyTradierSandboxPosition

func MyTradierSandboxPosition()

func MyTradier_Market

func MyTradier_Market()

func MyTradier_Stream

func MyTradier_Stream()

func OpenStreamSocket

func OpenStreamSocket(id string)

func ParseTimeMs

func ParseTimeMs(tsMs string) (time.Time, error)

func Redis_Subscribe

func Redis_Subscribe()

Types

type Client

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

Client provides methods for making requests to the Tradier API.

func NewClient

func NewClient(params ClientParams) *Client

func (*Client) GetAccountPositions

func (tc *Client) GetAccountPositions() (interface{}, error)

Get the current account Positions

func (*Client) GetMarketState

func (tc *Client) GetMarketState() (MarketStatus, error)

Get the current state of the market (open/closed/etc.)

func (*Client) GetSessionID

func (tc *Client) GetSessionID() (Stream, error)

func (*Client) SelectAccount

func (tc *Client) SelectAccount(account string)

type ClientParams

type ClientParams struct {
	Endpoint   string
	AuthToken  string
	Client     *fasthttp.Client
	RetryLimit int
	Account    string
}

func DefaultParams

func DefaultParams(authToken string) ClientParams

DefaultParams returns ClientParams initialized with default values.

type DateTime

type DateTime struct {
	time.Time
}

DateTime wraps time.Time and adds flexible implementations for unmarshaling JSON in the different forms it appears in the Tradier API.

func (*DateTime) Set

func (d *DateTime) Set(s string) error

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(b []byte) error

type Filter

type Filter string
const (
	FilterTrade    Filter = "trade"
	FilterQuote    Filter = "quote"
	FilterTimeSale Filter = "timesale"
	FilterSummary  Filter = "summary"
)

type FloatOrNaN

type FloatOrNaN float64

func (*FloatOrNaN) UnmarshalJSON

func (f *FloatOrNaN) UnmarshalJSON(data []byte) error

func (FloatOrNaN) Value

func (f FloatOrNaN) Value() (driver.Value, error)

type Interval

type Interval string
const (
	IntervalTick    Interval = "tick"
	IntervalMinute  Interval = "1min"
	Interval5Min    Interval = "5min"
	Interval15Min   Interval = "15min"
	IntervalDaily   Interval = "daily"
	IntervalWeekly  Interval = "weekly"
	IntervalMonthly Interval = "monthly"
)

type MarketCalendar

type MarketCalendar struct {
	Date        DateTime
	Status      string
	Description string
	Open        struct {
		Start string
		End   string
	}
	Premarket struct {
		Start string
		End   string
	}
	Postmarket struct {
		Start string
		End   string
	}
}

type MarketState

type MarketState string
const (
	MarketPremarket  MarketState = "premarket"
	MarketOpen       MarketState = "open"
	MarketPostmarket MarketState = "postmarket"
	MarketClosed     MarketState = "closed"
)

type MarketStatus

type MarketStatus struct {
	Time        DateTime `json:"date"`
	State       string
	Description string
	NextChange  DateTime `json:"next_change"`
	NextState   string   `json:"next_state"`
}

type Position

type Position struct {
	CostBasis    float64  `json:"cost_basis"`
	DateAcquired DateTime `json:"date_acquired"`
	Id           int
	Quantity     float64
	Symbol       string
}

type Quote

type Quote struct {
	Symbol           string
	Description      string
	Exchange         string `json:"exch"`
	Type             string
	Change           float64
	ChangePercentage float64 `json:"change_percentage"`
	Volume           int
	AverageVolume    int
	Last             float64
	LastVolume       int
	TradeDate        DateTime `json:"trade_date"`
	Open             float64
	High             float64
	Low              float64
	Close            float64
	PreviousClose    float64 `json:"prevclose"`
	Week52High       float64 `json:"week_52_high"`
	Week52Low        float64 `json:"week_52_low"`
	Bid              float64
	BidSize          int
	BidExchange      string   `json:"bidexch"`
	BidDate          DateTime `json:"bid_date"`
	Ask              float64
	AskSize          int
	AskExchange      string   `json:"askexch"`
	AskDate          DateTime `json:"ask_date"`
	OpenInterest     float64  `json:"open_interest"`
	Underlying       string
	Strike           float64
	ContractSize     int
	ExpirationDate   DateTime `json:"expiration_date"`
	ExpirationType   string   `json:"expiration_type"`
	OptionType       string   `json:"option_type"`
	RootSymbol       string   `json:"root_symbol"`
}

type Security

type Security struct {
	Symbol      string
	Exchange    string
	Type        string
	Description string
}

type SecurityType

type SecurityType string
const (
	SecurityTypeStock      SecurityType = "stock"
	SecurityTypeIndex      SecurityType = "index"
	SecurityTypeETF        SecurityType = "etf"
	SecurityTypeMutualFund SecurityType = "mutual_fund"
)

type Stream

type Stream struct {
	SessionId string
	Url       string
}
var SocketConfig Stream

type TimeSale

type TimeSale struct {
	Date      DateTime
	Time      DateTime
	Timestamp int64
	Open      FloatOrNaN
	Close     FloatOrNaN
	High      FloatOrNaN
	Low       FloatOrNaN
	Price     FloatOrNaN
	Vwap      FloatOrNaN
	Volume    int64
}

type TradierError

type TradierError struct {
	Fault struct {
		FaultString string
		Detail      struct {
			ErrorCode string
		}
	}
	HttpStatusCode int
	Message        string
}

func (TradierError) Error

func (te TradierError) Error() string

Jump to

Keyboard shortcuts

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