Documentation
¶
Index ¶
- Constants
- Variables
- func ImportDhParametersFromPem(pemPath string) (*dsa.Parameters, error)
- func ImportRsaKeyFromPem(pemPath string) (*rsa.PrivateKey, error)
- func SignRsa(input []byte, key *rsa.PrivateKey) ([]byte, error)
- type AccountLedger
- type AuthStatus
- type CancelOrderErrorResponse
- type CancelOrderResponse
- type GetAccountsResponse
- type HMDSDetails
- type IServerDetails
- type IbkrOAuthContext
- type IbkrOAuthCredentials
- type IbkrWebClient
- func (c *IbkrWebClient) AuthStatus() (*AuthStatus, error)
- func (c *IbkrWebClient) Authenticate() error
- func (c *IbkrWebClient) CancelOrder(accountId string, orderId string) (*CancelOrderResponse, error)
- func (c *IbkrWebClient) Delete(path string, queryParams map[string]string) (*clientResponse, error)
- func (c *IbkrWebClient) DoRequest(method string, path string, queryParams map[string]string, body interface{}) (*clientResponse, error)
- func (c *IbkrWebClient) Get(path string, queryParams map[string]string) (*clientResponse, error)
- func (c *IbkrWebClient) GetAccounts() ([]string, error)
- func (c *IbkrWebClient) GetLiveOrders() (*LiveOrdersResponse, error)
- func (c *IbkrWebClient) GetPortfolioAccountLedger(acctId string) (*PortfolioAccountLedger, error)
- func (c *IbkrWebClient) GetPortfolioSubaccounts() ([]PortfolioSubaccount, error)
- func (c *IbkrWebClient) GetPositions(acctId string, page int32) ([]Position, error)
- func (c *IbkrWebClient) InitializeBrokerSession() (*AuthStatus, error)
- func (c *IbkrWebClient) Logout() error
- func (c *IbkrWebClient) MarketDataHistory(conId int, period string, barType string) (*MarketDataHistoryResponse, error)
- func (c *IbkrWebClient) MarketDataSnapshot(conIds []int) ([]MarketDataSnapshot, error)
- func (c *IbkrWebClient) ParseJsonResponse(response *clientResponse, v interface{}) error
- func (c *IbkrWebClient) PlaceOrder(accountId string, order Order) (*PlaceOrderResponse, error)
- func (c *IbkrWebClient) Post(path string, queryParams map[string]string, body interface{}) (*clientResponse, error)
- func (c *IbkrWebClient) ResetAuthentication()
- func (c *IbkrWebClient) SearchContractBySymbol(symbol string) ([]SearchContractBySymbolResponse, error)
- func (c *IbkrWebClient) SuppressMessages() error
- func (c *IbkrWebClient) SwitchAccount(accountId string) error
- func (c *IbkrWebClient) Tickle() (*TickleResponse, error)
- type InitializeBrokerageSessionRequest
- type LiveOrdersResponse
- type LogoutResponse
- type MarketDataHistoryResponse
- type MarketDataSnapshot
- type MarketDataSnapshotResponse
- type OAuthContext
- type OAuthParams
- type OHLCBar
- type Order
- type OrderStatus
- type PlaceOrderRejectResponse
- type PlaceOrderRequest
- type PlaceOrderResponse
- type PlaceOrderResponseMessage
- type PlaceOrderResponsePlain
- type PortfolioAccountLedger
- type PortfolioSubaccount
- type Position
- type SearchContractBySymbolResponse
- type ServerInfo
- type SupressMessagesRequest
- type SwitchAccountRequest
- type SwitchAccountResponse
- type SwitchAccountResponseAlreadySet
- type TickleResponse
Constants ¶
View Source
const ( MarketDataPeriodSeconds = "S" MarketDataPeriodDay = "d" MarketDataPeriodWeek = "w" MarketDataPeriodMonth = "m" MarketDataPeriodYear = "y" )
View Source
const ( MarketDataBarSeconds = "secs" MarketDataBarMinutes = "mins" MarketDataBarHours = "hrs" MarketDataBarDay = "d" MarketDataBarWeek = "w" MarketDataBarMonth = "m" )
View Source
const ( MessageIdImmediateFill = "o403" MessageIdMarketOrderRisk = "o10151" MessageIdOrderWithoutMarketData = "o354" )
View Source
const DefaultUserAgent = "schmidthole/ibkr-webapi-go/1"
View Source
const GatewayBaseUrl = "https://localhost:5000"
View Source
const ProdBaseUrl = "https://api.ibkr.com"
Variables ¶
View Source
var IbkrGlobalRateLimit = 50
View Source
var LstExpirationThreshold int64 = 900
View Source
var MessagesToSupress = []string{ MessageIdImmediateFill, MessageIdMarketOrderRisk, MessageIdOrderWithoutMarketData, }
Functions ¶
func ImportDhParametersFromPem ¶
func ImportDhParametersFromPem(pemPath string) (*dsa.Parameters, error)
func ImportRsaKeyFromPem ¶
func ImportRsaKeyFromPem(pemPath string) (*rsa.PrivateKey, error)
Types ¶
type AccountLedger ¶
type AccountLedger struct {
SettledCash float64 `json:"settledCash" validation:"required"`
CashBalance float64 `json:"cashBalance" validation:"required"`
NetLiquidationValue float64 `json:"netLiquidationValue" validation:"required"`
UnrealizedPnL float64 `json:"unrealizedpnl" validation:"required"`
RealizedPnL float64 `json:"realizedpnl" validation:"required"`
Funds float64 `json:"funds" validation:"required"`
}
type AuthStatus ¶
type AuthStatus struct {
Authenticated bool `json:"authenticated" validation:"required"`
Competing bool `json:"competing" validation:"required"`
Connected bool `json:"connected" validation:"required"`
Message string `json:"message" validation:"required"`
MAC string `json:"MAC" validation:"required"`
ServerInfo ServerInfo `json:"serverInfo" validation:"required"`
}
type CancelOrderErrorResponse ¶
type CancelOrderErrorResponse struct {
Error string `json:"error" validation:"required"`
}
type CancelOrderResponse ¶
type GetAccountsResponse ¶ added in v1.0.0
type GetAccountsResponse struct {
Accounts []string `json:"accounts" validate:"required"`
}
type HMDSDetails ¶
type HMDSDetails struct {
Error string `json:"error"`
}
type IServerDetails ¶
type IServerDetails struct {
AuthStatus AuthStatus `json:"authStatus"`
}
type IbkrOAuthContext ¶
type IbkrOAuthContext struct {
ConsumerKey string
SigningKey *rsa.PrivateKey
EncryptionKey *rsa.PrivateKey
DhParams *dsa.Parameters
AccessToken string
AccessSecret string
LstExpiration int64
Lst string
VerboseLogging bool
}
func NewIbkrOAuthContext ¶
func NewIbkrOAuthContextFromFile ¶
func NewIbkrOAuthContextFromFile(credentialsFilePath string) (*IbkrOAuthContext, error)
func (*IbkrOAuthContext) GenerateLiveSessionToken ¶
func (i *IbkrOAuthContext) GenerateLiveSessionToken(client *http.Client, baseUrl string) error
func (*IbkrOAuthContext) GetOAuthHeader ¶
func (i *IbkrOAuthContext) GetOAuthHeader(method string, requestUrl string) (string, error)
func (*IbkrOAuthContext) Reset ¶ added in v1.1.0
func (i *IbkrOAuthContext) Reset()
func (*IbkrOAuthContext) ShouldReAuthenticate ¶ added in v1.0.5
func (i *IbkrOAuthContext) ShouldReAuthenticate() bool
type IbkrOAuthCredentials ¶
type IbkrOAuthCredentials struct {
CustomerKey string `yaml:"customer_key"`
AccessToken string `yaml:"access_token"`
AccessSecret string `yaml:"access_secret"`
SigningKeyPath string `yaml:"signing_key_path"`
EncryptionKeyPath string `yaml:"encryption_key_path"`
DHParamsPath string `yaml:"dh_params_path"`
}
type IbkrWebClient ¶
type IbkrWebClient struct {
VerboseLogging bool
BaseUrl string
// contains filtered or unexported fields
}
func NewIbkrWebClient ¶
func NewIbkrWebClient(baseUrl string, authContext OAuthContext) *IbkrWebClient
func (*IbkrWebClient) AuthStatus ¶
func (c *IbkrWebClient) AuthStatus() (*AuthStatus, error)
func (*IbkrWebClient) Authenticate ¶
func (c *IbkrWebClient) Authenticate() error
func (*IbkrWebClient) CancelOrder ¶
func (c *IbkrWebClient) CancelOrder(accountId string, orderId string) (*CancelOrderResponse, error)
func (*IbkrWebClient) Delete ¶
func (c *IbkrWebClient) Delete(path string, queryParams map[string]string) (*clientResponse, error)
func (*IbkrWebClient) Get ¶
func (c *IbkrWebClient) Get(path string, queryParams map[string]string) (*clientResponse, error)
func (*IbkrWebClient) GetAccounts ¶ added in v1.0.0
func (c *IbkrWebClient) GetAccounts() ([]string, error)
func (*IbkrWebClient) GetLiveOrders ¶
func (c *IbkrWebClient) GetLiveOrders() (*LiveOrdersResponse, error)
func (*IbkrWebClient) GetPortfolioAccountLedger ¶
func (c *IbkrWebClient) GetPortfolioAccountLedger(acctId string) (*PortfolioAccountLedger, error)
func (*IbkrWebClient) GetPortfolioSubaccounts ¶
func (c *IbkrWebClient) GetPortfolioSubaccounts() ([]PortfolioSubaccount, error)
func (*IbkrWebClient) GetPositions ¶
func (c *IbkrWebClient) GetPositions(acctId string, page int32) ([]Position, error)
func (*IbkrWebClient) InitializeBrokerSession ¶
func (c *IbkrWebClient) InitializeBrokerSession() (*AuthStatus, error)
func (*IbkrWebClient) Logout ¶
func (c *IbkrWebClient) Logout() error
func (*IbkrWebClient) MarketDataHistory ¶
func (c *IbkrWebClient) MarketDataHistory( conId int, period string, barType string, ) (*MarketDataHistoryResponse, error)
func (*IbkrWebClient) MarketDataSnapshot ¶
func (c *IbkrWebClient) MarketDataSnapshot( conIds []int, ) ([]MarketDataSnapshot, error)
func (*IbkrWebClient) ParseJsonResponse ¶
func (c *IbkrWebClient) ParseJsonResponse(response *clientResponse, v interface{}) error
func (*IbkrWebClient) PlaceOrder ¶
func (c *IbkrWebClient) PlaceOrder(accountId string, order Order) (*PlaceOrderResponse, error)
func (*IbkrWebClient) Post ¶
func (c *IbkrWebClient) Post(path string, queryParams map[string]string, body interface{}) (*clientResponse, error)
func (*IbkrWebClient) ResetAuthentication ¶ added in v1.1.0
func (c *IbkrWebClient) ResetAuthentication()
func (*IbkrWebClient) SearchContractBySymbol ¶
func (c *IbkrWebClient) SearchContractBySymbol(symbol string) ([]SearchContractBySymbolResponse, error)
func (*IbkrWebClient) SuppressMessages ¶ added in v0.4.0
func (c *IbkrWebClient) SuppressMessages() error
func (*IbkrWebClient) SwitchAccount ¶
func (c *IbkrWebClient) SwitchAccount(accountId string) error
func (*IbkrWebClient) Tickle ¶
func (c *IbkrWebClient) Tickle() (*TickleResponse, error)
type LiveOrdersResponse ¶
type LiveOrdersResponse struct {
Orders []OrderStatus `json:"orders" validation:"required"`
}
type LogoutResponse ¶
type LogoutResponse struct {
Status bool `json:"status" validation:"required"`
}
type MarketDataSnapshot ¶
type MarketDataSnapshotResponse ¶
type MarketDataSnapshotResponse struct {
ConID int `json:"conid" validation:"required"`
LastPrice string `json:"31" validation:"required"`
High string `json:"70" validation:"required"`
Low string `json:"71" validation:"required"`
Open string `json:"7295" validation:"required"`
Mark string `json:"7635" validation:"required"`
PriorClose string `json:"7741" validation:"required"`
}
type OAuthContext ¶
type OAuthParams ¶
func (OAuthParams) ToHeaderString ¶
func (p OAuthParams) ToHeaderString() string
func (OAuthParams) ToSignatureString ¶
func (p OAuthParams) ToSignatureString() string
type OrderStatus ¶
type OrderStatus struct {
Account string `json:"acct" validation:"required"`
ConID int32 `json:"conid" validation:"required"`
OrderID int32 `json:"orderId" validation:"required"`
Ticker string `json:"ticker" validation:"required"`
RemainingQuantity float64 `json:"remainingQuantity" validation:"required"`
FilledQuantity float64 `json:"filledQuantity" validation:"required"`
Status string `json:"status" validation:"required"`
OrderType string `json:"orderType" validation:"required"`
Side string `json:"side" validation:"required"`
TimeInForce string `json:"timeInForce" validation:"required"`
}
type PlaceOrderRejectResponse ¶
type PlaceOrderRejectResponse struct {
Error string `json:"error" validation:"required"`
}
type PlaceOrderRequest ¶
type PlaceOrderRequest struct {
Orders []Order `json:"orders"`
}
type PlaceOrderResponse ¶
type PlaceOrderResponsePlain ¶
type PortfolioAccountLedger ¶
type PortfolioAccountLedger struct {
Base AccountLedger `json:"BASE" validation:"required"`
}
type PortfolioSubaccount ¶
type PortfolioSubaccount struct {
ID string `json:"id" validation:"required"`
Currency string `json:"currency" validation:"required"`
Type string `json:"type" validation:"required"`
BusinessType string `json:"businessType" validation:"required"`
IBEntity string `json:"ibEntity" validation:"required"`
ClearingStatus string `json:"clearingStatus" validation:"required"`
NoClientTrading bool `json:"noClientTrading" validation:"required"`
}
type Position ¶
type Position struct {
AccountID string `json:"acctId" validation:"required"`
ConID int32 `json:"conid" validation:"required"`
ContractDesc string `json:"contractDesc" validation:"required"`
Position float64 `json:"position" validation:"required"`
MarketPrice float64 `json:"mktPrice" validation:"required"`
MarketValue float64 `json:"mktValue" validation:"required"`
AveragePrice float64 `json:"avgPrice" validation:"required"`
AverageCost float64 `json:"avgCost" validation:"required"`
RealizedPnL float64 `json:"realizedPnl" validation:"required"`
UnrealizedPnL float64 `json:"unrealizedPnl" validation:"required"`
Name string `json:"name" validation:"required"`
Ticker string `json:"ticker" validation:"required"`
PageSize int32 `json:"pageSize" validation:"required"`
}
type ServerInfo ¶
type SupressMessagesRequest ¶ added in v0.4.0
type SupressMessagesRequest struct {
MessageIDs []string `json:"messageIds"`
}
type SwitchAccountRequest ¶
type SwitchAccountRequest struct {
AccountID string `json:"acctId"`
}
type SwitchAccountResponse ¶
type SwitchAccountResponseAlreadySet ¶ added in v1.1.1
type SwitchAccountResponseAlreadySet struct {
Success string `json:"success" validate:"required"`
}
type TickleResponse ¶
type TickleResponse struct {
Session string `json:"session" validation:"required"`
SSOExpires int32 `json:"ssoExpires" validation:"required"`
Collission bool `json:"collission" validation:"required"`
UserID int32 `json:"userId" validation:"required"`
HMDS HMDSDetails `json:"hmds" validation:"required"`
IServer IServerDetails `json:"iserver" validation:"required"`
}
Click to show internal directories.
Click to hide internal directories.