tradier

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: LGPL-3.0 Imports: 15 Imported by: 0

README

My fork for handling Redis Cache from Tradier API

Thanks to

Thanks to Timothy Palpant for the work.

License

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

Documentation

Overview

Package tradier implements a Client for using the Tradier API.

Index

Constants

View Source
const (
	// Order classes.
	Equity                     = "equity"
	Option                     = "option"
	Multileg                   = "multileg"
	Combo                      = "combo"
	OneTriggersOther           = "oto"
	OneCancelsOther            = "oco"
	OneTriggersOneCancelsOther = "otoco"

	// Order sides.
	Buy         = "buy"
	BuyToCover  = "buy_to_cover"
	BuyToOpen   = "buy_to_open"
	BuyToClose  = "buy_to_close"
	Sell        = "sell"
	SellShort   = "sell_short"
	SellToOpen  = "sell_to_open"
	SellToClose = "sell_to_close"

	// Order types.
	MarketOrder    = "market"
	LimitOrder     = "limit"
	StopOrder      = "stop"
	StopLimitOrder = "stop_limit"
	Credit         = "credit"
	Debit          = "debit"
	Even           = "even"

	// Order durations.
	Day        = "day"
	GTC        = "gtc"
	PreMarket  = "pre"
	PostMarket = "post"

	// Option types.
	Put  = "put"
	Call = "call"

	// Order statuses.
	StatusOK        = "ok"
	Filled          = "filled"
	Canceled        = "canceled"
	Open            = "open"
	Expired         = "expired"
	Rejected        = "rejected"
	Pending         = "pending"
	PartiallyFilled = "partially_filled"
	Submitted       = "submitted"
)
View Source
const (
	SandboxEndpoint = "https://sandbox.tradier.com"
	APIEndpoint     = "https://api.tradier.com"
	StreamEndpoint  = "https://stream.tradier.com"
)
View Source
const (

	// Error returned by Tradier if we make too big of a request.
	ErrBodyBufferOverflow = "protocol.http.TooBigBody"
)

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 ParseTimeMs

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

func UnmarshalStreamEvent

func UnmarshalStreamEvent(buf []byte, se *StreamEvent) error

Types

type AccountBalances

type AccountBalances struct {
	AccountNumber      string  `json:"account_number"`
	AccountType        string  `json:"account_type"`
	ClosePL            float64 `json:"close_pl"`
	CurrentRequirement float64 `json:"current_requirement"`
	Equity             float64
	LongMarketValue    float64 `json:"long_market_value"`
	MarketValue        float64 `json:"market_value"`
	OpenPL             float64 `json:"open_pl"`
	OptionLongValue    float64 `json:"option_long_value"`
	OptionRequirement  float64 `json:"option_requirement"`
	OptionShortValue   float64 `json:"option_short_value"`
	PendingOrdersCount int     `json:"pending_orders_count"`
	ShortMarketValue   float64 `json:"short_market_value"`
	StockLongValue     float64 `json:"stock_long_value"`
	TotalCash          float64 `json:"total_cash"`
	TotalEquity        float64 `json:"total_equity"`
	UnclearedFunds     float64 `json:"uncleared_funds"`
	Margin             Margin
	Cash               Cash
	PDT                PDT
}

type Adjustment

type Adjustment struct {
	Description string
	Quantity    float64
}

type AlphaBeta

type AlphaBeta struct {
	Alpha        *float64 `json:"alpha"`
	AsOfDate     *string  `json:"as_of_date"`
	Beta         *float64 `json:"beta"`
	NonDivAlpha  *float64 `json:"non_div_alpha"`
	NonDivBeta   *float64 `json:"non_div_beta"`
	Period       *string  `json:"period"`
	ShareClassID *string  `json:"share_class_id"`
}

type AssetClassification

type AssetClassification struct {
	FinancialHealthGradeAsOfDate *string  `json:"FinancialHealthGrade.asOfDate"`
	GrowthGradeAsOfDate          *string  `json:"GrowthGrade.asOfDate"`
	ProfitabilityGradeAsOfDate   *string  `json:"ProfitabilityGrade.asOfDate"`
	StockTypeAsOfDate            *string  `json:"StockType.asOfDate"`
	StyleBoxAsOfDate             *string  `json:"StyleBox.asOfDate"`
	CANNAICS                     *int64   `json:"c_a_n_n_a_i_c_s"`
	CompanyID                    *string  `json:"company_id"`
	FinancialHealthGrade         *string  `json:"financial_health_grade"`
	GrowthGrade                  *string  `json:"growth_grade"`
	GrowthScore                  *float64 `json:"growth_score"`
	MorningstarEconomySphereCode *int64   `json:"morningstar_economy_sphere_code"`
	MorningstarIndustryCode      *int64   `json:"morningstar_industry_code"`
	MorningstarIndustryGroupCode *int64   `json:"morningstar_industry_group_code"`
	MorningstarSectorCode        *int64   `json:"morningstar_sector_code"`
	NACE                         *float64 `json:"n_a_c_e"`
	NAICS                        NAICS    `json:"n_a_i_c_s"`
	ProfitabilityGrade           *string  `json:"profitability_grade"`
	SIC                          SIC      `json:"s_i_c"`
	SizeScore                    *float64 `json:"size_score"`
	StockType                    *int64   `json:"stock_type"`
	StyleBox                     *int64   `json:"style_box"`
	StyleScore                   *float64 `json:"style_score"`
	ValueScore                   *float64 `json:"value_score"`
}

type BalanceSheet

