trader

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: GPL-2.0 Imports: 16 Imported by: 0

README

schwab

Go Reference Go Report Card License

built, maintained by @samjtro

if you want to contribute - go for it! there is no contribution guide, just a simple golden rule: if it ain't broke, don't fix it: all contributions should be tested via go test before submission.

why should you use this project?

  • lightning fast
  • return structs are easily indexable
  • easy to setup, easy to use (personal preference, i know - but trust me!)

docs

0.0 quick start
  1. go to https://developer.schwab.com, create an account, create an app, get app credentials from https://developer.schwab.com/dashboard/apps
  2. create config.env in your project directory, formatted as such:
APPKEY=KEY0 // App Key
SECRET=KEY1 // App Secret
CBURL=https://127.0.0.1 // App Callback URL
  1. go get github.com/go-schwab/trader
0.1 agent

requests in this library are made through a Handler(), facilitated by an Agent{} created by calling: agent := schwab.Initiate(). from here on out, the documentation assumes you have included the following code prior to making any requests:

import (
    "github.com/go-schwab/trader"
)

agent := trader.Initiate()
1.0 accessing market data
1.1.0 price history

code samples:

df, err := agent.GetPriceHistory("AAPL", "month", "1", "daily", "1", "", "")
check(err)

return:

agent.GetPriceHistory returns a []Candle, of the requested data period & frequency. struct details

[{1714971600000 78569667 182.354 181.71 184.2 180.42} {1715058000000 77305771 183.45 182.4 184.9 181.32} {1715144400000 45057087 182.85 182.74 183.07 181.45} {1715230800000 48982972 182.56 184.57 184.66 182.11} {1715317200000 50759496 184.9 183.05 185.09 182.13} {1715576400000 72044809 185.435 186.28 187.1 184.62} {1715662800000 52393619 187.51 187.43 188.3 186.29} {1715749200000 70399988 187.91 189.72 190.65 187.37} {1715835600000 52845230 190.47 189.84 191.095 189.6601} {1715922000000 41282925 189.51 189.87 190.81 189.18} {1716181200000 44361275 189.325 191.04 191.9199 189.01} {1716267600000 42309401 191.09 192.35 192.73 190.9201} {1716354000000 34648547 192.265 190.9 192.8231 190.27} {1716440400000 51005924 190.98 186.88 191 186.625} {1716526800000 36326975 188.82 189.98 190.58 188.0404} {1716872400000 52280051 191.51 189.99 193 189.1} {1716958800000 53068016 189.61 190.29 192.247 189.51} {1717045200000 49947941 190.76 191.29 192.18 190.63} {1717131600000 75158277 191.44 192.25 192.57 189.91} {1717390800000 50080539 192.9 194.03 194.99 192.52} {1717477200000 47471445 194.635 194.35 195.32 193.0342} {1717563600000 54156785 195.4 195.87 196.9 194.87}]
1.2.0 quotes

code samples:

quote, err := agent.GetQuote("AAPL")
check(err)

return:

agent.GetQuote returns a real-time Quote of the asset's performance. struct details

{EQUITY COE NBBO true 1973757747 AAPL 199.62 164.075 EDGX 195.75 5 1717687921950 XNAS 195.74 4 1717687920970 195.87 196.5 XADF 195.745 100 195.21 195.745 -0.125 -0.06381784 -0.125 -0.06381784 0 0 0 1717687921950 Normal 14237020 1717687921574}
1.3.0 instruments
1.3.1 simple

code samples:

simple, err := agent.SearchInstrumentSimple("AAPL")
check(err)

return:

agent.SearchInstrumentSimple returns a SimpleInstrument for the desired asset. struct details

{037833100 AAPL Apple Inc NASDAQ EQUITY}
1.3.2 fundamental

code samples:

fundamental, err := agent.SearchInstrumentFundamental("AAPL")
check(err)

return:

agent.SearchInstrumentFundamental returns a FundamentalInstrument for the desired asset. struct details

