Documentation
¶
Overview ¶
Package tradier implements a Client for using the Tradier API.
Index ¶
- Constants
- Variables
- func ParseTimeMs(tsMs string) (time.Time, error)
- func UnmarshalStreamEvent(buf []byte, se *StreamEvent) error
- type AccountBalances
- type Adjustment
- type AlphaBeta
- type AssetClassification
- type BalanceSheet
- type BalanceSheetResults
- type Cash
- type CashDividend
- type CashDividends
- type CashFlowStatement
- type CashFlowStatements
- type Client
- func (tc *Client) CancelOrder(orderId int) error
- func (tc *Client) ChangeOrder(orderId int, order Order) error
- func (tc *Client) GetAccountBalances() (*AccountBalances, error)
- func (tc *Client) GetAccountCostBasis() ([]*ClosedPosition, error)
- func (tc *Client) GetAccountHistory(limit int) ([]*Event, error)
- func (tc *Client) GetAccountPositions() ([]*Position, error)
- func (tc *Client) GetCompanyInfo(symbols []string) (GetCompanyInfoResponse, error)
- func (tc *Client) GetCorporateActions(symbols []string) (GetCorporateActionsResponse, error)
- func (tc *Client) GetCorporateCalendars(symbols []string) (GetCorporateCalendarsResponse, error)
- func (tc *Client) GetDividends(symbols []string) (GetDividendsResponse, error)
- func (tc *Client) GetEasyToBorrow() ([]Security, error)
- func (tc *Client) GetFinancials(symbols []string) (GetFinancialsResponse, error)
- func (tc *Client) GetMarketCalendar(year int, month time.Month) ([]MarketCalendar, error)
- func (tc *Client) GetMarketState() (MarketStatus, error)
- func (tc *Client) GetOpenOrders() ([]*Order, error)
- func (tc *Client) GetOptionChain(symbol string, expiration time.Time) ([]*Quote, error)
- func (tc *Client) GetOptionExpirationDates(symbol string) ([]time.Time, error)
- func (tc *Client) GetOptionStrikes(symbol string, expiration time.Time) ([]float64, error)
- func (tc *Client) GetOrderStatus(orderId int) (*Order, error)
- func (tc *Client) GetPriceStatistics(symbols []string) (GetPriceStatisticsResponse, error)
- func (tc *Client) GetQuote(symbol string) (*Quote, error)
- func (tc *Client) GetQuotes(symbols []string) ([]*Quote, error)
- func (tc *Client) GetRatios(symbols []string) (GetRatiosResponse, error)
- func (tc *Client) GetTimeSales(symbol string, interval Interval, start, end time.Time) ([]TimeSale, error)
- func (tc *Client) LookupSecurities(types []SecurityType, exchanges []string, query string) ([]Security, error)
- func (tc *Client) PlaceOrder(order Order) (int, error)
- func (tc *Client) PreviewOrder(order Order) (*OrderPreview, error)
- func (tc *Client) SelectAccount(account string)
- func (tc *Client) StreamMarketEvents(symbols []string, filter []Filter) (io.ReadCloser, error)
- type ClientParams
- type ClosedPosition
- type CompanyHeadquarter
- type CompanyInfoResult
- type CompanyProfile
- type CorporateCalendar
- type CorporateEvent
- type DateTime
- type EarningReport
- type EarningReports
- type EarningsRatiosRestate
- type Event
- type Filter
- type FinancialStatementsRestate
- type FloatOrNaN
- type GetCompanyInfoResponse
- type GetCorporateActionsResponse
- type GetCorporateCalendarsResponse
- type GetDividendsResponse
- type GetFinancialsResponse
- type GetPriceStatisticsResponse
- type GetRatiosResponse
- type Greeks
- type HistoricalAssetClassification
- type HistoricalReturns
- type IncomeStatement
- type IncomeStatements
- type Interval
- type Margin
- type MarketCalendar
- type MarketEventStream
- type MarketState
- type MarketStatus
- type MergerAndAcquisition
- type MergersAndAcquisitions
- type NAICS
- type OpenOrders
- type OperationRatio
- type OperationRatios
- type Order
- type OrderPreview
- type OwnershipDetail
- type OwnershipDetails
- type OwnershipSummary
- type PDT
- type Position
- type PriceStatistics
- type Quote
- type QuoteEvent
- type SIC
- type Security
- type SecurityType
- type Segmentation
- type ShareClass
- type ShareClassProfile
- type StdLogger
- type StockSplit
- type StockSplits
- type StreamDemuxer
- type StreamEvent
- type SummaryEvent
- type TimeSale
- type TimeSaleEvent
- type Trade
- type TradeEvent
- type TradierError
- type TrailingReturns
- type ValuationRatios
Constants ¶
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" )
const ( SandboxEndpoint = "https://sandbox.tradier.com" APIEndpoint = "https://api.tradier.com" StreamEndpoint = "https://stream.tradier.com" )
const (
// Error returned by Tradier if we make too big of a request.
ErrBodyBufferOverflow = "protocol.http.TooBigBody"
)
Variables ¶
var ( // ErrNoAccountSelected is returned if account-specific methods // are attempted to be used without selecting an account first. ErrNoAccountSelected = errors.New("no account selected") )
Functions ¶
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 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"` 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"` 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 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"` }
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"` 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 (*Client) GetAccountBalances ¶
func (tc *Client) GetAccountBalances() (*AccountBalances, error)
func (*Client) GetAccountCostBasis ¶
func (tc *Client) GetAccountCostBasis() ([]*ClosedPosition, error)
func (*Client) GetAccountPositions ¶
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 ¶
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 ¶
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 (*Client) GetOptionChain ¶
Get an option chain.
func (*Client) GetOptionExpirationDates ¶
Get an option's expiration dates.
func (*Client) GetOptionStrikes ¶
Get an option's expiration dates.
func (*Client) GetPriceStatistics ¶
func (tc *Client) GetPriceStatistics(symbols []string) (GetPriceStatisticsResponse, error)
Get price statistics.
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) PreviewOrder ¶
func (tc *Client) PreviewOrder(order Order) (*OrderPreview, error)
func (*Client) SelectAccount ¶
func (*Client) StreamMarketEvents ¶
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 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 DateTime ¶
DateTime wraps time.Time and adds flexible implementations for unmarshaling JSON in the different forms it appears in the Tradier API.
func (*DateTime) UnmarshalJSON ¶
type EarningReport ¶
type EarningReport struct { AccessionNumber *string `json:"accession_number"` AsOfDate *string `json:"as_of_date"` 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"` DilutedContinuousOperations *float64 `json:"diluted_continuous_operations"` DilutedEPS *float64 `json:"diluted_e_p_s"` 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"` }
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"` }
type Event ¶
type Event struct { Amount float64 Date DateTime Type string Trade Trade Adjustment Adjustment }
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
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 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 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 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"` 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 MarketCalendar ¶
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 MergerAndAcquisition ¶
type MergersAndAcquisitions ¶
type MergersAndAcquisitions []MergerAndAcquisition
func (*MergersAndAcquisitions) UnmarshalJSON ¶
func (maq *MergersAndAcquisitions) 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 OwnershipDetail ¶
type OwnershipDetail struct { AsOfDate *string `json:"as_of_date"` CurrencyOfMarketValue *string `json:"currencyof_market_value"` MarketValue *int64 `json:"market_value"` 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"` }
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"` InstitutionHolderNumber *int64 `json:"institution_holder_number"` NumberOfInsiderBuys *int64 `json:"number_of_insider_buys"` NumberOfInsiderSellers *int64 `json:"number_of_insider_sellers"` ShortInterest *int64 `json:"short_interest"` ShortInterestsPercentageChange map[string]float64 `json:"short_interests_percentage_change"` ShortPercentageOfFloat *float64 `json:"short_percentage_of_float"` }
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 PriceStatistics ¶
type PriceStatistics struct { 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 `json:"average_volume"` Last float64 LastVolume int `json:"last_volume"` 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 `json:"contract_size"` 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 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 {}
type ShareClassProfile ¶
type ShareClassProfile struct {}
type StdLogger ¶
type StdLogger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) }
type StockSplit ¶
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 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 ValuationRatios ¶
type ValuationRatios struct { AsOfDate *string `json:"as_of_date"` BookValueYield *float64 `json:"book_value_yield"` BuyBackYield *float64 `json:"buy_back_yield"` 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"` 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"` SalesYield *float64 `json:"sales_yield"` SustainableGrowthRate *float64 `json:"sustainable_growth_rate"` TotalYield *float64 `json:"total_yield"` }