type BalanceSheet struct {
	AccountsPayable                               *float64 `json:"accounts_payable"`
	AccountsReceivable                            *float64 `json:"accounts_receivable"`
	AccumulatedDepreciation                       *float64 `json:"accumulated_depreciation"`
	CapitalStock                                  *float64 `json:"capital_stock"`
	CashAndCashEquivalents                        *float64 `json:"cash_and_cash_equivalents"`
	CashCashEquivalentsAndMarketableSecurities    *float64 `json:"cash_cash_equivalents_and_marketable_securities"`
	CommercialPaper                               *float64 `json:"commercial_paper"`
	CommonStock                                   *float64 `json:"common_stock"`
	CommonStockEquity                             *float64 `json:"common_stock_equity"`
	CurrencyID                                    *string  `json:"currency_id"`
	CurrentAccruedExpenses                        *float64 `json:"current_accrued_expenses"`
	CurrentAssets                                 *float64 `json:"current_assets"`
	CurrentDebt                                   *float64 `json:"current_debt"`
	CurrentDebtAndCapitalLeaseObligation          *float64 `json:"current_debt_and_capital_lease_obligation"`
	CurrentDeferredLiabilities                    *float64 `json:"current_deferred_liabilities"`
	CurrentDeferredRevenue                        *float64 `json:"current_deferred_revenue"`
	CurrentLiabilities                            *float64 `json:"current_liabilities"`
	FileDate                                      *string  `json:"file_date"`
	FiscalYearEnd                                 *string  `json:"fiscal_year_end"`
	GainsLossesNotAffectingRetainedEarnings       *float64 `json:"gains_losses_not_affecting_retained_earnings"`
	Goodwill                                      *float64 `json:"goodwill"`
	GoodwillAndOtherIntangibleAssets              *float64 `json:"goodwill_and_other_int64angible_assets"`
	GrossPPE                                      *float64 `json:"gross_p_p_e"`
	Inventory                                     *float64 `json:"inventory"`
	InvestedCapital                               *float64 `json:"invested_capital"`
	InvestmentsAndAdvances                        *float64 `json:"investments_and_advances"`
	LandAndImprovements                           *float64 `json:"land_and_improvements"`
	Leases                                        *float64 `json:"leases"`
	LongTermDebt                                  *float64 `json:"long_term_debt"`
	LongTermDebtAndCapitalLeaseObligation         *float64 `json:"long_term_debt_and_capital_lease_obligation"`
	MachineryFurnitureEquipment                   *float64 `json:"machinery_furniture_equipment"`
	NetDebt                                       *float64 `json:"net_debt"`
	NetPPE                                        *float64 `json:"net_p_p_e"`
	NetTangibleAssets                             *float64 `json:"net_tangible_assets"`
	NonCurrentDeferredLiabilities                 *float64 `json:"non_current_deferred_liabilities"`
	NonCurrentDeferredRevenue                     *float64 `json:"non_current_deferred_revenue"`
	NonCurrentDeferredTaxesLiabilities            *float64 `json:"non_current_deferred_taxes_liabilities"`
	NumberOfShareHolders                          *int64   `json:"number_of_share_holders"`
	OrdinarySharesNumber                          *float64 `json:"ordinary_shares_number"`
	OtherCurrentAssets                            *float64 `json:"other_current_assets"`
	OtherCurrentBorrowings                        *float64 `json:"other_current_borrowings"`
	OtherIntangibleAssets                         *float64 `json:"other_int64angible_assets"`
	OtherNonCurrentAssets                         *float64 `json:"other_non_current_assets"`
	OtherNonCurrentLiabilities                    *float64 `json:"other_non_current_liabilities"`
	OtherReceivables                              *float64 `json:"other_receivables"`
	OtherShortTermInvestments                     *float64 `json:"other_short_term_investments"`
	Payables                                      *float64 `json:"payables"`
	PayablesAndAccruedExpenses                    *float64 `json:"payables_and_accrued_expenses"`
	Period                                        *string  `json:"period"`
	PeriodEndingDate                              *string  `json:"period_ending_date"`
	Receivables                                   *float64 `json:"receivables"`
	ReportType                                    *string  `json:"report_type"`
	RetainedEarnings                              *float64 `json:"retained_earnings"`
	ShareIssued                                   *float64 `json:"share_issued"`
	StockholdersEquity                            *float64 `json:"stockholders_equity"`
	TangibleBookValue                             *float64 `json:"tangible_book_value"`
	TotalAssets                                   *float64 `json:"total_assets"`
	TotalCapitalization                           *float64 `json:"total_capitalization"`
	TotalDebt                                     *float64 `json:"total_debt"`
	TotalEquity                                   *float64 `json:"total_equity"`
	TotalEquityGrossMinorityInterest              *float64 `json:"total_equity_gross_minority_int64erest"`
	TotalLiabilities                              *float64 `json:"total_liabilities"`
	TotalLiabilitiesNetMinorityInterest           *float64 `json:"total_liabilities_net_minority_int64erest"`
	TotalNonCurrentAssets                         *float64 `json:"total_non_current_assets"`
	TotalNonCurrentLiabilities                    *float64 `json:"total_non_current_liabilities"`
	TotalNonCurrentLiabilitiesNetMinorityInterest *float64 `json:"total_non_current_liabilities_net_minority_int64erest"`
	WorkingCapital                                *float64 `json:"working_capital"`
}

type BalanceSheetResults

type BalanceSheetResults []map[string]BalanceSheet

func (*BalanceSheetResults) UnmarshalJSON

func (bsr *BalanceSheetResults) UnmarshalJSON(data []byte) error

type Cash

type Cash struct {
	CashAvailable  float64 `json:"cash_available"`
	Sweep          int
	UnsettledFunds float64 `json:"unsettled_funds"`
}

type CashDividend

type CashDividend struct {
	CashAmount      *float64 `json:"cash_amount"`
	CurrencyID      *string  `json:"currency_i_d"`
	DeclarationDate *string  `json:"declaration_date"`
	DividendType    *string  `json:"dividend_type"`
	ExDate          *string  `json:"ex_date"`
	Frequency       *int64   `json:"frequency"`
	PayDate         *string  `json:"pay_date"`
	RecordDate      *string  `json:"record_date"`
	ShareClassID    *string  `json:"share_class_id"`
}

type CashDividends

type CashDividends []CashDividend

func (*CashDividends) UnmarshalJSON

func (cds *CashDividends) UnmarshalJSON(data []byte) error

type CashFlowStatement

