Documentation ¶
Index ¶
- Variables
- type Account
- type AccountInstrument
- type AccountNumbers
- type Agent
- func (agent *Agent) GetAccount(id string) (Account, error)
- func (agent *Agent) GetAccountNumbers() ([]AccountNumbers, error)
- func (agent *Agent) GetAccountOrders(accountNumber, fromEnteredTime, toEnteredTime string) ([]FullOrder, error)
- func (agent *Agent) GetAccounts() ([]Account, error)
- func (agent *Agent) GetAllOrders(fromEnteredTime, toEnteredTime string) ([]FullOrder, error)
- func (agent *Agent) GetMovers(index, direction, change string) ([]Screener, error)
- func (agent *Agent) GetOrder(accountNumber, orderID string) (FullOrder, error)
- func (agent *Agent) GetPriceHistory(...) ([]Candle, error)
- func (agent *Agent) GetQuote(symbol string) (Quote, error)
- func (agent *Agent) GetTransaction(accountNumber, transactionId string) (Transaction, error)
- func (agent *Agent) Handler(req *http.Request) (*http.Response, error)
- func (agent *Agent) SearchInstrumentFundamental(symbol string) (FundamentalInstrument, error)
- func (agent *Agent) SearchInstrumentSimple(symbols string) (SimpleInstrument, error)
- func (agent *Agent) Single(ticker, contractType, strikeRange, strikeCount, toDate string) ([]Contract, error)
- func (agent *Agent) SubmitSingleLegOrder(hashValue string, order *SingleLegOrder) error
- type AggregatedBalance
- type Candle
- type Contract
- type CurrentBalance
- type FullExecutionLeg
- type FullOrder
- type FullOrderActivity
- type FullOrderLeg
- type FundamentalInstrument
- type InitialBalance
- type InstrumentRef
- type MultiLegOrder
- type MultiLegSimpleOrderComposition
- type Position
- type ProjectedBalance
- type Quote
- type Screener
- type SimpleInstrument
- type SimpleOrderInstrument
- type SimpleOrderLeg
- type SingleLegOrder
- type SingleLegOrderComposition
- func Duration(duration string) SingleLegOrderComposition
- func Instruction(instruction string) SingleLegOrderComposition
- func Instrument(instrument SimpleOrderInstrument) SingleLegOrderComposition
- func OrderType(t string) SingleLegOrderComposition
- func Quantity(quantity float32) SingleLegOrderComposition
- func Session(session string) SingleLegOrderComposition
- func Strategy(strategy string) SingleLegOrderComposition
- type Token
- type Transaction
- type TransferItems
- type User
Constants ¶
This section is empty.
Variables ¶
var SingleLegOrderTemplate = `` /* 265-byte string literal not displayed */
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Type string AccountNumber string RoundTrips int IsDayTrader bool IsClosingOnlyRestricted bool PFCBFlag bool Positions []Position InitialBalances InitialBalance CurrentBalances CurrentBalance ProjectedBalances ProjectedBalance AggregatedBalance AggregatedBalance }
type AccountInstrument ¶
type AccountNumbers ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func Initiate ¶
func Initiate() *Agent
Initiate the Schwab oAuth process to retrieve bearer/refresh tokens
func (*Agent) GetAccount ¶
Get account by encrypted account id
func (*Agent) GetAccountNumbers ¶
func (agent *Agent) GetAccountNumbers() ([]AccountNumbers, error)
Get encrypted account numbers for trading
func (*Agent) GetAccountOrders ¶
func (agent *Agent) GetAccountOrders(accountNumber, fromEnteredTime, toEnteredTime string) ([]FullOrder, error)
fromEnteredTime, toEnteredTime format: yyyy-MM-ddTHH:mm:ss.SSSZ
func (*Agent) GetAccounts ¶
Get all accounts associated with the user logged in
func (*Agent) GetAllOrders ¶
WIP: fromEnteredTime, toEnteredTime format: yyyy-MM-ddTHH:mm:ss.SSSZ
func (*Agent) GetMovers ¶
GetMovers returns information on the desired index's movers per your desired direction and change type(percent or value), It takes three params: index = "$DJI", "$SPX.X", or "$COMPX" direction = "up" or "down" change = "percent" or "value"
func (*Agent) GetPriceHistory ¶
func (agent *Agent) GetPriceHistory(symbol, periodType, period, frequencyType, frequency, startDate, endDate string) ([]Candle, error)
PriceHistory returns a series of candles with price volume & datetime info per candlestick. It takes seven parameters: ticker = "AAPL", etc.; periodType = "day", "month", "year", "ytd" - default is "day"; period = the number of periods to show; frequencyType = the type of frequency with which each candle is formed; valid fTypes by pType; "day": "minute" / "month": "daily", "weekly" / "year": "daily", "weekly", "monthly" / "ytd": "daily", "weekly"; frequency = the number of the frequencyType included in each candle; valid freqs by fType "minute": 1,5,10,15,30 / "daily": 1 / "weekly": 1 / "monthly": 1; startDate = endDate =
func (*Agent) GetQuote ¶
Quote returns a Quote; containing a real time quote of the desired stock's performance with a number of different indicators (including volatility, volume, price, fundamentals & more). It takes one parameter: ticker = "AAPL", etc.
func (*Agent) GetTransaction ¶
func (agent *Agent) GetTransaction(accountNumber, transactionId string) (Transaction, error)
Get a transaction for a specific account id
func (*Agent) Handler ¶
Handler is the general purpose request function for the td-ameritrade api, all functions will be routed through this handler function, which does all of the API calling work It performs a GET request after adding the apikey found in the config.env file in the same directory as the program calling the function, then returns the body of the GET request's return. It takes one parameter: req = a request of type *http.Request
func (*Agent) SearchInstrumentFundamental ¶
func (agent *Agent) SearchInstrumentFundamental(symbol string) (FundamentalInstrument, error)
SearchInstrumentFundamental returns instrument's fundamentals. It takes one param:
func (*Agent) SearchInstrumentSimple ¶
func (agent *Agent) SearchInstrumentSimple(symbols string) (SimpleInstrument, error)
SearchInstrumentSimple returns instrument's simples. It takes one param:
func (*Agent) Single ¶
func (agent *Agent) Single(ticker, contractType, strikeRange, strikeCount, toDate string) ([]Contract, error)
Single returns a []CONTRACT; containing a SINGLE option chain of your desired strike, type, etc., it takes four parameters: ticker = "AAPL", etc. contractType = "CALL", "PUT", "ALL"; strikeRange = returns option chains for a given range: ITM = in da money NTM = near da money OTM = out da money SAK = strikes above market SBK = strikes below market SNK = strikes near market ALL* = default, all strikes; strikeCount = The number of strikes to return above and below the at-the-money price; toDate = Only return expirations before this date. Valid ISO-8601 formats are: yyyy-MM-dd and yyyy-MM-dd'T'HH:mm:ssz. Lets examine a sample call of Single: Single("AAPL","CALL","ALL","5","2022-07-01"). This returns 5 AAPL CALL contracts both above and below the at the money price, with no preference as to the status of the contract ("ALL"), expiring before 2022-07-01
func (*Agent) SubmitSingleLegOrder ¶
func (agent *Agent) SubmitSingleLegOrder(hashValue string, order *SingleLegOrder) error
Submit a single-leg order for the specified encrypted account ID
type AggregatedBalance ¶
type Contract ¶
type Contract struct { TYPE string `json:""` SYMBOL string `json:""` STRIKE float64 `json:""` EXCHANGE string `json:""` EXPIRATION float64 `json:""` DAYS2EXPIRATION float64 `json:""` BID float64 `json:""` ASK float64 `json:""` LAST float64 `json:""` MARK float64 `json:""` BIDASK_SIZE string `json:""` VOLATILITY float64 `json:""` DELTA float64 `json:""` GAMMA float64 `json:""` THETA float64 `json:""` VEGA float64 `json:""` RHO float64 `json:""` OPEN_INTEREST float64 `json:""` TIME_VALUE float64 `json:""` THEORETICAL_VALUE float64 `json:""` THEORETICAL_VOLATILITY float64 `json:""` PERCENT_CHANGE float64 `json:""` MARK_CHANGE float64 `json:""` MARK_PERCENT_CHANGE float64 `json:""` INTRINSIC_VALUE float64 `json:""` IN_THE_MONEY bool `json:""` }
WIP: type Underlying struct{} WIP:
type CurrentBalance ¶
type FullExecutionLeg ¶
type FullOrder ¶
type FullOrder struct { Session string Duration string OrderType string CancelTime string ComplexOrderStrategyType string Quantity int FilledQuantity int RemainingQuantity int RequestedDestination string DestinationLinkName string ReleaseTime string StopPrice int StopPriceLinkBasis string StopPriceLinkType string StopPriceOffset int StopType string Price string TaxLotMethod string OrderLegCollection []FullOrderLeg ActivationPrice int SpecialInstruction string OrderStrategyType string OrderId int Cancelable bool Editable bool Status string EnteredTime string CloseTime string Tag string AccountNumber int OrderActivityCollection []FullOrderActivity ReplacingOrderCollection string ChildOrderStrategies string StatusDescription string }
type FullOrderActivity ¶
type FullOrderActivity struct { ActivityType string ExecutionType string Quantity int OrderRemainingQuantity int ExecutionLegs []FullExecutionLeg }
type FullOrderLeg ¶
type FundamentalInstrument ¶
type FundamentalInstrument struct { Symbol string `json:"symbol"` Cusip string `json:"cusip"` Description string `json:"description"` Exchange string `json:"exchange"` Type string `json:"assetType"` Hi52 float64 `json:"high52"` Lo52 float64 `json:"low52"` DividendYield float64 `json:"dividendYield"` DividendAmount float64 `json:"dividendAmount"` DividendDate string `json:"dividendDate"` PE float64 `json:"peRatio"` PEG float64 `json:"pegRatio"` PB float64 `json:"pbRatio"` PR float64 `json:"prRatio"` PCF float64 `json:"pcfRatio"` GrossMarginTTM float64 `json:"grossMarginTTM"` NetProfitMarginTTM float64 `json:"netMarginTTM"` OperatingMarginTTM float64 `json:"operatingMarginTTM"` GrossMarginMRQ float64 `json:"grossMarginMRQ"` NetProfitMarginMRQ float64 `json:"netMarginMRQ"` OperatingMarginMRQ float64 `json:"operatingMarginMRQ"` ROE float64 `json:"returnOnEquity"` ROA float64 `json:"returnOnAssets"` ROI float64 `json:"returnOnInvestment"` QuickRatio float64 `json:"quickRatio"` CurrentRatio float64 `json:"currentRatio"` InterestCoverage float64 `json:"interestCoverage"` TotalDebtToCapital float64 `json:"totalDebtToCapital"` LTDebtToEquity float64 `json:"ltDebtToEquity"` TotalDebtToEquity float64 `json:"totalDebtToEquity"` EPSTTM float64 `json:"epsTTM"` EPSChangePercentTTM float64 `json:"epsChangePercentTTM"` EPSChangeYear float64 `json:"epsChangeYear"` EPSChange float64 `json:"epsChange"` RevenueChangeYear float64 `json:"revChangeYear"` RevenueChangeTTM float64 `json:"revChangeTTM"` RevenueChangeIn float64 `json:"revChangeIn"` MarketCapFloat float64 `json:"marketCapFloat"` MarketCap float64 `json:"marketCap"` ShortIntToFloat float64 `json:"shortIntToFloat"` ShortIntDayToCover float64 `json:"shortIntDayToCover"` DividendGrowthRate3Year float64 `json:"dividendGrowthRate3Year"` DividendPayAmount float64 `json:"dividendPayAmount"` DividendPayDate string `json:"dividendPayDate"` Beta float64 `json:"beta"` Vol1DayAverage float64 `json:"vol1DayAvg"` Vol10DayAverage float64 `json:"vol10DayAvg"` Vol3MonthAverage float64 `json:"vol3MonthAvg"` Avg1DayVolume int `json:"avg1DayVolume"` Avg10DaysVolume int `json:"avg10DaysVolume"` Avg3MonthVolume int `json:"avg3MonthVolume"` DeclarationDate string `json:"declarationDate"` DividendFrequency int `json:"dividendFreq"` EPS float64 `json:"eps"` DTNVolume int `json:"dtnVolume"` NextDividendPayDate string `json:"nextDividendPayDate"` NextDividendDate string `json:"nextDividendDate"` FundLeverageFactor float64 `json:"fundLeverageFactor"` }
Change this to reflect ordering of schwab return
type InitialBalance ¶
type InitialBalance struct { AccruedInterest float64 AvailableFundsNonMarginableTrade float64 BondValue float64 BuyingPower float64 CashBalance float64 CashAvailableForTrading float64 CashReceipts float64 DayTradingBuyingPower float64 DayTradingBuyingPowerCall float64 DayTradingEquityCall float64 Equity float64 EquityPercentage float64 LiquidationValue float64 LongMarginValue float64 LongOptionMarketValue float64 LongStockValue float64 MaintenanceCall float64 MaintenanceRequirement float64 Margin float64 MarginEquity float64 MoneyMarketFund float64 MutualFundValue float64 RegTCall float64 ShortMarginValue float64 ShortOptionMarketValue float64 ShortStockValue float64 TotalCash float64 IsInCall float64 UnsettledCash float64 PendingDeposits float64 MarginBalance float64 ShortBalance float64 AccountValue float64 }
type InstrumentRef ¶
type MultiLegOrder ¶
type MultiLegOrder struct { OrderType string // LIMIT, MARKET Session string // NORMAL Duration string // DAY Strategy string // SINGLE OrderLegCollection []SimpleOrderLeg }
type MultiLegSimpleOrderComposition ¶
type MultiLegSimpleOrderComposition func(order *MultiLegOrder)
type Position ¶
type Position struct { ShortQuantity int AveragePrice float64 CurrentDayProfitLoss float64 LongQuantity int SettledLongQuantity int SettledShortQuantity int AgedQuantity int Instrument AccountInstrument MarketValue float64 MaintenanceRequirement float64 AverageLongPrice float64 AverageShortPrice float64 TaxLotAverageLongPrice float64 TaxLotAverageShortPrice float64 LongOpenProfitLoss float64 ShortOpenProfitLoss float64 PreviousSessionLongQuantity int PreviousSessionShortQuantity int CurrentDayCost float64 }
type ProjectedBalance ¶
type ProjectedBalance struct { AvailableFunds float64 AvailableFundsNonMarginableTrade float64 BuyingPower float64 BuyingPowerNonMarginableTrade float64 DayTradingBuyingPower float64 DayTradingBuyingPowerCall float64 Equity float64 EquityPercentage float64 LongMarginValue float64 MaintenanceCall float64 MaintenanceRequirement float64 MarginBalance float64 RegTCall float64 ShortBalance float64 ShortMarginValue float64 SMA float64 IsInCall float64 StockBuyingPower float64 OptionBuyingPower float64 }
type Quote ¶
type Quote struct { AssetMainType string `json:"assetMainType"` AssetSubType string `json:"assetSubType"` QuoteType string `json:"quoteType"` RealTime bool `json:"realTime"` SSID int `json:"ssid"` Symbol string `json:"symbol"` Hi52 float64 `json:"52WeekHigh"` Lo52 float64 `json:"52WeekLow"` AskMICID string `json:"askMICId"` Ask float64 `json:"askPrice"` AskSize int `json:"askSize"` AskTime int `json:"askTime"` BidMICID string `json:"bidMICId"` Bid float64 `json:"bidPrice"` BidSize int `json:"bidSize"` BidTime int `json:"bidTime"` Close float64 `json:"closePrice"` Hi float64 `json:"highPrice"` LastMICID string `json:"lastMICId"` LastPrice float64 `json:"lastPrice"` LastSize int `json:"lastSize"` Lo float64 `json:"lowPrice"` Mark float64 `json:"mark"` MarkChange float64 `json:"markChange"` MarkPercentChange float64 `json:"markPercentChange"` NetChange float64 `json:"netChange"` NetPercentChange float64 `json:"netPercentChange"` Open float64 `json:"open"` PostMarketChange float64 `json:"postMarketChange"` PostMarketPercentChange float64 `json:"postMarketPercentChange"` QuoteTime int `json:"quoteTime"` SecurityStatus string `json:"securityStatus"` TotalVolume int `json:"totalVolume"` TradeTime int `json:"tradeTime"` }
type Screener ¶
type Screener struct { Symbol string `json:"symbol"` Description string `json:"description"` Volume int `json:"volume"` LastPrice float64 `json:"lastPrice"` NetChange float64 `json:"netChange"` TotalVolume int `json:"totalVolume"` Trades int `json:"trades"` NetPercentChange float64 `json:"netPercentChange"` }
type SimpleInstrument ¶
type SimpleOrderInstrument ¶
type SimpleOrderLeg ¶
type SimpleOrderLeg struct { Instruction string Quantity float32 Instrument SimpleOrderInstrument }
type SingleLegOrder ¶
type SingleLegOrder struct { OrderType string `default:"MARKET"` Session string `default:"NORMAL"` Duration string `default:"DAY"` Strategy string `default:"SINGLE"` Instruction string Quantity float32 Instrument SimpleOrderInstrument }
func CreateSingleLegOrder ¶
func CreateSingleLegOrder(opts ...SingleLegOrderComposition) *SingleLegOrder
Create a new Market order
type SingleLegOrderComposition ¶
type SingleLegOrderComposition func(order *SingleLegOrder)
func Duration ¶
func Duration(duration string) SingleLegOrderComposition
Set SingleLegOrder.Duration
func Instruction ¶
func Instruction(instruction string) SingleLegOrderComposition
Set SingleLegOrder.Instruction
func Instrument ¶
func Instrument(instrument SimpleOrderInstrument) SingleLegOrderComposition
Set SingleLegOrder.Instrument
func Quantity ¶
func Quantity(quantity float32) SingleLegOrderComposition
Set SingleLegOrder.Quantity
func Strategy ¶
func Strategy(strategy string) SingleLegOrderComposition
Set SingleLegOrder.Strategy