Documentation
¶
Index ¶
- Constants
- func GatewayDepthCSVHeader() string
- func GatewayQuoteCSVHeader() string
- func GatewayTradeCSVHeader() string
- func GatewayUserAccountCSVHeader() string
- func GatewayUserOrderCSVHeader() string
- func GatewayUserPositionCSVHeader() string
- func GatewayUserTradeCSVHeader() string
- func GetWsConn(negotiateUrl, wsUrl, token string) (net.Conn, error)
- func ReadFullText(conn net.Conn) ([]byte, error)
- func WriteTextFrame(conn net.Conn, payload []byte) error
- type APIError
- type Account
- type AccountResponse
- type AccountSearchRequest
- type AccountService
- type AvailableContractRequest
- type AvailableContractResponse
- type Bar
- type BarHistoryRequest
- type BasicOrderResponse
- type BasicPositionResponse
- type Bracket
- type CancelOrderRequest
- type CloseContractRequest
- type Contract
- type GatewayDepth
- type GatewayQuote
- type GatewayTrade
- type GatewayUserAccount
- type GatewayUserOrder
- type GatewayUserPosition
- type GatewayUserTrade
- type HistoryResponse
- type MarketService
- func (s *MarketService) AvailableContracts(ctx context.Context, req AvailableContractRequest) ([]Contract, error)
- func (s *MarketService) History(ctx context.Context, req BarHistoryRequest) ([]Bar, error)
- func (s *MarketService) SearchContractById(ctx context.Context, req SearchContractByIdRequest) ([]Contract, error)
- func (s *MarketService) SearchContracts(ctx context.Context, req SearchContractRequest) ([]Contract, error)
- type ModifyOrderRequest
- type OpenOrder
- type OpenOrderSearchRequest
- type OpenOrderSearchResponse
- type Order
- type OrderSearchRequest
- type OrderSearchResponse
- type OrderService
- func (s *OrderService) CancelOrder(ctx context.Context, req CancelOrderRequest) (bool, error)
- func (s *OrderService) ModifyOrder(ctx context.Context, req ModifyOrderRequest) (bool, error)
- func (s *OrderService) OpenOrderSearch(ctx context.Context, req OpenOrderSearchRequest) ([]OpenOrder, error)
- func (s *OrderService) OrderSearch(ctx context.Context, req OrderSearchRequest) ([]Order, error)
- func (s *OrderService) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (int, error)
- type PartialCloseContractRequest
- type PlaceOrderRequest
- type PlaceOrderResponse
- type PositionService
- func (p *PositionService) CloseContract(ctx context.Context, req CloseContractRequest) (bool, error)
- func (p *PositionService) PartialCloseContract(ctx context.Context, req PartialCloseContractRequest) (bool, error)
- func (p *PositionService) SearchOpenContract(ctx context.Context, req SearchOpenContractRequest) (bool, error)
- type ProjectXClient
- type RealtimeService
- func (r *RealtimeService) Close()
- func (r *RealtimeService) Connect(ctx context.Context) error
- func (r *RealtimeService) DepthStream() <-chan GatewayDepth
- func (r *RealtimeService) QuotesStream() <-chan GatewayQuote
- func (r *RealtimeService) SubscribeAccounts(contractId string) error
- func (r *RealtimeService) SubscribeContractMarketDepth(contractId string) error
- func (r *RealtimeService) SubscribeContractQuotes(contractId string) error
- func (r *RealtimeService) SubscribeContractTrades(contractId string) error
- func (r *RealtimeService) SubscribeOrders(contractId string) error
- func (r *RealtimeService) SubscribePositions(contractId string) error
- func (r *RealtimeService) SubscribeTrades(contractId string) error
- func (r *RealtimeService) TradesStream() <-chan GatewayTrade
- func (r *RealtimeService) UserAccountStream() <-chan GatewayUserAccount
- func (r *RealtimeService) UserOrdersStream() <-chan GatewayUserOrder
- func (r *RealtimeService) UserPositionStream() <-chan GatewayUserPosition
- func (r *RealtimeService) UserTradeStream() <-chan GatewayUserTrade
- type SearchContractByIdRequest
- type SearchContractRequest
- type SearchOpenContractRequest
- type SubscribeMsg
- type TradeSearchRequest
- type TradeSearchResponse
- type TradeService
- type WebSocketHandshakeResponse
Constants ¶
View Source
const ( Bid = 0 Ask = 1 Https = "https://" Wss = "wss://" CHAN_SIZE = 100 )
View Source
const (
RecordSep = 0x1E
)
Variables ¶
This section is empty.
Functions ¶
func GatewayDepthCSVHeader ¶ added in v0.0.5
func GatewayDepthCSVHeader() string
func GatewayQuoteCSVHeader ¶ added in v0.0.5
func GatewayQuoteCSVHeader() string
func GatewayTradeCSVHeader ¶ added in v0.0.5
func GatewayTradeCSVHeader() string
func GatewayUserAccountCSVHeader ¶ added in v0.0.5
func GatewayUserAccountCSVHeader() string
func GatewayUserOrderCSVHeader ¶ added in v0.0.5
func GatewayUserOrderCSVHeader() string
func GatewayUserPositionCSVHeader ¶ added in v0.0.5
func GatewayUserPositionCSVHeader() string
func GatewayUserTradeCSVHeader ¶ added in v0.0.5
func GatewayUserTradeCSVHeader() string
func ReadFullText ¶
readText reads a FULL text message (handles fragmentation)
Types ¶
type AccountResponse ¶
type AccountSearchRequest ¶
type AccountSearchRequest struct {
OnlyActiveAccounts bool `json:"onlyActiveAccounts"`
}
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
func (*AccountService) Search ¶
func (s *AccountService) Search(ctx context.Context, req AccountSearchRequest) ([]Account, error)
type AvailableContractRequest ¶
type AvailableContractRequest struct {
Live bool `json:"live"`
}
type BarHistoryRequest ¶
type BarHistoryRequest struct {
ContractId string `json:"contractId"`
Live bool `json:"live"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
Unit int `json:"unit"` // second, minute, hour, day, week, month
UnitNumber int `json:"unitNumber"` // number of units to aggregate
Limit int `json:"limit"`
IncludePartialBar bool `json:"includePartialBar"`
}
type BasicOrderResponse ¶
type BasicPositionResponse ¶
type CancelOrderRequest ¶
type CloseContractRequest ¶
type GatewayDepth ¶ added in v0.0.5
type GatewayDepth struct {
Timestamp string `json:"timestamp"`
Type int `json:"type"`
Price float64 `json:"price"`
Volume int64 `json:"volume"`
CurrentVolume int64 `json:"currentVolume"`
}
func (GatewayDepth) String ¶ added in v0.0.5
func (d GatewayDepth) String() string
func (GatewayDepth) ToCSVRow ¶ added in v0.0.5
func (d GatewayDepth) ToCSVRow() string
type GatewayQuote ¶ added in v0.0.5
type GatewayQuote struct {
Symbol string `json:"symbol"`
SymbolName string `json:"symbolName,omitempty"`
LastPrice float64 `json:"lastPrice,omitempty"`
BestBid float64 `json:"bestBid,omitempty"`
BestAsk float64 `json:"bestAsk,omitempty"`
Change float64 `json:"change,omitempty"`
ChangePercent float64 `json:"changePercent,omitempty"`
Open float64 `json:"open,omitempty"`
High float64 `json:"high,omitempty"`
Low float64 `json:"low,omitempty"`
Volume int64 `json:"volume,omitempty"`
LastUpdated string `json:"lastUpdated"`
Timestamp string `json:"timestamp"`
}
func (GatewayQuote) String ¶ added in v0.0.5
func (q GatewayQuote) String() string
func (GatewayQuote) ToCSVRow ¶ added in v0.0.5
func (q GatewayQuote) ToCSVRow() string
type GatewayTrade ¶
type GatewayTrade struct {
SymbolId string `json:"symbolId"`
Price float64 `json:"price"`
Timestamp string `json:"timestamp"`
Type int `json:"type"`
Volume int64 `json:"volume"`
}
func (GatewayTrade) String ¶ added in v0.0.5
func (t GatewayTrade) String() string
func (GatewayTrade) ToCSVRow ¶ added in v0.0.5
func (t GatewayTrade) ToCSVRow() string
type GatewayUserAccount ¶ added in v0.0.5
type GatewayUserAccount struct {
Id int `json:"id"`
Name string `json:"name"`
Balance float64 `json:"balance"`
CanTrade bool `json:"canTrade"`
IsVisible bool `json:"isVisible"`
Simulated bool `json:"Simulated"`
}
func (GatewayUserAccount) String ¶ added in v0.0.5
func (a GatewayUserAccount) String() string
func (GatewayUserAccount) ToCSVRow ¶ added in v0.0.5
func (a GatewayUserAccount) ToCSVRow() string
type GatewayUserOrder ¶ added in v0.0.5
type GatewayUserOrder struct {
Id int `json:"id"`
AccountId int `json:"accountId"`
ContractId string `json:"contractId"`
SymbolId string `json:"symbolId"`
CreationTimestamp string `json:"creationTimestamp"`
UpdateTimestamp string `json:"updateTimestamp"`
Status int `json:"status"`
Type int `json:"type"`
Side int `json:"side"`
Size int `json:"size"`
LimitPrice float64 `json:"limitPrice"`
StopPrice float64 `json:"stopPrice"`
FillVolume int `json:"fillVolume"`
FilledPrice float64 `json:"filledPrice"`
CustomTag string `json:"customTag"`
}
func (GatewayUserOrder) String ¶ added in v0.0.5
func (o GatewayUserOrder) String() string
func (GatewayUserOrder) ToCSVRow ¶ added in v0.0.5
func (o GatewayUserOrder) ToCSVRow() string
type GatewayUserPosition ¶ added in v0.0.5
type GatewayUserPosition struct {
Id int `json:"id"`
AccountId int `json:"accountId"`
ContractId string `json:"contractId"`
CreationTimestamp string `json:"creationTimestamp"`
Type int `json:"type"`
Size int `json:"size"`
AveragePrice float64 `json:"averagePrice"`
}
func (GatewayUserPosition) String ¶ added in v0.0.5
func (p GatewayUserPosition) String() string
func (GatewayUserPosition) ToCSVRow ¶ added in v0.0.5
func (p GatewayUserPosition) ToCSVRow() string
type GatewayUserTrade ¶ added in v0.0.5
type GatewayUserTrade struct {
Id int `json:"id"`
AccountId int `json:"accountId"`
ContractId string `json:"contractId"`
CreationTimestamp string `json:"creationTimestamp"`
Price float64 `json:"price"`
ProfitAndLoss float64 `json:"profitAndLoss"`
Fees float64 `json:"fees"`
Side int `json:"side"`
Size int `json:"size"`
Voided bool `json:"voided"`
OrderId int `json:"orderId"`
}
func (GatewayUserTrade) String ¶ added in v0.0.5
func (t GatewayUserTrade) String() string
func (GatewayUserTrade) ToCSVRow ¶ added in v0.0.5
func (t GatewayUserTrade) ToCSVRow() string
type HistoryResponse ¶
type MarketService ¶
type MarketService struct {
// contains filtered or unexported fields
}
func (*MarketService) AvailableContracts ¶
func (s *MarketService) AvailableContracts(ctx context.Context, req AvailableContractRequest) ([]Contract, error)
func (*MarketService) History ¶
func (s *MarketService) History(ctx context.Context, req BarHistoryRequest) ([]Bar, error)
func (*MarketService) SearchContractById ¶
func (s *MarketService) SearchContractById(ctx context.Context, req SearchContractByIdRequest) ([]Contract, error)
func (*MarketService) SearchContracts ¶
func (s *MarketService) SearchContracts(ctx context.Context, req SearchContractRequest) ([]Contract, error)
type ModifyOrderRequest ¶
type OpenOrder ¶
type OpenOrder struct {
ID int64 `json:"id"`
AccountID int64 `json:"accountId"`
ContractID string `json:"contractId"`
CreationTimestamp time.Time `json:"creationTimestamp"`
UpdateTimestamp time.Time `json:"updateTimestamp"`
Status int `json:"status"`
Type int `json:"type"`
Side int `json:"side"`
Size int `json:"size"`
LimitPrice *float64 `json:"limitPrice"`
StopPrice *float64 `json:"stopPrice"`
FilledPrice *float64 `json:"filledPrice"`
}
type OpenOrderSearchRequest ¶
type OpenOrderSearchRequest struct {
AccountId int `json:"accountId"`
}
type OpenOrderSearchResponse ¶
type Order ¶
type Order struct {
ID int64 `json:"id"`
AccountID int64 `json:"accountId"`
ContractID string `json:"contractId"`
SymbolID string `json:"symbolId"`
CreationTimestamp time.Time `json:"creationTimestamp"`
UpdateTimestamp time.Time `json:"updateTimestamp"`
Status int `json:"status"`
Type int `json:"type"`
Side int `json:"side"`
Size int `json:"size"`
LimitPrice *float64 `json:"limitPrice"`
StopPrice *float64 `json:"stopPrice"`
FillVolume int `json:"fillVolume"`
FilledPrice *float64 `json:"filledPrice"`
CustomTag *string `json:"customTag"`
}
type OrderSearchRequest ¶
type OrderSearchResponse ¶
type OrderService ¶
type OrderService struct {
// contains filtered or unexported fields
}
func (*OrderService) CancelOrder ¶
func (s *OrderService) CancelOrder(ctx context.Context, req CancelOrderRequest) (bool, error)
func (*OrderService) ModifyOrder ¶
func (s *OrderService) ModifyOrder(ctx context.Context, req ModifyOrderRequest) (bool, error)
func (*OrderService) OpenOrderSearch ¶
func (s *OrderService) OpenOrderSearch(ctx context.Context, req OpenOrderSearchRequest) ([]OpenOrder, error)
func (*OrderService) OrderSearch ¶
func (s *OrderService) OrderSearch(ctx context.Context, req OrderSearchRequest) ([]Order, error)
func (*OrderService) PlaceOrder ¶
func (s *OrderService) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (int, error)
type PlaceOrderRequest ¶
type PlaceOrderRequest struct {
AccountId int `json:"accountId"`
ContractId string `json:"contractId"`
Type int `json:"type"`
Side int `json:"side"`
Size int `json:"size"`
LimitPrice float64 `json:"limitPrice"`
StopPrice float64 `json:"stopPrice"`
TrailPrice float64 `json:"trailPrice"`
CustomTag string `json:"customTag"`
StopLossBracket Bracket `json:"stopLossBracket"`
TakeProfitBracket Bracket `json:"takeProfitBracket"`
}
type PlaceOrderResponse ¶
type PositionService ¶
type PositionService struct {
// contains filtered or unexported fields
}
func (*PositionService) CloseContract ¶
func (p *PositionService) CloseContract(ctx context.Context, req CloseContractRequest) (bool, error)
func (*PositionService) PartialCloseContract ¶
func (p *PositionService) PartialCloseContract(ctx context.Context, req PartialCloseContractRequest) (bool, error)
func (*PositionService) SearchOpenContract ¶
func (p *PositionService) SearchOpenContract(ctx context.Context, req SearchOpenContractRequest) (bool, error)
type ProjectXClient ¶
type ProjectXClient struct {
Accounts *AccountService
Markets *MarketService
Orders *OrderService
Trades *TradeService
Realtime *RealtimeService
// contains filtered or unexported fields
}
func NewProjectXClient ¶
func NewProjectXClient(baseUrl, wsUrl, username, apiKey string) *ProjectXClient
func (*ProjectXClient) PostNoAuth ¶
type RealtimeService ¶
type RealtimeService struct {
// contains filtered or unexported fields
}
func NewRealtimeService ¶
func NewRealtimeService(c *ProjectXClient) *RealtimeService
func (*RealtimeService) Close ¶ added in v0.0.7
func (r *RealtimeService) Close()
func (*RealtimeService) DepthStream ¶
func (r *RealtimeService) DepthStream() <-chan GatewayDepth
func (*RealtimeService) QuotesStream ¶
func (r *RealtimeService) QuotesStream() <-chan GatewayQuote
func (*RealtimeService) SubscribeAccounts ¶
func (r *RealtimeService) SubscribeAccounts(contractId string) error
func (*RealtimeService) SubscribeContractMarketDepth ¶
func (r *RealtimeService) SubscribeContractMarketDepth(contractId string) error
func (*RealtimeService) SubscribeContractQuotes ¶
func (r *RealtimeService) SubscribeContractQuotes(contractId string) error
func (*RealtimeService) SubscribeContractTrades ¶
func (r *RealtimeService) SubscribeContractTrades(contractId string) error
func (*RealtimeService) SubscribeOrders ¶
func (r *RealtimeService) SubscribeOrders(contractId string) error
func (*RealtimeService) SubscribePositions ¶
func (r *RealtimeService) SubscribePositions(contractId string) error
func (*RealtimeService) SubscribeTrades ¶
func (r *RealtimeService) SubscribeTrades(contractId string) error
func (*RealtimeService) TradesStream ¶
func (r *RealtimeService) TradesStream() <-chan GatewayTrade
func (*RealtimeService) UserAccountStream ¶
func (r *RealtimeService) UserAccountStream() <-chan GatewayUserAccount
func (*RealtimeService) UserOrdersStream ¶
func (r *RealtimeService) UserOrdersStream() <-chan GatewayUserOrder
func (*RealtimeService) UserPositionStream ¶
func (r *RealtimeService) UserPositionStream() <-chan GatewayUserPosition
func (*RealtimeService) UserTradeStream ¶
func (r *RealtimeService) UserTradeStream() <-chan GatewayUserTrade
type SearchContractByIdRequest ¶
type SearchContractByIdRequest struct {
ContractId string `json:"contractId"`
}
type SearchContractRequest ¶
type SearchOpenContractRequest ¶
type SearchOpenContractRequest struct {
AccountId int `json:"accountId"`
}
type SubscribeMsg ¶
type TradeSearchRequest ¶
type TradeSearchResponse ¶
type TradeSearchResponse struct {
Trades []GatewayUserTrade `json:"trades"`
Success bool `json:"success"`
ErrorCode int `json:"errorCode"`
ErrorMessage string `json:"errorMessage"`
}
type TradeService ¶
type TradeService struct {
// contains filtered or unexported fields
}
func (*TradeService) Search ¶
func (s *TradeService) Search(ctx context.Context, req TradeSearchRequest) ([]GatewayUserTrade, error)
Click to show internal directories.
Click to hide internal directories.