type CashFlowStatement struct {
	BeginningCashPosition             *float64 `json:"beginning_cash_position"`
	CapitalExpenditure                *float64 `json:"capital_expenditure"`
	CashDividendsPaid                 *float64 `json:"cash_dividends_paid"`
	ChangeInAccountPayable            *float64 `json:"change_in_account_payable"`
	ChangeInInventory                 *float64 `json:"change_in_inventory"`
	ChangeInOtherWorkingCapital       *float64 `json:"change_in_other_working_capital"`
	ChangeInPayable                   *float64 `json:"change_in_payable"`
	ChangeInPayablesAndAccruedExpense *float64 `json:"change_in_payables_and_accrued_expense"`
	ChangeInReceivables               *float64 `json:"change_in_receivables"`
	ChangeInWorkingCapital            *float64 `json:"change_in_working_capital"`
	ChangesInAccountReceivables       *float64 `json:"changes_in_account_receivables"`
	ChangesInCash                     *float64 `json:"changes_in_cash"`
	CommonStockIssuance               *float64 `json:"common_stock_issuance"`
	CommonStockPayments               *float64 `json:"common_stock_payments"`
	CurrencyID                        *string  `json:"currency_id"`
	DeferredIncomeTax                 *float64 `json:"deferred_income_tax"`
	DeferredTax                       *float64 `json:"deferred_tax"`
	DepreciationAmortizationDepletion *float64 `json:"depreciation_amortization_depletion"`
	DepreciationAndAmortization       *float64 `json:"depreciation_and_amortization"`
	DomesticSales                     *float64 `json:"domestic_sales"`
	EndCashPosition                   *float64 `json:"end_cash_position"`
	FileDate                          *string  `json:"file_date"`
	FinancingCashFlow                 *float64 `json:"financing_cash_flow"`
	FiscalYearEnd                     *string  `json:"fiscal_year_end"`
	ForeignSales                      *float64 `json:"foreign_sales"`
	FreeCashFlow                      *float64 `json:"free_cash_flow"`
	IncomeTaxPaidSupplementalData     *float64 `json:"income_tax_paid_supplemental_data"`
	InterestPaidSupplementalData      *float64 `json:"int64erest_paid_supplemental_data"`
	InvestingCashFlow                 *float64 `json:"investing_cash_flow"`
	IssuanceOfCapitalStock            *float64 `json:"issuance_of_capital_stock"`
	NetBusinessPurchaseAndSale        *float64 `json:"net_business_purchase_and_sale"`
	NetCommonStockIssuance            *float64 `json:"net_common_stock_issuance"`
	NetIncome                         *float64 `json:"net_income"`
	NetIncomeFromContinuingOperations *float64 `json:"net_income_from_continuing_operations"`
	NetIntangiblesPurchaseAndSale     *float64 `json:"net_int64angibles_purchase_and_sale"`
	NetInvestmentPurchaseAndSale      *float64 `json:"net_investment_purchase_and_sale"`
	NetIssuancePaymentsOfDebt         *float64 `json:"net_issuance_payments_of_debt"`
	NetOtherFinancingCharges          *float64 `json:"net_other_financing_charges"`
	NetOtherInvestingChanges          *float64 `json:"net_other_investing_changes"`
	NetPPEPurchaseAndSale             *float64 `json:"net_p_p_e_purchase_and_sale"`
	NetShortTermDebtIssuance          *float64 `json:"net_short_term_debt_issuance"`
	NumberOfShareHolders              *int64   `json:"number_of_share_holders"`
	OperatingCashFlow                 *float64 `json:"operating_cash_flow"`
	OtherNonCashItems                 *float64 `json:"other_non_cash_items"`
	Period                            *string  `json:"period"`
	PeriodEndingDate                  *string  `json:"period_ending_date"`
	PurchaseOfBusiness                *float64 `json:"purchase_of_business"`
	PurchaseOfIntangibles             *float64 `json:"purchase_of_int64angibles"`
	PurchaseOfInvestment              *float64 `json:"purchase_of_investment"`
	PurchaseOfPPE                     *float64 `json:"purchase_of_p_p_e"`
	ReportType                        *string  `json:"report_type"`
	RepurchaseOfCapitalStock          *float64 `json:"repurchase_of_capital_stock"`
	SaleOfInvestment                  *float64 `json:"sale_of_investment"`
	StockBasedCompensation            *float64 `json:"stock_based_compensation"`
}

type CashFlowStatements

type CashFlowStatements []map[string]CashFlowStatement

func (*CashFlowStatements) UnmarshalJSON

func (cfs *CashFlowStatements) UnmarshalJSON(data []byte) error

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) CancelOrder

func (tc *Client) CancelOrder(orderId int) error

func (*Client) ChangeOrder

func (tc *Client) ChangeOrder(orderId int, order Order) error

func (*Client) GetAccountBalances

func (tc *Client) GetAccountBalances() (*AccountBalances, error)

func (*Client) GetAccountCostBasis

func (tc *Client) GetAccountCostBasis() ([]*ClosedPosition, error)

func (*Client) GetAccountHistory

func (tc *Client) GetAccountHistory(limit int) ([]*Event, error)

func (*Client) GetAccountPositions

func (tc *Client) GetAccountPositions() ([]*Position, error)

func (*Client) GetCompanyInfo

func (tc *Client) GetCompanyInfo(symbols []string) (GetCompanyInfoResponse, error)

Get company fundamentals.

func (*Client) GetCorporateActions

func (tc *Client) GetCorporateActions(symbols []string) (GetCorporateActionsResponse, error)

Get corporate actions.

func (*Client) GetCorporateCalendars

func (tc *Client) GetCorporateCalendars(symbols []string) (
	GetCorporateCalendarsResponse, error)

Get corporate calendars.

func (*Client) GetDividends

func (tc *Client) GetDividends(symbols []string) (GetDividendsResponse, error)

Get dividends.

func (*Client) GetEasyToBorrow

func (tc *Client) GetEasyToBorrow() ([]Security, error)

Get the securities on the Easy-to-Borrow list.

func (*Client) GetFinancials

func (tc *Client) GetFinancials(symbols []string) (GetFinancialsResponse, error)

Get financial reports.

func (*Client) GetMarketCalendar

func (tc *Client) GetMarketCalendar(year int, month time.Month) ([]MarketCalendar, error)

Get the market calendar for a given month.

func (*Client) GetMarketState

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

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

func (*Client) GetOpenOrders

func (tc *Client) GetOpenOrders() ([]*Order, error)

func (*Client) GetOptionChain

func (tc *Client) GetOptionChain(symbol string, expiration time.Time) ([]*Quote, error)

Get an option chain.

func (*Client) GetOptionExpirationDates

func (tc *Client) GetOptionExpirationDates(symbol string) ([]time.Time, error)

Get an option's expiration dates.

func (*Client) GetOptionStrikes

func (tc *Client) GetOptionStrikes(symbol string, expiration time.Time) ([]float64, error)

Get an option's expiration dates.

func (*Client) GetOrderStatus

func (tc *Client) GetOrderStatus(orderId int) (*Order, error)

func (*Client) GetPriceStatistics

func (tc *Client) GetPriceStatistics(symbols []string) (GetPriceStatisticsResponse, error)

Get price statistics.

func (*Client) GetQuotes

func (tc *Client) GetQuotes(symbols []string) ([]*Quote, error)

func (*Client) GetRatios

func (tc *Client) GetRatios(symbols []string) (GetRatiosResponse, error)

Get corporate ratios.

func (*Client) GetTimeSales

func (tc *Client) GetTimeSales(
	symbol string, interval Interval,
	start, end time.Time) ([]TimeSale, error)

Return daily, minute, or tick price bars for the given symbol. Tick data is available for the past 5 days, minute data for the past 20 days, and daily data since 1980-01-01. NOTE: The results are split, but not dividend-adjusted. https://developer.tradier.com/documentation/markets/get-history https://developer.tradier.com/documentation/markets/get-timesales

func (*Client) LookupSecurities

func (tc *Client) LookupSecurities(
	types []SecurityType, exchanges []string, query string) (
	[]Security, error)

Get a list of symbols matching the given parameters.

func (*Client) PlaceOrder

func (tc *Client) PlaceOrder(order Order) (int, error)

func (*Client) PreviewOrder

func (tc *Client) PreviewOrder(order Order) (*OrderPreview, error)

func (*Client) SelectAccount

func (tc *Client) SelectAccount(account string)

func (*Client) StreamMarketEvents

func (tc *Client) StreamMarketEvents(
	symbols []string, filter []Filter) (io.ReadCloser, error)

Subscribe to a stream of market events for the given symbols. Filter restricts the type of events streamed and can include: summary, trade, quote, timesale. If nil then all events are streamed. https://developer.tradier.com/documentation/streaming/get-markets-events

type ClientParams

type ClientParams struct {
	Endpoint   string
	AuthToken  string
	Client     *http.Client
	Backoff    backoff.BackOff
	RetryLimit int
	Account    string
}

