tradestation

package
v0.0.0-...-9f17ba5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiKey

func ApiKey() string

func DecryptAES

func DecryptAES(ct string) string

func EncryptAES

func EncryptAES(plaintext string) string

func Secret

func Secret() string

Types

type API

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

func New

func New() *API

func (*API) CheckAuth

func (api *API) CheckAuth()

CheckAuth checks if there is a token that is not expired available

func (*API) GetAccount

func (api *API) GetAccount(accountID string) (*Account, error)

func (*API) GetAccounts

func (api *API) GetAccounts() ([]*Account, error)

func (*API) GetQuotes

func (api *API) GetQuotes(tickers []string) ([]*Quote, error)

type Account

type Account struct {
	AccountID   string
	Alias       string
	Currency    string
	Status      string
	AccountType string
	// contains filtered or unexported fields
}

func (*Account) ConfirmGroupOrder

func (account *Account) ConfirmGroupOrder(orders []*OrderRequest) ([]*OrderConfirm, error)

ConfirmGroupOrder returns estimated cost and commission information for a group of orders without the orders actually being placed. Request valid for Market, Limit, Stop Market, Stop Limit, Options, and Order Sends Order (OSO) order types.

func (*Account) ConfirmOrder

func (account *Account) ConfirmOrder(order *OrderRequest) (*OrderConfirm, error)

ConfirmOrder returns estimated cost and commission information for an order without the order actually being placed. Request valid for Market, Limit, Stop Market, Stop Limit, Options, and Order Sends Order (OSO) order types.

func (*Account) GetBalances

func (account *Account) GetBalances() (*Balance, error)

func (*Account) GetBalancesBOD

func (account *Account) GetBalancesBOD() (*Balance, error)

func (*Account) GetHistoricalOrders

func (account *Account) GetHistoricalOrders(since time.Time) ([]*Order, error)

GetHistoricalOrders retrieves historical orders from tradestation

since is the earliest date to retrieve orders for

func (*Account) GetOrders

func (account *Account) GetOrders() ([]*Order, error)

GetOrders retrieves todays orders from tradestation

func (*Account) GetPositions

func (account *Account) GetPositions() ([]*Position, error)

func (*Account) PlaceGroupOrder

func (account *Account) PlaceGroupOrder(orders []*OrderRequest) ([]*Order, error)

Creates a new brokerage order. Request valid for all account types. Request valid for Market, Limit, Stop Market, Stop Limit, Options and Order Sends Order (OSO) order types.

func (*Account) PlaceOrder

func (account *Account) PlaceOrder(order *OrderRequest) (*Order, error)

Creates a new brokerage order. Request valid for all account types. Request valid for Market, Limit, Stop Market, Stop Limit, Options and Order Sends Order (OSO) order types.

type Action

type Action string
const (
	BUY        Action = "BUY"
	SELL       Action = "SELL"
	BUYTOCOVER Action = "BUYTOCOVER"
	SELLSHORT  Action = "SELLSHORT"
)

type Balance

type Balance struct {
	AccountID            string
	AccountType          string
	BuyingPower          float64
	CashBalance          float64
	Commission           float64
	CostOfPositions      float64
	DayTrades            float64
	Equity               float64
	MaintenanceRate      float64
	MarketValue          float64
	OvernightBuyingPower float64
	TodaysProfitLoss     float64
	RealizedProfitLoss   float64
	RequiredMargin       float64
	UnclearedDeposit     float64
	UnrealizedProfitLoss float64
}

type LinkedOrder

type LinkedOrder struct {
	OrderID      string
	Relationship string
}

type MarketFlags

type MarketFlags struct {
	IsBats         bool
	IsDelayed      bool
	IsHalted       bool
	IsHardToBorrow bool
}

type MarketRule

type MarketRule struct {
	RuleType   MarketRuleType
	Symbol     string
	Predicate  MarketRulePredicate
	TriggerKey MarketRuleTrigger
	Price      float64
}

type MarketRulePredicate

type MarketRulePredicate string
const (
	LT  MarketRulePredicate = "Lt"
	LTE MarketRulePredicate = "Lte"
	GT  MarketRulePredicate = "Gt"
	GTE MarketRulePredicate = "Gte"
)