{AAPL 037833100 Apple Inc NASDAQ EQUITY 199.62 164.075 0.51454 1 2024-05-10 00:00:00.0 30.51106 96.708 35.44905 6.98872 23.01545 45.5858 0 26.3058 46.578 0 26.0443 147.2497 22.0738 47.00102 0.87464 1.0371 0 51.3642 140.9682 123.7714 6.41964 9.1372 0 0 -2.8005 -0.9016 0 1.5334082e+16 0 2.9801788367e+12 4.83737 0 0 0 0.25 2024-05-16 00:00:00.0 0 0 0 0 57760123 49229712 61209206 2024-05-02 00:00:00.0 4 6.13 47471445 2024-08-16 00:00:00.0 2024-08-12 00:00:00.0 0}
1.4.0 movers

code samples:

movers, err := agent.GetMovers("$DJI", "up", "percent")
check(err)

return:

agent.GetMovers returns a []Screener of the day's top movers. struct details

[{AMZN Amazon.com Inc 2883278 183.2 183.2 58.33 4943302 5450 1} {MRK Merck & Co. Inc. 546846 127.78 127.78 11.06 4943302 5420 1} {PG Procter & Gamble 540105 169.93 169.93 10.93 4943302 8155 1} {INTC INTEL CORP 284653 30.83 30.83 5.76 4943302 3654 1} {AAPL Apple Inc 216203 218.24 218.24 4.37 4943302 6985 1} {MSFT Microsoft Corp 137598 426.73 426.73 2.78 4943302 7008 1} {KO The Coca-Cola Co 90896 66.83 66.83 1.84 4943302 1103 1} {DIS Walt Disney Co 56167 92.14 92.14 1.14 4943302 1884 1} {NKE Nike Inc B 33306 73.55 73.55 0.67 4943302 1209 1} {MMM 3M Co 20242 125.16 125.16 0.41 4943302 632 1}]
2.0 trading, accessing account data
2.1.0 trading

to submit any trades in this library, one must use your encrypted account id. this as accessed by using the agent.GetAccountNumbers() function, which is then passed to the submission function. this is because there are use cases where you might want to change between multiple accounts while trading the same session.

an, err := agent.GetAccountNumbers()
check(err)

the rest of the docs assume you want to use the first element of the []AccountNumbers array returned. the encrypted id is stored in the HashValue element of the AccountNumbers struct: e.g. an[0].HashValue

2.1.1.0 single-leg

suppose we wanted to submit a single-leg market order for the symbol "AAPL". this is as easy as:

err = agent.SubmitSingleLegOrder(an[0].HashValue, CreateSingleLegOrder(OrderType("MARKET"), Session("NORMAL"), Duration("DAY"), Strategy("SINGLE"), Instruction("BUY"), Quantity(1.0), Instrument(SimpleOrderInstrument{
	Symbol:    "AAPL",
	AssetType: "EQUITY",
})))
check(err)

let's break this down, although it's fairly straight forward. CreateSingleLegOrder returns a SingleLegOrder, passed to agent.SubmitSingleLegOrder after the hash value of your encrypted id. CreateSingleOrder accepts an unknown amount of parameters setting the various required elements for the order:

OrderType:
Session:
Duration:
Strategy:
Instruction:
Quantity:
Instrument:

WIP: DO NOT CROSS, DANGER DANGER

2.2.0 accessing account data
2.2.1.0
an, err := agent.GetAccountNumbers()
check(err)
fmt.Println(an)

aca, err := agent.GetAccounts()
check(err)
fmt.Println(aca)

ac, err := agent.GetAccount(an[0].HashValue)
check(err)
fmt.Println(ac)

orders, err := agent.GetAllOrders("2023-06-12T00:00:00.000Z", "2024-06-12T00:00:00.000Z")
check(err)

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 AccountInstrument struct {
	Cusip        string
	Symbol       string
	Description  string
	InstrumentID int
	NetChange    float64
	Type         string
}

type AccountNumbers

type AccountNumbers struct {
	AccountNumber string
	HashValue     string
}

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

func (agent *Agent) GetAccount(id string) (Account, error)

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

func (agent *Agent) GetAccounts() ([]Account, error)

Get all accounts associated with the user logged in

func (*Agent) GetAllOrders