func DefaultParams

func DefaultParams(authToken string) ClientParams

DefaultParams returns ClientParams initialized with default values.

type ClosedPosition

type ClosedPosition struct {
	CloseDate       DateTime `json:"close_date"`
	Cost            float64
	GainLoss        float64  `json:"gain_loss"`
	GainLossPercent float64  `json:"gain_loss_percent"`
	OpenDate        DateTime `json:"open_date"`
	Proceeds        float64
	Quantity        float64
	Symbol          string
	Term            int
}

type CompanyHeadquarter

type CompanyHeadquarter struct {
	AddressLine1 *string `json:"address_line1"`
	City         *string `json:"city"`
	Country      *string `json:"country"`
	Fax          *string `json:"fax"`
	Homepage     *string `json:"homepage"`
	Phone        *string `json:"phone"`
	PostalCode   *string `json:"postal_code"`
	Province     *string `json:"province"`
}

type CompanyInfoResult

type CompanyInfoResult struct {
	ID     string `json:"id"`
	Tables struct {
		AssetClassification           *AssetClassification           `json:"asset_classification"`
		CompanyProfile                *CompanyProfile                `json:"company_profile"`
		HistoricalAssetClassification *HistoricalAssetClassification `json:"historical_asset_classification"`
		LongDescriptions              *string                        `json:"long_descriptions"`
		OwnershipDetails              OwnershipDetails               `json:"ownership_details"`
		OwnershipSummary              *OwnershipSummary              `json:"ownership_summary"`
		ShareClass                    *ShareClass                    `json:"share_class"`
		ShareClassProfile             *ShareClassProfile             `json:"share_class_profile"`
	} `json:"tables"`
	Type string `json:"type"`
}

type CompanyProfile

type CompanyProfile struct {
	TotalEmployeeNumberAsOfDate *string             `json:"TotalEmployeeNumber.asOfDate"`
	CompanyID                   *string             `json:"company_id"`
	ContactEmail                *string             `json:"contact_email"`
	Headquarter                 *CompanyHeadquarter `json:"headquarter"`
	ShortDescription            *string             `json:"short_description"`
	TotalEmployeeNumber         *int64              `json:"total_employee_number"`
}

type CorporateCalendar

type CorporateCalendar []CorporateEvent

If there is only a single event, then tradier sends back an object, but if there are multiple events, then it sends a list of objects...

func (*CorporateCalendar) UnmarshalJSON

func (cc *CorporateCalendar) UnmarshalJSON(data []byte) error

type CorporateEvent

type CorporateEvent struct {
	BeginDateTime *string `json:"begin_date_time"`
	CompanyID     *string `json:"company_id"`
	EndDateTime   *string `json:"end_date_time"`
	Event         *string `json:"event"`
	EventType     *int64  `json:"event_type"`
	TimeZone      *string `json:"time_zone,omitempty"`
}

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 EarningReport

type EarningReport struct {
	AccessionNumber                     *string  `json:"accession_number"`
	AsOfDate                            *string  `json:"as_of_date"`
	BasicAverageShares                  *float64 `json:"basic_average_shares"`
	BasicContinuousOperations           *float64 `json:"basic_continuous_operations"`
	BasicEPS                            *float64 `json:"basic_e_p_s"`
	ContinuingAndDiscontinuedBasicEPS   *float64 `json:"continuing_and_discontinued_basic_e_p_s"`
	ContinuingAndDiscontinuedDilutedEPS *float64 `json:"continuing_and_discontinued_diluted_e_p_s"`
	CurrencyID                          *string  `json:"currency_id"`
	DilutedAverageShares                *float64 `json:"diluted_average_shares"`
	DilutedContinuousOperations         *float64 `json:"diluted_continuous_operations"`
	DilutedEPS                          *float64 `json:"diluted_e_p_s"`
	DividendPerShare                    *float64 `json:"dividend_per_share"`
	FileDate                            *string  `json:"file_date"`
	FiscalYearEnd                       *string  `json:"fiscal_year_end"`
	FormType                            *string  `json:"form_type"`
	NormalizedBasicEPS                  *float64 `json:"normalized_basic_e_p_s"`
	NormalizedDilutedEPS                *float64 `json:"normalized_diluted_e_p_s"`
	Period                              *string  `json:"period"`
	PeriodEndingDate                    *string  `json:"period_ending_date"`
	ReportType                          *string  `json:"report_type"`
	ShareClassID                        *string  `json:"share_class_id"`
}

type EarningReports

type EarningReports []map[string]EarningReport

func (*EarningReports) UnmarshalJSON

func (ers *EarningReports) UnmarshalJSON(data []byte) error

type EarningsRatiosRestate

type EarningsRatiosRestate struct {
	AsOfDate             *string  `json:"as_of_date"`
	DPSGrowth            *float64 `json:"d_p_s_growth"`
	DilutedContEPSGrowth *float64 `json:"diluted_cont_e_p_s_growth"`
	DilutedEPSGrowth     *float64 `json:"diluted_e_p_s_growth"`
	FiscalYearEnd        *string  `json:"fiscal_year_end"`
	Period               *string  `json:"period"`
	ReportType           *string  `json:"report_type"`
	ShareClassID         *string  `json:"share_class_id"`
}

type Event

type Event struct {
	Amount     float64
	Date       DateTime
	Type       string
	Trade      Trade
	Adjustment Adjustment
}

type Filter

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

type FinancialStatementsRestate

type FinancialStatementsRestate struct {
	AsOfDate          *string             `json:"as_of_date"`
	BalanceSheet      BalanceSheetResults `json:"balance_sheet"`
	CashFlowStatement CashFlowStatements  `json:"cash_flow_statement"`
	CompanyID         *string             `json:"company_id"`
	IncomeStatement   IncomeStatements    `json:"income_statement"`
}

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 GetCompanyInfoResponse

type GetCompanyInfoResponse []struct {
	Error   string
	Request string              `json:"request"`
	Results []CompanyInfoResult `json:"results"`
	Type    string              `json:"type"`
}

type GetCorporateActionsResponse

type GetCorporateActionsResponse []struct {
	Error   string
	Request string `json:"request"`
	Results []struct {
		ID     string `json:"id"`
		Tables struct {
			MergersAndAcquisitions MergersAndAcquisitions `json:"mergers_and_acquisitions"`
			StockSplits            StockSplits            `json:"stock_splits"`
		} `json:"tables"`
		Type string `json:"type"`
	} `json:"results"`
	Type string `json:"type"`
}

type GetCorporateCalendarsResponse

type GetCorporateCalendarsResponse []struct {
	Error   string
	Request string `json:"request"`
	Results []struct {
		ID     string `json:"id"`
		Tables struct {
			CorporateCalendars *CorporateCalendar `json:"corporate_calendars"`
		} `json:"tables"`
		Type string `json:"type"`
	} `json:"results"`
	Type string `json:"type"`
}

type GetDividendsResponse