type MarketRuleTrigger

type MarketRuleTrigger string
const (
	SINGLE_TRADE_TICK      MarketRuleTrigger = "STT"  // One trade tick must print within your stop price to trigger your stop.
	SINGLE_TRADE_TICK_NBBO MarketRuleTrigger = "STTN" // One trade tick within the National Best Bid or Offer must print within your stop price to trigger your stop.
	SINGLE_BIDASK_TICK     MarketRuleTrigger = "SBA"  // Buy/Cover Orders: One Ask tick must print within your stop price to trigger your stop. Sell/Short Orders: One Bid tick must print within your stop price to trigger your stop.
	SINGLE_ASKBID_TICK     MarketRuleTrigger = "SAB"  // Buy/Cover Orders: One Bid tick must print within your stop price to trigger your stop. Sell/Short Orders: One Ask tick must print within your stop price to trigger your stop.
	DOUBLE_TRADE_TICK      MarketRuleTrigger = "DTT"  // Two consecutive trade ticks must print within your stop price to trigger your stop.
	DOUBLE_TRADE_TICK_NBBO MarketRuleTrigger = "DTTN" // Two consecutive trade ticks within the National Best Bid or Offer must print within your stop price to trigger your stop.
	DOUBLE_BIDASK_TICK     MarketRuleTrigger = "DBA"  // Buy/Cover Orders: Two consecutive Ask ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two consecutive Bid ticks must print within your stop price to trigger your stop.
	DOUBLE_ASKBID_TICK     MarketRuleTrigger = "DAB"  // Buy/Cover Orders: Two consecutive Bid ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two consecutive Ask ticks must print within your stop price to trigger your stop.
	TWICE_TRADE_TICK       MarketRuleTrigger = "TTT"  // Two trade ticks must print within your stop price to trigger your stop.
	TWICE_TRADE_TICK_NBBO  MarketRuleTrigger = "TTTN" // Two trade ticks within the National Best Bid or Offer must print within your stop price to trigger your stop.
	TWICE_BIDASK_TICK      MarketRuleTrigger = "TBA"  // Buy/Cover Orders: Two Ask ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two Bid ticks must print within your stop price to trigger your stop.
	TWICE_ASKBID_TICK      MarketRuleTrigger = "TAB"  // Buy/Cover Orders: Two Bid ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two Ask ticks must print within your stop price to trigger your stop.
)

type MarketRuleType

type MarketRuleType string
const (
	PRICE MarketRuleType = "Price"
)

type OAuthToken

type OAuthToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	IDToken      string `json:"id_token"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
}

type Order

type Order struct {
	AccountID               string
	AdvancedOptions         string
	ClosedDateTime          time.Time
	CommissionFee           float64
	ConditionalOrders       []*LinkedOrder
	Duration                string
	FilledPrice             float64
	GoodTillDate            time.Time
	GroupName               string
	Legs                    []*OrderLeg
	MarketActivationRules   []*MarketRule
	OrderID                 string
	OpenedDateTime          time.Time
	OrderType               string
	PriceUsedForBuyingPower float64
	RejectReason            string
	Routing                 string
	Status                  OrderStatus
	StatusDescription       string
	TimeActivationRules     []*TimeRule
	UnbundledRouteFee       float64
}

type OrderConfirm

type OrderConfirm struct {
	AccountCurrency          string
	AccountID                string
	BaseCurrency             string
	CounterCurrency          string
	Currency                 string
	DebitCreditEstimatedCost float64
	EstimatedCommission      float64
	EstimatedCost            float64
	EstimatedPrice           float64
	InitialMarginDisplay     string
	ExpirationDate           time.Time
	Quantity                 int64
	Symbol                   string
	TradeAction              Action
	LimitPrice               float64
	OrderAssetCategory       string
	OrderConfirmID           string
	ProductCurrency          string
	Route                    string
	StopPrice                float64
	SummaryMessage           string
	TimeInForceDur           TimeInForceDuration
	TimeInForceExpiration    time.Time
}

type OrderLeg

type OrderLeg struct {
	OpenOrClose       string
	QuantityOrdered   int64
	ExecQuantity      int64
	QuantityRemaining int64
	BuyOrSell         string
	Symbol            string
	AssetType         string
}

type OrderRequest

type OrderRequest struct {
	AccountID      string
	LimitPrice     float64
	OrderConfirmID string
	OrderType      TSOrderType
	Quantity       int64
	StopPrice      float64
	Symbol         string
	TimeInForceDur TimeInForceDuration
	TradeAction    Action
}

type OrderStatus

type OrderStatus string
const (
	RECEIVED              OrderStatus = "ACK"
	BROKEN                OrderStatus = "BRO"
	CANCELED              OrderStatus = "CAN"
	EXPIRED               OrderStatus = "EXP"
	FILLED                OrderStatus = "FLL"
	PARTIAL_FILL          OrderStatus = "FLP"
	PARTIAL_FILL_ALIVE    OrderStatus = "FPR"
	TOO_LATE_TO_CANCEL    OrderStatus = "LAT"
	OPEN                  OrderStatus = "OPN"
	OUT                   OrderStatus = "OUT"
	REJECTED              OrderStatus = "REJ"
	REPLACED              OrderStatus = "UCH"
	CANCEL_SENT           OrderStatus = "UCN"
	TRADE_SERVER_CANCELED OrderStatus = "TSC"
	CANCEL_REJECTED       OrderStatus = "RJC"
	QUEUED                OrderStatus = "DON"
	REPLACE_SENT          OrderStatus = "RSN"
	CONDITION_MET         OrderStatus = "CND"
	OSO_ORDER             OrderStatus = "OSO"
	SUSPENDED             OrderStatus = "SUS"
)

type Position

type Position struct {
	AccountID                   string
	AveragePrice                float64
	AssetType                   string
	Last                        float64
	Bid                         float64
	Ask                         float64
	PositionID                  string
	LongShort                   string
	Quantity                    int64
	Symbol                      string
	Timestamp                   time.Time
	TodaysProfitLoss            float64
	TotalCost                   float64
	MarketValue                 float64
	MarkToMarketPrice           float64
	UnrealizedProfitLoss        float64
	UnrealizedProfitLossPercent float64
	UnrealizedProfitLossQty     float64
}

type Quote

type Quote struct {
	Ask                 float64
	AskSize             int64
	Bid                 float64
	BidSize             int64
	Close               float64
	High                float64
	Low                 float64
	High52Week          float64
	High52WeekTimestamp time.Time
	Last                float64
	MinPrice            float64
	MaxPrice            float64
	FirstNoticeDate     time.Time
	LastTradingDate     time.Time
	Low52Week           float64
	Low52WeekTimestamp  time.Time
	Flags               *MarketFlags
	NetChange           float64
	NetChangePct        float64
	Open                float64
	PreviousClose       float64
	PreviousVolume      int64
	Restrictions        []string
	Symbol              string
	TickSizeTier        int64
	TradeTime           time.Time
	Volume              int64
	LastSize            int64
	LastVenue           string
	VWAP                float64
}

type TSOrderType

type TSOrderType string
const (
	LIMIT      TSOrderType = "Limit"
	STOP       TSOrderType = "StopMarket"
	MARKET     TSOrderType = "Market"
	STOP_LIMIT TSOrderType = "StopLimit"
)

type TimeInForceDuration

type TimeInForceDuration string
const (
	DAY                      TimeInForceDuration = "DAY"
	DAY_PLUS                 TimeInForceDuration = "DYP"
	GOOD_TILL_CANCELLED      TimeInForceDuration = "GTC"
	GOOD_TILL_CANCELLED_PLUS TimeInForceDuration = "GCP"
	GOOD_THROUGH_DATE        TimeInForceDuration = "GDP"
	ON_OPEN                  TimeInForceDuration = "OPG"
	ON_CLOSE                 TimeInForceDuration = "CLO"
	IMMEDIATE                TimeInForceDuration = "IOC"
	FILL_OR_KILL             TimeInForceDuration = "FOK"
	ONE_MIN                  TimeInForceDuration = "1"
	THREE_MIN                TimeInForceDuration = "3"
	FIVE_MIN                 TimeInForceDuration = "5"
)

type TimeRule

type TimeRule struct {
	TimeUtc time.Time
}

Jump to

Keyboard shortcuts

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