func (agent *Agent) GetAllOrders(fromEnteredTime, toEnteredTime string) ([]FullOrder, error)

WIP: fromEnteredTime, toEnteredTime format: yyyy-MM-ddTHH:mm:ss.SSSZ

func (*Agent) GetMovers

func (agent *Agent) GetMovers(index, direction, change string) ([]Screener, error)

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

func (agent *Agent) GetOrder(accountNumber, orderID string) (FullOrder, error)

Get a specific order by account number & order ID

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

func (agent *Agent) GetQuote(symbol string) (Quote, error)

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

func (agent *Agent) Handler(req *http.Request) (*http.Response, error)

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 AggregatedBalance struct {
	CurrentLiquidationValue float64
	LiquidationValue        float64
}

type Candle

type Candle struct {
	Time   int     `json:"datetime"`
	Volume int     `json:"volume"`
	Open   float64 `json:"open"`
	Close  float64 `json:"close"`
	Hi     float64 `json:"high"`
	Lo     float64 `json:"low"`
}

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 CurrentBalance struct {
	AccruedInterest       float64
	CashBalance           float64
	CashReceipts          float64
	LongOptionMarketValue float64
	LiquidationValue      float64
	SMA                   float64
}

type FullExecutionLeg

type FullExecutionLeg struct {
	LegId             int
	Price             int
	Quantity          int
	MismarkedQuantity int
	InstrumentId      int
	Time              string
}

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 FullOrderLeg struct {
	OrderLegType   string
	LegId          int
	Instrument     InstrumentRef
	Instruction    string
	PositionEffect string
	Quantity       int
	QuantityType   string
	DivCapGains    string
	ToSymbol       string
}

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"`
	SharesOutstanding       float64 `json:"sharesOutstanding"`
	MarketCapFloat          float64 `json:"marketCapFloat"`
	MarketCap               float64 `json:"marketCap"`
	BookValuePerShare       float64 `json:"bookValuePerShare"`
	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 InstrumentRef struct {
	Cusip        string
	Symbol       string
	Description  string
	InstrumentId int
	NetChange    int
	Type         string
}

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"`
	MarketShare      float64 `json:"marketShare"`
	TotalVolume      int     `json:"totalVolume"`
	Trades           int     `json:"trades"`
	NetPercentChange float64 `json:"netPercentChange"`
}

type SimpleInstrument

type SimpleInstrument struct {
	Cusip       string `json:"cusip"`
	Symbol      string `json:"symbol"`
	Description string `json:"description"`
	Exchange    string `json:"exchange"`
	AssetType   string `json:"assetType"`
}

type SimpleOrderInstrument

type SimpleOrderInstrument struct {
	Symbol    string
	AssetType string // EQUITY
}

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 OrderType

func OrderType(t string) SingleLegOrderComposition

Set SingleLegOrder.OrderType

func Quantity

func Quantity(quantity float32) SingleLegOrderComposition

Set SingleLegOrder.Quantity

func Session

func Session(session string) SingleLegOrderComposition

Set SingleLegOrder.Session

func Strategy

func Strategy(strategy string) SingleLegOrderComposition

Set SingleLegOrder.Strategy

type Token

type Token struct {
	RefreshExpiration time.Time
	Refresh           string
	BearerExpiration  time.Time
	Bearer            string
}

type Transaction

type Transaction struct {
	ActivityID     int `json:"ActivityId"`
	Time           string
	User           User
	Description    string
	AccountNumber  string
	Type           string
	Status         string
	SubAccount     string
	TradeDate      string
	SettlementDate string
	PositionId     int
	OrderId        int
	NetAmount      int
	ActivityType   string
	TransferItems  TransferItems
}

type TransferItems

type TransferItems struct {
	Instrument     InstrumentRef
	Amount         int
	Cost           int
	Price          int
	FeeType        string
	PositionEffect string
}

type User

type User struct {
	CdDomainId     string
	Login          string
	Type           string
	UserId         int
	SystemUserName string
	FirstName      string
	LastName       string
	BrokerRepCode  string
}

Jump to

Keyboard shortcuts

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