type GetDividendsResponse []struct {
	Error   string
	Request string `json:"request"`
	Results []struct {
		ID     string `json:"id"`
		Tables struct {
			CashDividends CashDividends `json:"cash_dividends"`
		} `json:"tables"`
		Type string `json:"type"`
	} `json:"results"`
	Type string `json:"type"`
}

type GetFinancialsResponse

type GetFinancialsResponse []struct {
	Error   string
	Request string `json:"request"`
	Results []struct {
		ID     string `json:"id"`
		Tables struct {
			FinancialStatementsRestate *FinancialStatementsRestate  `json:"financial_statements_restate"`
			Segmentation               map[string]Segmentation      `json:"segmentation"`
			EarningReportsAOR          EarningReports               `json:"earning_reports_a_o_r"`
			EarningReportsRestate      EarningReports               `json:"earning_reports_restate"`
			HistoricalReturns          map[string]HistoricalReturns `json:"historical_returns"`
		} `json:"tables"`
		Type string `json:"type"`
	} `json:"results"`
	Type string `json:"type"`
}

type GetPriceStatisticsResponse

type GetPriceStatisticsResponse []struct {
	Error   string
	Request string `json:"request"`
	Results []struct {
		ID     string `json:"id"`
		Tables struct {
			PriceStatistics map[string]PriceStatistics `json:"price_statistics"`
			TrailingReturns map[string]TrailingReturns `json:"trailing_returns"`
		} `json:"tables"`
		Type string `json:"type"`
	} `json:"results"`
	Type string `json:"type"`
}

type GetRatiosResponse

type GetRatiosResponse []struct {
	Error   string
	Request string `json:"request"`
	Results []struct {
		ID     string `json:"id"`
		Tables struct {
			OperationRatiosAOR     OperationRatios                  `json:"operation_ratios_a_o_r"`
			OperationRatiosRestate OperationRatios                  `json:"operation_ratios_restate"`
			AlphaBeta              map[string]AlphaBeta             `json:"alpha_beta"`
			EarningsRatiosRestate  map[string]EarningsRatiosRestate `json:"earnings_ratios_restate"`
			ValuationRatios        *ValuationRatios                 `json:"valuation_ratios"`
		} `json:"tables"`
		Type string `json:"type"`
	} `json:"results"`
	Type string `json:"type"`
}

type Greeks

type Greeks struct {
	Delta  float64
	Gamma  float64
	Theta  float64
	Vega   float64
	Rho    float64
	BidIV  float64 `json:"bid_iv"`
	MidIV  float64 `json:"mid_iv"`
	AskIV  float64 `json:"ask_iv"`
	SmvVol float64 `json:"smv_vol"`
}

type HistoricalAssetClassification

type HistoricalAssetClassification struct {
	AsOfDate                     *string  `json:"as_of_date"`
	CompanyID                    *string  `json:"company_id"`
	FinancialHealthGrade         *string  `json:"financial_health_grade"`
	GrowthScore                  *float64 `json:"growth_score"`
	MorningstarEconomySphereCode *int64   `json:"morningstar_economy_sphere_code"`
	MorningstarIndustryCode      *int64   `json:"morningstar_industry_code"`
	MorningstarIndustryGroupCode *int64   `json:"morningstar_industry_group_code"`
	MorningstarSectorCode        *int64   `json:"morningstar_sector_code"`
	ProfitabilityGrade           *string  `json:"profitability_grade"`
	SizeScore                    *float64 `json:"size_score"`
	StockType                    *int64   `json:"stock_type"`
	StyleBox                     *int64   `json:"style_box"`
	StyleScore                   *float64 `json:"style_score"`
	ValueScore                   *float64 `json:"value_score"`
}

type HistoricalReturns

type HistoricalReturns struct {
	AsOfDate     *string  `json:"as_of_date"`
	Period       *string  `json:"period"`
	ShareClassID *string  `json:"share_class_id"`
	TotalReturn  *float64 `json:"total_return"`
}

type IncomeStatement

type IncomeStatement struct {
	AccessionNumber                                     *string  `json:"accession_number"`
	CostOfRevenue                                       *float64 `json:"cost_of_revenue"`
	CurrencyID                                          *string  `json:"currency_id"`
	EBIT                                                *float64 `json:"e_b_i_t"`
	EBITDA                                              *float64 `json:"e_b_i_t_d_a"`
	FileDate                                            *string  `json:"file_date"`
	FiscalYearEnd                                       *string  `json:"fiscal_year_end"`
	FormType                                            *string  `json:"form_type"`
	GrossProfit                                         *float64 `json:"gross_profit"`
	InterestExpense                                     *float64 `json:"int64erest_expense"`
	InterestExpenseNonOperating                         *float64 `json:"int64erest_expense"`
	InterestIncome                                      *float64 `json:"int64erest_income"`
	InterestIncomeNonOperating                          *float64 `json:"int64erest_income_non_operating"`
	InterestAndSimilarIncome                            *float64 `json:"int64erestand_similar_income"`
	NetIncome                                           *float64 `json:"net_income"`
	NetIncomeCommonStockholders                         *float64 `json:"net_income_common_stockholders"`
	NetIncomeContinuousOperations                       *float64 `json:"net_income_continuous_operations"`
	NetIncomeFromContinuingAndDiscontinuedOperation     *float64 `json:"net_income_from_continuing_and_discontinued_operation"`
	NetIncomeFromContinuingOperationNetMinorityInterest *float64 `json:"net_income_from_continuing_operation_net_minority_int64erest"`
	NetIncomeIncludingNoncontrollingInterests           *float64 `json:"net_income_including_noncontrolling_int64erests"`
	NetInterestIncome                                   *float64 `json:"net_int64erest_income"`
	NetNonOperatingInterestIncomeExpense                *float64 `json:"net_non_operating_int64erest_income_expense"`
	NonOperatingExpenses                                *float64 `json:"non_operating_expenses"`
	NonOperatingIncome                                  *float64 `json:"non_operating_income"`
	NormalizedEBITDA                                    *float64 `json:"normalized_e_b_i_t_d_a"`
	NormalizedIncome                                    *float64 `json:"normalized_income"`
	NumberOfShareHolders                                *int64   `json:"number_of_share_holders"`
	OperatingExpense                                    *float64 `json:"operating_expense"`
	OperatingIncome                                     *float64 `json:"operating_income"`
	OperatingRevenue                                    *float64 `json:"operating_revenue"`
	OtherIncomeExpense                                  *float64 `json:"other_income_expense"`
	Period                                              *string  `json:"period"`
	PeriodEndingDate                                    *string  `json:"period_ending_date"`
	PretaxIncome                                        *float64 `json:"pretax_income"`
	ReconciledCostOfRevenue                             *float64 `json:"reconciled_cost_of_revenue"`
	ReconciledDepreciation                              *float64 `json:"reconciled_depreciation"`
	ReportType                                          *string  `json:"report_type"`
	ResearchAndDevelopment                              *float64 `json:"research_and_development"`
	SellingGeneralAndAdministration                     *float64 `json:"selling_general_and_administration"`
	TaxEffectOfUnusualItems                             *float64 `json:"tax_effect_of_unusual_items"`
	TaxProvision                                        *float64 `json:"tax_provision"`
	TaxRateForCalcs                                     *float64 `json:"tax_rate_for_calcs"`
	TotalExpenses                                       *float64 `json:"total_expenses"`
	TotalRevenue                                        *float64 `json:"total_revenue"`
}

type IncomeStatements

type IncomeStatements []map[string]IncomeStatement

func (*IncomeStatements) UnmarshalJSON

func (is *IncomeStatements) UnmarshalJSON(data []byte) 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 Margin

type Margin struct {
	FedCall           int     `json:"fed_call"`
	MaintenanceCall   int     `json:"maintenance_call"`
	OptionBuyingPower float64 `json:"option_buying_power"`
	StockBuyingPower  float64 `json:"stock_buying_power"`
	StockShortValue   float64 `json:"stock_short_value"`
	Sweep             int
}

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 MarketEventStream

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

MarketEventStream scans the newline-delimited market stream sent by Tradier and decodes each event into a StreamEvent.

func NewMarketEventStream

func NewMarketEventStream(input io.ReadCloser, output chan *StreamEvent) *MarketEventStream

func (*MarketEventStream) Stop

func (mes *MarketEventStream) Stop()

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 MergerAndAcquisition

type MergerAndAcquisition struct {
	AcquiredCompanyID *string  `json:"acquired_company_id"`
	CashAmount        *float64 `json:"cash_amount"`
	CurrencyID        *string  `json:"currency_id"`
	EffectiveDate     *string  `json:"effective_date"`
	Notes             *string  `json:"notes"`
	ParentCompanyID   *string  `json:"parent_company_id"`
}

type MergersAndAcquisitions

type MergersAndAcquisitions []MergerAndAcquisition

func (*MergersAndAcquisitions) UnmarshalJSON

func (maq *MergersAndAcquisitions) UnmarshalJSON(data []byte) error

type NAICS

type NAICS []int64

func (*NAICS) UnmarshalJSON

func (n *NAICS) UnmarshalJSON(data []byte) error

type OpenOrders

type OpenOrders []*Order

If there is only a single event, then tradier sends back an object, but if there are multiple events, then it sends a list of objects...

func (*OpenOrders) UnmarshalJSON

func (oo *OpenOrders) UnmarshalJSON(data []byte) error

type OperationRatio

type OperationRatio struct {
	AsOfDate                      *string  `json:"as_of_date"`
	AssetsTurnover                *float64 `json:"assets_turnover"`
	CapExSalesRatio               *float64 `json:"cap_ex_sales_ratio"`
	CashConversionCycle           *float64 `json:"cash_conversion_cycle"`
	CommonEquityToAssets          *float64 `json:"common_equity_to_assets"`
	CompanyID                     *string  `json:"company_id"`
	CurrentRatio                  *float64 `json:"current_ratio"`
	DaysInInventory               *float64 `json:"days_in_inventory"`
	DaysInPayment                 *float64 `json:"days_in_payment"`
	DaysInSales                   *float64 `json:"days_in_sales"`
	DebtToAssets                  *float64 `json:"debt_to_assets"`
	EBITDAMargin                  *float64 `json:"e_b_i_t_d_a_margin"`
	EBITMargin                    *float64 `json:"e_b_i_t_margin"`
	FCFNetIncomeRatio             *float64 `json:"f_c_f_net_income_ratio"`
	FCFSalesRatio                 *float64 `json:"f_c_f_sales_ratio"`
	FinancialLeverage             *float64 `json:"financial_leverage"`
	FiscalYearEnd                 *string  `json:"fiscal_year_end"`
	FixAssetsTurnover             *float64 `json:"fix_assets_turonver"`
	GrossMargin                   *float64 `json:"gross_margin"`
	InterestCoverage              *float64 `json:"int64erest_coverage"`
	InventoryTurnover             *float64 `json:"inventory_turnover"`
	LongTermDebtEquityRatio       *float64 `json:"long_term_debt_equity_ratio"`
	LongTermDebtTotalCapitalRatio *float64 `json:"long_term_debt_total_capital_ratio"`
	NetIncomeGrowth               *float64 `json:"net_income_growth"`
	NetIncomeContOpsGrowth        *float64 `json:"net_income_cont_ops_growth"`
	NetMargin                     *float64 `json:"net_margin"`
	NormalizedNetProfitMargin     *float64 `json:"normalized_net_profit_margin"`
	NormalizedROIC                *float64 `json:"normalized_r_o_i_c"`
	OperationIncomeGrowth         *float64 `json:"operation_income_growth"`
	OperationMargin               *float64 `json:"operation_margin"`
	PaymentTurnover               *float64 `json:"payment_turnover"`
	Period                        *string  `json:"period"`
	PretaxMargin                  *float64 `json:"pretax_margin"`
	QuickRatio                    *float64 `json:"quick_ratio"`
	ROA                           *float64 `json:"r_o_a"`
	ROE                           *float64 `json:"r_o_e"`
	ROIC                          *float64 `json:"r_o_i_c"`
	ReceivableTurnover            *float64 `json:"receivable_turnover"`
	ReportType                    *string  `json:"report_type"`
	SalesPerEmployee              *float64 `json:"sales_per_employee"`
	TaxRate                       *float64 `json:"tax_rate"`
	TotalDebtEquityRatio          *float64 `json:"total_debt_equity_ratio"`
}

type OperationRatios

type OperationRatios []map[string]OperationRatio

func (*OperationRatios) UnmarshalJSON

func (ors *OperationRatios) UnmarshalJSON(data []byte) error

type Order

type Order struct {
	Id                int
	Type              string
	Symbol            string
	OptionSymbol      string `json:"option_symbol"`
	Side              string
	Quantity          float64
	Status            string
	Duration          string
	Price             float64
	StopPrice         float64  `json:"stop_price"`
	OptionType        string   `json:"option_type"`
	ExpirationDate    DateTime `json:"expiration_date"`
	Exchange          string   `json:"exch"`
	AverageFillPrice  float64  `json:"avg_fill_price"`
	ExecutedQuantity  float64  `json:"exec_quantity"`
	ExecutionExchange string   `json:"exec_exch"`
	LastFillPrice     float64  `json:"last_fill_price"`
	LastFillQuantity  float64  `json:"last_fill_quantity"`
	RemainingQuantity float64  `json:"remaining_quantity"`
	CreateDate        DateTime `json:"create_date"`
	TransactionDate   DateTime `json:"transaction_date"`
	Class             string
	NumLegs           int `json:"num_legs"`
	Legs              []Order
	Strategy          string
}

type OrderPreview

type OrderPreview struct {
	Commission    float64
	Cost          float64
	ExtendedHours bool `json:"extended_hours"`
	Fees          float64
	MarginChange  float64 `json:"margin_change"`
	Quantity      float64
	Status        string
}

type OwnershipDetail

type OwnershipDetail struct {
	AsOfDate              *string  `json:"as_of_date"`
	CurrencyOfMarketValue *string  `json:"currencyof_market_value"`
	MarketValue           *int64   `json:"market_value"`
	NumberOfShares        *float64 `json:"number_of_shares"`
	OwnerCIK              *int64   `json:"owner_c_i_k"`
	OwnerID               *string  `json:"owner_id"`
	OwnerName             *string  `json:"owner_name"`
	OwnerType             *int64   `json:"owner_type,string"`
	PercentageInPortfolio *float64 `json:"percentage_in_portfolio"`
	PercentageOwnership   *float64 `json:"percentage_ownership"`
	ShareChange           *int64   `json:"share_change"`
	ShareClassID          *string  `json:"share_class_id"`
}

type OwnershipDetails

type OwnershipDetails []OwnershipDetail

func (*OwnershipDetails) UnmarshalJSON

func (ods *OwnershipDetails) UnmarshalJSON(data []byte) error

type OwnershipSummary

type OwnershipSummary struct {
	AsOfDate                                     *string            `json:"as_of_date"`
	DaysToCoverShort                             map[string]float64 `json:"days_to_cover_short"`
	Float                                        *int64             `json:"float"`
	InsiderPercentOwned                          *float64           `json:"insider_percent_owned"`
	InsiderSharesBought                          *int64             `json:"insider_shares_bought"`
	InsiderSharesOwned                           *int64             `json:"insider_shares_owned"`
	InsiderSharesSold                            *int64             `json:"insider_shares_sold"`
	InstitutionHolderNumber                      *int64             `json:"institution_holder_number"`
	InstitutionSharesBought                      *int64             `json:"institution_shares_bought"`
	InstitutionSharesHeld                        *int64             `json:"institution_shares_held"`
	InstitutionSharesSold                        *int64             `json:"institution_shares_sold"`
	NumberOfInsiderBuys                          *int64             `json:"number_of_insider_buys"`
	NumberOfInsiderSellers                       *int64             `json:"number_of_insider_sellers"`
	ShareClassID                                 *string            `json:"share_class_id"`
	ShareClassLevelSharesOutstanding             *int64             `json:"share_class_level_shares_outstanding"`
	ShareClassLevelSharesOutstandingBalanceSheet *int64             `json:"share_class_level_shares_outstanding_balance_sheet"`
	ShareClassLevelSharesOutstandingInterim      *int64             `json:"share_class_level_shares_outstanding_interim"`
	ShareClassLevelTreasuryShareOutstanding      *int64             `json:"share_class_level_treasury_share_outstanding"`
	SharesOutstanding                            *int64             `json:"shares_outstanding"`
	SharesOutstandingWithBalanceSheetEndingDate  *string            `json:"shares_outstanding_with_balance_sheet_ending_date"`
	ShortInterest                                *int64             `json:"short_interest"`
	ShortInterestsPercentageChange               map[string]float64 `json:"short_interests_percentage_change"`
	ShortPercentageOfFloat                       *float64           `json:"short_percentage_of_float"`
	ShortPercentageOfSharesOutstanding           *float64           `json:"short_percentage_of_shares_outstanding"`
}

type PDT

type PDT struct {
	DayTradeBuyingPower float64 `json:"day_trade_buying_power"`
	FedCall             int     `json:"fed_call"`
	MaintenanceCall     int     `json:"maintenance_call"`
	OptionBuyingPower   float64 `json:"option_buying_power"`
	StockBuyingPower    float64 `json:"stock_buying_power"`
	StockShortValue     float64 `json:"stock_short_value"`
}

type Position

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

type PriceStatistics

type PriceStatistics struct {
	ShareClassID              *string  `json:"share_class_id"`
	AsOfDate                  *string  `json:"as_of_date"`
	Period                    *string  `json:"period"`
	ArithmeticMean            *float64 `json:"arithmetic_mean"`
	AverageVolume             *float64 `json:"average_volume"`
	Best3MonthTotalReturn     *float64 `json:"best3_month_return_total"`
	ClosePriceToMovingAverage *float64 `json:"close_price_to_moving_average"`
	HighPrice                 *float64 `json:"high_price"`
	LowPrice                  *float64 `json:"low_price"`
	MovingAveragePrice        *float64 `json:"moving_average_price"`
	PercentageBelowHighPrice  *float64 `json:"percentage_below_high_price"`
	StandardDeviation         *float64 `json:"standard_deviation"`
	TotalVolume               *float64 `json:"total_volume"`
	Worst3MonthTotalReturn    *float64 `json:"worst3_month_total_return"`
}

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"`
	Greeks           Greeks
}

type QuoteEvent

type QuoteEvent struct {
	Symbol      string
	Bid         float64
	BidSize     int64  `json:"bidsz"`
	BidExchange string `json:"bidexch"`
	BidDateMs   int64  `json:"biddate,string"`
	Ask         float64
	AskSize     int64  `json:"asksz"`
	AskExchange string `json:"askexch"`
	AskDateMs   int64  `json:"askdate,string"`
}

func DecodeQuote

func DecodeQuote(e *StreamEvent) (*QuoteEvent, error)

type SIC

type SIC []int64

func (*SIC) UnmarshalJSON

func (n *SIC) UnmarshalJSON(data []byte) error

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 Segmentation

type Segmentation struct {
	AsOfDate                    *string  `json:"as_of_date"`
	CompanyID                   *string  `json:"company_id"`
	DepreciationAndAmortization *float64 `json:"depreciation_and_amortization"`
	OperatingIncome             *float64 `json:"operating_income"`
	OperatingRevenue            *float64 `json:"operating_revenue"`
	Period                      *string  `json:"period"`
	TotalAssets                 *float64 `json:"total_assets"`
}

type ShareClass

type ShareClass struct {
	CompanyID           *string `json:"company_id"`
	CUSIP               *string `json:"c_u_s_i_p"`
	CurrencyID          *string `json:"currency_id"`
	DelistingDate       *string `json:"delisting_date"`
	ExchangeID          *string `json:"exchange_id"`
	IPODate             *string `json:"i_p_o_date"`
	ISIN                *string `json:"i_s_i_n"`
	InvestmentID        *string `json:"investment_id"`
	IsDepositaryReceipt *bool   `json:"is_depositary_receipt"`
	IsDirectInvest      *bool   `json:"is_direct_invest"`
	IsDividendReinvest  *bool   `json:"is_dividend_reinvest"`
	IsPrimaryShare      *bool   `json:"is_primary_share"`
	MIC                 *string `json:"m_i_c"`
	SEDOL               *string `json:"s_e_d_o_l"`
	SecurityType        *string `json:"security_type"`
	ShareClassID        *string `json:"share_class_id"`
	ShareClassStatus    *string `json:"share_class_status"`
	Symbol              *string `json:"symbol"`
	TradingStatus       *bool   `json:"trading_status"`
	Valoren             *string `json:"valoren"`
}

type ShareClassProfile

type ShareClassProfile struct {
	EnterpriseValueAsOfDate                     *string `json:"EnterpriseValue.asOfDate"`
	MarketCapAsOfDate                           *string `json:"MarketCap.asOfDate"`
	SharesOutstandingAsOfDate                   *string `json:"SharesOutstanding.asOfDate"`
	EnterpriseValue                             *int64  `json:"enterprise_value"`
	MarketCap                                   *int64  `json:"market_cap"`
	ShareClassID                                *string `json:"share_class_id"`
	ShareClassLevelSharesOutstanding            *int64  `json:"share_class_level_shares_outstanding"`
	SharesOutstanding                           *int64  `json:"shares_outstanding"`
	SharesOutstandingWithBalanceSheetEndingDate *string `json:"shares_outstanding_with_balance_sheet_ending_date"`
}

type StdLogger

type StdLogger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}
var Logger StdLogger = log.New(ioutil.Discard, "[go-tradier] ", log.LstdFlags)

type StockSplit

type StockSplit struct {
	AdjustmentFactor *float64 `json:"adjustment_factor"`
	ExDate           *string  `json:"ex_date"`
	ShareClassID     *string  `json:"share_class_id"`
	SplitFrom        *float64 `json:"split_from"`
	SplitTo          *float64 `json:"split_to"`
	SplitType        *string  `json:"split_type"`
}

type StockSplits

type StockSplits map[string]StockSplit

type StreamDemuxer

type StreamDemuxer struct {
	Quotes    func(quote *QuoteEvent)
	Trades    func(trade *TradeEvent)
	Summaries func(summary *SummaryEvent)
	TimeSales func(timeSale *TimeSaleEvent)
	Errors    func(err error)
}

StreamDemuxer demuxes the different types of messages in a market events stream.

func (*StreamDemuxer) Handle

func (sd *StreamDemuxer) Handle(event *StreamEvent)

func (*StreamDemuxer) HandleChan

func (sd *StreamDemuxer) HandleChan(events <-chan *StreamEvent)

type StreamEvent

type StreamEvent struct {
	Type    string
	Symbol  string
	Message json.RawMessage
	Error   error
}

StreamEvent is used to unmarshal stream events before they are demuxed. Message contains the remainder of the type-specific message.

StreamEvents can be demuxed into type-specific events using the StreamDemuxer.

type SummaryEvent

type SummaryEvent struct {
	Symbol        string
	Open          float64 `json:",string"`
	High          float64 `json:",string"`
	Low           float64 `json:",string"`
	PreviousClose float64 `json:"prevClose,string"`
}

func DecodeSummary

func DecodeSummary(e *StreamEvent) (*SummaryEvent, error)

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 TimeSaleEvent

type TimeSaleEvent struct {
	Symbol     string
	Exchange   string  `json:"exch"`
	Bid        float64 `json:",string"`
	Ask        float64 `json:",string"`
	Last       float64 `json:",string"`
	Size       int64   `json:",string"`
	DateMs     int64   `json:"date,string"`
	Seq        int64
	Flag       string
	Cancel     bool
	Correction bool
	Session    string
}

func DecodeTimeSale

func DecodeTimeSale(e *StreamEvent) (*TimeSaleEvent, error)

type Trade

type Trade struct {
	Commission  float64
	Description string
	Price       float64
	Quantity    float64
	Symbol      string
	TradeType   string `json:"trade_type"`
}

type TradeEvent

type TradeEvent struct {
	Symbol           string
	Exchange         string  `json:"exch"`
	Price            float64 `json:",string"`
	Last             float64 `json:",string"`
	Size             int64   `json:",string"`
	CumulativeVolume int64   `json:"cvol,string"`
	DateMs           int64   `json:"date,string"`
}

func DecodeTrade

func DecodeTrade(e *StreamEvent) (*TradeEvent, error)

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

type TrailingReturns

type TrailingReturns struct {
	ShareClassID *string  `json:"share_class_id"`
	AsOfDate     *string  `json:"as_of_date"`
	Period       *string  `json:"period"`
	TotalReturn  *float64 `json:"total_return"`
}

type ValuationRatios

type ValuationRatios struct {
	AsOfDate                       *string  `json:"as_of_date"`
	BookValuePerShare              *float64 `json:"book_value_per_share"`
	BookValueYield                 *float64 `json:"book_value_yield"`
	BuyBackYield                   *float64 `json:"buy_back_yield"`
	CFOPerShare                    *float64 `json:"c_f_o_per_share"`
	CFYield                        *float64 `json:"c_f_yield"`
	CashReturn                     *float64 `json:"cash_return"`
	DividendRate                   *float64 `json:"dividend_rate"`
	DividendYield                  *float64 `json:"dividend_yield"`
	EVToEBITDA                     *float64 `json:"e_v_to_e_b_i_t_d_a"`
	EarningYield                   *float64 `json:"earning_yield"`
	FCFPerShare                    *float64 `json:"f_c_f_per_share"`
	FCFRatio                       *float64 `json:"f_c_f_ratio"`
	FCFYield                       *float64 `json:"f_c_f_yield"`
	ForwardDividendYield           *float64 `json:"forward_dividend_yield"`
	ForwardEarningYield            *float64 `json:"forward_earning_yield"`
	ForwardPERatio                 *float64 `json:"forward_p_e_ratio"`
	NormalizedPERatio              *float64 `json:"normalized_p_e_ratio"`
	PBRatio                        *float64 `json:"p_b_ratio"`
	PCFRatio                       *float64 `json:"p_c_f_ratio"`
	PEGPayback                     *float64 `json:"p_e_g_payback"`
	PEGRatio                       *float64 `json:"p_e_g_ratio"`
	PERatio                        *float64 `json:"p_e_ratio"`
	PSRatio                        *float64 `json:"p_s_ratio"`
	PayoutRatio                    *float64 `json:"payout_ratio"`
	PriceChange1M                  *float64 `json:"price_change1_m"`
	PriceToEBITDA                  *float64 `json:"priceto_e_b_i_t_d_a"`
	RatioPE5YearAverage            *float64 `json:"ratio_p_e5_year_average"`
	SalesPerShare                  *float64 `json:"sales_per_share"`
	SalesYield                     *float64 `json:"sales_yield"`
	ShareClassID                   *string  `json:"share_class_id"`
	SustainableGrowthRate          *float64 `json:"sustainable_growth_rate"`
	TangibleBVPerShare3YearAvg     *float64 `json:"tangible_b_v_per_share3_yr_avg"`
	TangibleBVPerShare5YearAvg     *float64 `json:"tangible_b_v_per_share5_yr_avg"`
	TangibleBookValuePerShare      *float64 `json:"tangible_book_value_per_share"`
	TotalYield                     *float64 `json:"total_yield"`
	WorkingCapitalPerShare         *float64 `json:"working_capital_per_share"`
	WorkingCapitalPerShare3YearAvg *float64 `json:"working_capital_per_share3_yr_avg"`
	WorkingCapitalPerShare5YearAvg *float64 `json:"working_capital_per_share5_yr_avg"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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