Documentation
¶
Index ¶
- Constants
- type AdjustType
- type Brokers
- type BrokersData
- type CalcIndex
- type Candlestick
- type CandlestickRequestOption
- type CandlestickTradeSession
- type Capital
- type CapitalDistribution
- type CapitalFlowLine
- type Depth
- type DepthData
- type EventType
- type IntradayLine
- type Issuer
- type IssuerInfo
- type MarketPackageDetail
- type MarketTradingDay
- type MarketTradingSession
- type Option
- func OnReconnect(fn func(successResub bool)) Option
- func WithEnableOvernight(enable bool) Option
- func WithHttpClient(client *http.Client) Option
- func WithLanguage(language openapi.Language) Option
- func WithLbOptions(opts *longbridge.Options) Option
- func WithLogLevel(level string) Option
- func WithLogger(l log.Logger) Option
- func WithQuoteURL(url string) Option
- type OptionExtend
- type OptionQuote
- type Options
- type PackageDetail
- type ParticipantInfo
- type Period
- type PrePostQuote
- type PushBrokers
- type PushDepth
- type PushQuote
- type PushTrade
- type Quote
- type QuoteContext
- func (c *QuoteContext) Brokers(ctx context.Context, symbol string) (securityBrokers *SecurityBrokers, err error)
- func (c *QuoteContext) CalcIndex(ctx context.Context, symbols []string, indexes []CalcIndex) (calcIndexes []*SecurityCalcIndex, err error)
- func (c *QuoteContext) Candlesticks(ctx context.Context, symbol string, period Period, count int32, ...) (sticks []*Candlestick, err error)
- func (c *QuoteContext) CapitalDistribution(ctx context.Context, symbol string) (capitalDib CapitalDistribution, err error)
- func (c *QuoteContext) CapitalFlow(ctx context.Context, symbol string) (capitalFlowLines []CapitalFlowLine, err error)
- func (c *QuoteContext) Close() error
- func (c *QuoteContext) CreateWatchlistGroup(ctx context.Context, name string, symbols []string) (gid int64, err error)
- func (c *QuoteContext) DeleteWatchlistGroup(ctx context.Context, id int64, purge bool) (err error)
- func (c *QuoteContext) Depth(ctx context.Context, symbol string) (securityDepth *SecurityDepth, err error)
- func (c *QuoteContext) HistoryCandlesticksByDate(ctx context.Context, symbol string, period Period, adjustType AdjustType, ...) (sticks []*Candlestick, err error)
- func (c *QuoteContext) HistoryCandlesticksByOffset(ctx context.Context, symbol string, period Period, adjustType AdjustType, ...) (sticks []*Candlestick, err error)
- func (c *QuoteContext) Intraday(ctx context.Context, symbol string) (lines []*IntradayLine, err error)
- func (c *QuoteContext) OnBrokers(f func(*PushBrokers))
- func (c *QuoteContext) OnDepth(f func(*PushDepth))
- func (c *QuoteContext) OnQuote(f func(*PushQuote))
- func (c *QuoteContext) OnTrade(f func(*PushTrade))
- func (c *QuoteContext) OptionChainExpiryDateList(ctx context.Context, symbol string) (times []time.Time, err error)
- func (c *QuoteContext) OptionChainInfoByDate(ctx context.Context, symbol string, expiryDate *time.Time) (strikePriceInfos []*StrikePriceInfo, err error)
- func (c *QuoteContext) OptionQuote(ctx context.Context, symbols []string) (optionQuotes []*OptionQuote, err error)
- func (c *QuoteContext) Participants(ctx context.Context) (infos []*ParticipantInfo, err error)
- func (c *QuoteContext) Profile() *UserProfile
- func (c *QuoteContext) Quote(ctx context.Context, symbols []string) (quotes []*SecurityQuote, err error)
- func (c *QuoteContext) RealtimeBrokers(ctx context.Context, symbol string) (*SecurityBrokers, error)
- func (c *QuoteContext) RealtimeDepth(ctx context.Context, symbol string) (*SecurityDepth, error)
- func (c *QuoteContext) RealtimeQuote(ctx context.Context, symbols []string) ([]*Quote, error)
- func (c *QuoteContext) RealtimeTrades(ctx context.Context, symbol string) ([]*Trade, error)
- func (c *QuoteContext) SecurityList(ctx context.Context, market openapi.Market, category SecurityListCategory) (list []*Security, err error)
- func (c *QuoteContext) StaticInfo(ctx context.Context, symbols []string) (staticInfos []*StaticInfo, err error)
- func (c *QuoteContext) Subscribe(ctx context.Context, symbols []string, subTypes []SubType, isFirstPush bool) (err error)
- func (c *QuoteContext) Subscriptions(ctx context.Context) (subscriptions map[string][]SubType, err error)
- func (c *QuoteContext) Trades(ctx context.Context, symbol string, count int32) (trades []*Trade, err error)
- func (c *QuoteContext) TradingDays(ctx context.Context, market openapi.Market, begin *time.Time, end *time.Time) (days *MarketTradingDay, err error)
- func (c *QuoteContext) TradingSession(ctx context.Context) (sessions []*MarketTradingSession, err error)
- func (c *QuoteContext) Unsubscribe(ctx context.Context, unSubAll bool, symbols []string, subTypes []SubType) (err error)
- func (c *QuoteContext) UpdateWatchlistGroup(ctx context.Context, id int64, name string, symbols []string, ...) (err error)
- func (c *QuoteContext) WarrantIssuers(ctx context.Context) (infos []*IssuerInfo, err error)
- func (c *QuoteContext) WarrantList(ctx context.Context, symbol string, config WarrantFilter, lang WarrantLanguage) (infos []*WarrantInfo, err error)
- func (c *QuoteContext) WarrantQuote(ctx context.Context, symbols []string) (warrantQuotes []*WarrantQuote, err error)
- func (c *QuoteContext) WatchedGroups(ctx context.Context) (groupList []*WatchedGroup, err error)
- type QuoteData
- type RateLimit
- type Security
- type SecurityBrokers
- type SecurityCalcIndex
- type SecurityDepth
- type SecurityListCategory
- type SecurityQuote
- type StaticInfo
- type StrikePriceInfo
- type SubType
- type Trade
- type TradeDate
- type TradePeriod
- type TradeSession
- type TradeSessionType
- type TradeStatus
- type TradesData
- type UserProfile
- type UserQuoteLevelDetail
- type WarrantExpiryDateType
- type WarrantExtend
- type WarrantFilter
- type WarrantInOutBoundsType
- type WarrantInfo
- type WarrantLanguage
- type WarrantQuote
- type WarrantSortBy
- type WarrantSortOrder
- type WarrantStatus
- type WarrantType
- type WatchedGroup
- type WatchedSecurity
- type WatchlistUpdateMode
Constants ¶
const ( // SubType SubTypeUnknown SubType = SubType(quotev1.SubType_UNKNOWN_TYPE) SubTypeQuote SubType = SubType(quotev1.SubType_QUOTE) SubTypeDepth SubType = SubType(quotev1.SubType_DEPTH) SubTypeBrokers SubType = SubType(quotev1.SubType_BROKERS) SubTypeTrade SubType = SubType(quotev1.SubType_TRADE) // SubEvent EventQuote EventType = iota EventBroker EventTrade EventDepth // Period PeriodOneMinute = Period(quotev1.Period_ONE_MINUTE) PeriodFiveMinute = Period(quotev1.Period_FIVE_MINUTE) PeriodFifteenMinute = Period(quotev1.Period_FIFTEEN_MINUTE) PeriodThirtyMinute = Period(quotev1.Period_THIRTY_MINUTE) PeriodSixtyMinute = Period(quotev1.Period_SIXTY_MINUTE) PeriodDay = Period(quotev1.Period_DAY) PeriodWeek = Period(quotev1.Period_WEEK) PeriodMonth = Period(quotev1.Period_MONTH) PeriodYear = Period(quotev1.Period_YEAR) // AdjustType AdjustTypeNo = AdjustType(quotev1.AdjustType_NO_ADJUST) AdjustTypeForward = AdjustType(quotev1.AdjustType_FORWARD_ADJUST) // TradeSession TradeSessionNormal = TradeSession(quotev1.TradeSession_NORMAL_TRADE) TradeSessionPreTrade = TradeSession(quotev1.TradeSession_PRE_TRADE) TradeSessionPostTrade = TradeSession(quotev1.TradeSession_POST_TRADE) TradeSessionOvernight = TradeSession(quotev1.TradeSession_OVERNIGHT_TRADE) // CandlestickTradeSessionNormal includes normal trade session CandlestickTradeSessionNormal = CandlestickTradeSession(0) // CandlestickTradeSessionAll includes all trade sessions CandlestickTradeSessionAll = CandlestickTradeSession(100) // CalcIndex CalcIndexUnknown CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_UNKNOWN) CalcIndexLastDone CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_LAST_DONE) CalcIndexChangeVal CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CHANGE_VAL) CalcIndexChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CHANGE_RATE) CalcIndexVolume CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_VOLUME) CalcIndexTurnover CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TURNOVER) CalcIndexYtdChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_YTD_CHANGE_RATE) CalcIndexTurnoverRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TURNOVER_RATE) CalcIndexTotalMarketValue CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TOTAL_MARKET_VALUE) CalcIndexCapitalFlow CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CAPITAL_FLOW) CalcIndexAmplitude CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_AMPLITUDE) CalcIndexVolumeRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_VOLUME_RATIO) CalcIndexPeTTMRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_PE_TTM_RATIO) CalcIndexPbRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_PB_RATIO) CalcIndexDividendRatioTTM CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_DIVIDEND_RATIO_TTM) CalcIndexFiveDayChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_FIVE_DAY_CHANGE_RATE) CalcIndexTenDayChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TEN_DAY_CHANGE_RATE) CalcIndexHalfYearChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_HALF_YEAR_CHANGE_RATE) CalcIndexFiveMinutesChangeRate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_FIVE_MINUTES_CHANGE_RATE) CalcIndexExpiryDate CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_EXPIRY_DATE) CalcIndexStrikePrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_STRIKE_PRICE) CalcIndexUpperStrikePrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_UPPER_STRIKE_PRICE) CalcIndexLowerStrikePrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_LOWER_STRIKE_PRICE) CalcIndexOutstandingQTY CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_OUTSTANDING_QTY) CalcIndexOutstandingRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_OUTSTANDING_RATIO) CalcIndexPremium CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_PREMIUM) CalcIndexItmOtm CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_ITM_OTM) CalcIndexImpliedVolatility CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_IMPLIED_VOLATILITY) CalcIndexWarrantDelta CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_WARRANT_DELTA) CalcIndexCallPrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CALL_PRICE) CalcIndexToCallPrice CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_TO_CALL_PRICE) CalcIndexEffectiveLeverage CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_EFFECTIVE_LEVERAGE) CalcIndexLeverageRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_LEVERAGE_RATIO) CalcIndexConversionRatio CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_CONVERSION_RATIO) CalcIndexBalancePoint CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_BALANCE_POINT) CalcIndexOpenInterest CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_OPEN_INTEREST) CalcIndexDELTA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_DELTA) CalcIndexGAMMA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_GAMMA) CalcIndexTHETA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_THETA) CalcIndexVEGA CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_VEGA) CalcIndexRHO CalcIndex = CalcIndex(quotev1.CalcIndex_CALCINDEX_RHO) )
const (
DefaultQuoteUrl = "wss://openapi-quote.longportapp.com/v2"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdjustType ¶
type AdjustType int32
type BrokersData ¶
type Candlestick ¶
type Candlestick struct {
Close *decimal.Decimal
Open *decimal.Decimal
Low *decimal.Decimal
High *decimal.Decimal
Volume int64
Turnover *decimal.Decimal
Timestamp int64
}
Candlestick is candlestick details
type CandlestickRequestOption ¶ added in v0.17.0
type CandlestickRequestOption func(*quotev1.SecurityHistoryCandlestickRequest)
CandlestickRequestOption is the option for the candlestick request
func CandlestickRequestTradeSession ¶ added in v0.17.0
func CandlestickRequestTradeSession(session CandlestickTradeSession) CandlestickRequestOption
CandlestickRequestTradeSession sets the trade session of the candlestick request
type CandlestickTradeSession ¶ added in v0.17.1
type CandlestickTradeSession int32
type CapitalDistribution ¶
type CapitalDistribution struct {
Symbol string
Timestamp int64 // data update timestamp
CapitalIn Capital // inflow capital data
CapitalOut Capital // outflow capital data
}
CapitalDistribution information
type CapitalFlowLine ¶
CapitalFlowLine
type IntradayLine ¶
type IntradayLine struct {
Price *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
AvgPrice *decimal.Decimal
}
IntradayLine is k line
type IssuerInfo ¶
IssuerInfo is issuer infomation
type MarketPackageDetail ¶ added in v0.16.0
type MarketTradingDay ¶
MarketTradingDay contains market open trade days
type MarketTradingSession ¶
type MarketTradingSession struct {
Market openapi.Market
TradeSession []*TradePeriod
}
MarketTradingSession is market's session details
type Option ¶
type Option func(*Options)
Option for quote context
func OnReconnect ¶ added in v0.16.2
OnReconnect to set reconnect callbacks for quote context
func WithEnableOvernight ¶ added in v0.13.0
WithEnableOvernight to set enable overnight for quote context
func WithHttpClient ¶
WithHttpClient to set http client for quote context
func WithLanguage ¶ added in v0.16.0
WithLanguage to set language for quote context
func WithLbOptions ¶
func WithLbOptions(opts *longbridge.Options) Option
WithLbOptions to set longbridge options for quote context
func WithLogLevel ¶
WithLogLevel to set log level for quote context
type OptionExtend ¶
type OptionExtend struct {
ImpliedVolatility string
OpenInterest int64
ExpiryDate string // YYMMDD
StrikePrice *decimal.Decimal
ContractMultiplier string
ContractType string
ContractSize string
Direction string
HistoricalVolatility string
UnderlyingSymbol string
}
OptionExtend is option extended properties
type OptionQuote ¶
type OptionQuote struct {
Symbol string
LastDone *decimal.Decimal
PrevClose *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
OptionExtend *OptionExtend
}
OptionQuote to option quote details
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options for quote context
type PackageDetail ¶ added in v0.16.0
type ParticipantInfo ¶
type ParticipantInfo struct {
BrokerIds []int32
ParticipantNameCn string
ParticipantNameEn string
ParticipantNameHk string
}
ParticipantInfo has all participant brokers
type PrePostQuote ¶
type PrePostQuote struct {
LastDone *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
PrevClose *decimal.Decimal
}
PrePostQuote is pre or post quote details
type PushBrokers ¶
type PushBrokers struct {
Symbol string
Sequence int64
AskBrokers []*Brokers
BidBrokers []*Brokers
}
PushBrokers is brokers info push from server
type PushQuote ¶
type PushQuote struct {
Symbol string
Sequence int64
LastDone *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
TradeSession TradeSessionType
}
PushQuote is quote info push from server
type Quote ¶
type Quote struct {
Symbol string
LastDone *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
TradeSession TradeSessionType
}
Quote is quote details
type QuoteContext ¶
type QuoteContext struct {
// contains filtered or unexported fields
}
func New ¶
func New(opt ...Option) (*QuoteContext, error)
New return QuoteContext with option. A connection will be created with quote server.
func NewFormEnv
deprecated
func NewFormEnv() (*QuoteContext, error)
Deprecated: NewFromEnv return QuoteContext, use NewFromCfg plz
func NewFromCfg ¶
func NewFromCfg(cfg *config.Config) (*QuoteContext, error)
NewFromCfg return QuoteContext with config.Config
func (*QuoteContext) Brokers ¶
func (c *QuoteContext) Brokers(ctx context.Context, symbol string) (securityBrokers *SecurityBrokers, err error)
Brokers obtain the real-time broker queue data of security. Reference: https://open.longportapp.com/en/docs/quote/pull/brokers
Example:
qctx, err := quote.NewFromEnv() brokers, err := qctx.Brokers(context.Background(), "AAPL.HK")
func (*QuoteContext) CalcIndex ¶
func (c *QuoteContext) CalcIndex(ctx context.Context, symbols []string, indexes []CalcIndex) (calcIndexes []*SecurityCalcIndex, err error)
CalcIndex is used to obtain the calculate indexes of securities. Reference: https://open.longportapp.com/en/docs/quote/pull/calc-index
Example:
qctx, err := quote.NewFromEnv() flowlines, err := qctx.CapitalFlow(context.Background(), "700.HK")
func (*QuoteContext) Candlesticks ¶
func (c *QuoteContext) Candlesticks(ctx context.Context, symbol string, period Period, count int32, adjustType AdjustType) (sticks []*Candlestick, err error)
Candlesticks obtain the candlestick data of security. Reference: https://open.longportapp.com/en/docs/quote/pull/candlestick periond support values:
- quote.PeriodOneMinute - 1m
- quote.PeriodFiveMinute - 5m
- quote.PeriodFifteenMinute - 15m
- quote.PeriodThirtyMinute - 40m
- quote.PeriodDay - 1 day
- quote.PeriodWeek - 1 week
- quote.PeriodMonth - 1 month
- quote.PeriodYear - 1 year
adjustType support values:
- quote.AdjustTypeNo
- quote.AdjustTypeForward
Example:
qctx, err := quote.NewFromEnv() klines, err := qctx.Candlesticks(context.Background(), "AAPL.US", quote.PeriodDay, 10, quote.AdjustTypeNo)
func (*QuoteContext) CapitalDistribution ¶
func (c *QuoteContext) CapitalDistribution(ctx context.Context, symbol string) (capitalDib CapitalDistribution, err error)
CapitalDistribution is used to obtain the daily capital distribution of security. Reference: https://open.longportapp.com/en/docs/quote/pull/capital-distribution
Example:
qctx, err := quote.NewFromEnv() dist, err := qctx.CapitalDistribution(context.Background(), "700.HK")
func (*QuoteContext) CapitalFlow ¶
func (c *QuoteContext) CapitalFlow(ctx context.Context, symbol string) (capitalFlowLines []CapitalFlowLine, err error)
CapitalFlow is used to obtain the daily capital flow intraday of security. Reference: https://open.longportapp.com/en/docs/quote/pull/capital-flow-intraday
Example:
qctx, err := quote.NewFromEnv() flowlines, err := qctx.CapitalFlow(context.Background(), "700.HK")
func (*QuoteContext) CreateWatchlistGroup ¶ added in v0.12.0
func (c *QuoteContext) CreateWatchlistGroup(ctx context.Context, name string, symbols []string) (gid int64, err error)
CreateWatchlistGroup use to create watchlist group. Doc: https://open.longportapp.com/en/docs/quote/individual/watchlist_create_group
Example:
qctx, err := quote.NewFromCfg(conf)
// handle error
err = qctx.CreateWatchlistGroup(context.Background(), "test", []string{"AAPL.US"})
qctx, err := quote.NewFromCfg(conf)
// ignore handle error
err = qctx.CreateWatchlistGroup(context.Background(), "test", []string{"AAPL.US"})
func (*QuoteContext) DeleteWatchlistGroup ¶ added in v0.12.0
func (*QuoteContext) Depth ¶
func (c *QuoteContext) Depth(ctx context.Context, symbol string) (securityDepth *SecurityDepth, err error)
Depth obtain the depth data of security. Reference: https://open.longportapp.com/en/docs/quote/pull/depth
Example:
qctx, err := quote.NewFromEnv()
depth, err := qctx.Depth(context.Background(), []string{"AAPL.HK"})
func (*QuoteContext) HistoryCandlesticksByDate ¶ added in v0.13.0
func (c *QuoteContext) HistoryCandlesticksByDate(ctx context.Context, symbol string, period Period, adjustType AdjustType, startDate *time.Time, endDate *time.Time, opts ...CandlestickRequestOption) (sticks []*Candlestick, err error)
HistoryCandlesticksByOffset obtains the history candlestick data of security after or before an offset time. Reference: https://open.longportapp.com/en/docs/quote/pull/history-candlestick periond support values:
- quote.PeriodOneMinute - 1m
- quote.PeriodFiveMinute - 5m
- quote.PeriodFifteenMinute - 15m
- quote.PeriodThirtyMinute - 40m
- quote.PeriodDay - 1 day
- quote.PeriodWeek - 1 week
- quote.PeriodMonth - 1 month
- quote.PeriodYear - 1 year
adjustType support values:
- quote.AdjustTypeNo
- quote.AdjustTypeForward
Example:
qctx, err := quote.NewFromEnv() startDate := time.Date(2022, 5, 10, 0, 0, 0, 0, time.UTC) endDate := time.Date(2022, 6, 10, 0, 0, 0, 0, time.UTC) klines, err := qctx.HistoryCandlesticksByDate(context.Background(), "AAPL.US", quote.PeriodDay, quote.AdjustTypeNo, &startDate, &endDate)
func (*QuoteContext) HistoryCandlesticksByOffset ¶ added in v0.13.0
func (c *QuoteContext) HistoryCandlesticksByOffset(ctx context.Context, symbol string, period Period, adjustType AdjustType, isForward bool, dateTime *time.Time, count int32, opts ...CandlestickRequestOption) (sticks []*Candlestick, err error)
HistoryCandlesticksByDate obtains the history candlestick data of security within a date range. Reference: https://open.longportapp.com/en/docs/quote/pull/history-candlestick periond support values:
- quote.PeriodOneMinute - 1m
- quote.PeriodFiveMinute - 5m
- quote.PeriodFifteenMinute - 15m
- quote.PeriodThirtyMinute - 40m
- quote.PeriodDay - 1 day
- quote.PeriodWeek - 1 week
- quote.PeriodMonth - 1 month
- quote.PeriodYear - 1 year
adjustType support values:
- quote.AdjustTypeNo
- quote.AdjustTypeForward
Example:
qctx, err := quote.NewFromEnv() dateTime := time.Date(2022, 5, 10, 11, 10, 0, 0, time.UTC) klines, err := qctx.HistoryCandlesticksByOffset(context.Background(), "AAPL.US", quote.PeriodDay, quote.AdjustTypeNo, true, &dateTime, 100)
func (*QuoteContext) Intraday ¶
func (c *QuoteContext) Intraday(ctx context.Context, symbol string) (lines []*IntradayLine, err error)
Intraday obtain the intraday data of security. Reference: https://open.longportapp.com/en/docs/quote/pull/intraday Example:
qctx, err := quote.NewFromEnv() trades, err := qctx.Intraday(context.Background(), "AAPL.US")
func (*QuoteContext) OnBrokers ¶
func (c *QuoteContext) OnBrokers(f func(*PushBrokers))
OnBrokers set callback function which will be called when server push brokers events.
func (*QuoteContext) OnDepth ¶
func (c *QuoteContext) OnDepth(f func(*PushDepth))
OnDepth set callback function which will be called when server push depth events.
func (*QuoteContext) OnQuote ¶
func (c *QuoteContext) OnQuote(f func(*PushQuote))
OnQuote set callback function which will be called when server push quote events.
func (*QuoteContext) OnTrade ¶
func (c *QuoteContext) OnTrade(f func(*PushTrade))
OnTrade set callback function which will be called when server push trade events.
func (*QuoteContext) OptionChainExpiryDateList ¶
func (c *QuoteContext) OptionChainExpiryDateList(ctx context.Context, symbol string) (times []time.Time, err error)
OptionChainExpiryDateList obtain the the list of expiration dates of option chain Reference: https://open.longportapp.com/en/docs/quote/pull/optionchain-date
Example:
qctx, err := quote.NewFromEnv() list, err := qctx.OptionChainExpiryDateList(context.Background(), "AAPL.US")
func (*QuoteContext) OptionChainInfoByDate ¶
func (c *QuoteContext) OptionChainInfoByDate(ctx context.Context, symbol string, expiryDate *time.Time) (strikePriceInfos []*StrikePriceInfo, err error)
OptionChainInfoByDate obtain a list of option securities by the option chain expiry date. Reference: https://open.longportapp.com/en/docs/quote/pull/optionchain-date-strike
Example:
qctx, err := quote.NewFromEnv() date := time.Date(2022, 5, 10, 0, 0, 0, 0, time.UTC) list, err := qctx.OptionChainInfoByDate(context.Background(), "AAPL.US", &date)
func (*QuoteContext) OptionQuote ¶
func (c *QuoteContext) OptionQuote(ctx context.Context, symbols []string) (optionQuotes []*OptionQuote, err error)
OptionQuote obtain the real-time quotes of US stock options, including the option-specific data. Reference: https://open.longportapp.com/en/docs/quote/pull/option-quote
Example:
qctx, err := quote.NewFromEnv()
optionQuotes, err := qctx.OptionQuote(context.Background(), []string{"AAPL240531P192500.US"})
func (*QuoteContext) Participants ¶
func (c *QuoteContext) Participants(ctx context.Context) (infos []*ParticipantInfo, err error)
Participants obtain participant IDs data (which can be synchronized once a day). Reference: https://open.longportapp.com/en/docs/quote/pull/broker-ids
Example:
qctx, err := quote.NewFromEnv() participants, err := qctx.Participants(context.Background())
func (*QuoteContext) Profile ¶ added in v0.16.0
func (c *QuoteContext) Profile() *UserProfile
Profile obtain the user quote profile
func (*QuoteContext) Quote ¶
func (c *QuoteContext) Quote(ctx context.Context, symbols []string) (quotes []*SecurityQuote, err error)
Quote obtain the real-time quotes of securities, and supports all types of securities. Reference: https://open.longportapp.com/en/docs/quote/pull/quote
Example:
qctx, err := quote.NewFromEnv()
quotes, err := qctx.Quote(context.Background(), []string{"AAPL.US"})
func (*QuoteContext) RealtimeBrokers ¶
func (c *QuoteContext) RealtimeBrokers(ctx context.Context, symbol string) (*SecurityBrokers, error)
RealtimeBrokers to get broker infomations on local store
Example:
qctx, err := quote.NewFromEnv() brokers, err := qctx.RealtimeBrokers(context.Background(), "700.HK")
func (*QuoteContext) RealtimeDepth ¶
func (c *QuoteContext) RealtimeDepth(ctx context.Context, symbol string) (*SecurityDepth, error)
RealtimeDepth to get depth infomations on local store
Example:
qctx, err := quote.NewFromEnv() depth, err := qctx.RealtimeDepth(context.Background(), "700.HK")
func (*QuoteContext) RealtimeQuote ¶
RealtimeQuote to get quote infomations on local store
Example:
qctx, err := quote.NewFromEnv()
flowlines, err := qctx.RealtimeQuote(context.Background(), []string{"700.HK", "9988.HK"})
func (*QuoteContext) RealtimeTrades ¶
RealtimeTrades to get trade infomations on local store
Example:
qctx, err := quote.NewFromEnv() trades, err := qctx.RealtimeTrades(context.Background(), "700.HK")
func (*QuoteContext) SecurityList ¶ added in v0.12.0
func (c *QuoteContext) SecurityList(ctx context.Context, market openapi.Market, category SecurityListCategory) (list []*Security, err error)
SecurityList used to list securities. Doc: https://open.longportapp.com/en/docs/quote/security/security_list
func (*QuoteContext) StaticInfo ¶
func (c *QuoteContext) StaticInfo(ctx context.Context, symbols []string) (staticInfos []*StaticInfo, err error)
func (*QuoteContext) Subscribe ¶
func (c *QuoteContext) Subscribe(ctx context.Context, symbols []string, subTypes []SubType, isFirstPush bool) (err error)
Subscribe quote Reference: https://open.longportapp.com/en/docs/quote/subscribe/subscribe
func (*QuoteContext) Subscriptions ¶
func (c *QuoteContext) Subscriptions(ctx context.Context) (subscriptions map[string][]SubType, err error)
Subscriptions obtain the subscription information. Reference: https://open.longportapp.com/en/docs/quote/subscribe/subscription
Example:
qctx, err := quote.NewFromEnv() subs, err := qctx.Subscriptions(context.Background())
func (*QuoteContext) Trades ¶
func (c *QuoteContext) Trades(ctx context.Context, symbol string, count int32) (trades []*Trade, err error)
Trades obtain the trades data of security. Reference: https://open.longportapp.com/en/docs/quote/pull/trade
Example:
qctx, err := quote.NewFromEnv() trades, err := qctx.Trades(context.Background())
func (*QuoteContext) TradingDays ¶
func (c *QuoteContext) TradingDays(ctx context.Context, market openapi.Market, begin *time.Time, end *time.Time) (days *MarketTradingDay, err error)
TradingDays obtain the trading days of the market. Reference: https://open.longportapp.com/en/docs/quote/pull/trade-day
Example:
qctx, err := quote.NewFromEnv() begin := time.Date(2024, 5, 1, 0, 0, 0, 0, time.UTC) end := time.Date(2024, 6, 1, 0, 0, 0, 0, time.UTC) days, err := qctx.TradingDays(context.Background(), openapi.MarketUS, &begin, &end)
func (*QuoteContext) TradingSession ¶
func (c *QuoteContext) TradingSession(ctx context.Context) (sessions []*MarketTradingSession, err error)
TradingSession obtain the daily trading hours of each market. Reference: https://open.longportapp.com/en/docs/quote/pull/trade-session
Example:
qctx, err := quote.NewFromEnv() sess, err := qctx.TradingSession(context.Background())
func (*QuoteContext) Unsubscribe ¶
func (c *QuoteContext) Unsubscribe(ctx context.Context, unSubAll bool, symbols []string, subTypes []SubType) (err error)
Unsubscribe quote Reference: https://open.longportapp.com/en/docs/quote/subscribe/unsubscribe
func (*QuoteContext) UpdateWatchlistGroup ¶ added in v0.12.0
func (c *QuoteContext) UpdateWatchlistGroup(ctx context.Context, id int64, name string, symbols []string, mode WatchlistUpdateMode) (err error)
func (*QuoteContext) WarrantIssuers ¶
func (c *QuoteContext) WarrantIssuers(ctx context.Context) (infos []*IssuerInfo, err error)
WarrantIssuers obtain the warrant issuer IDs data (which can be synchronized once a day). Reference: https://open.longportapp.com/en/docs/quote/pull/issuer
Example:
qctx, err := quote.NewFromEnv() infos, err := qctx.WarrantIssuers(context.Background())
func (*QuoteContext) WarrantList ¶ added in v0.10.0
func (c *QuoteContext) WarrantList(ctx context.Context, symbol string, config WarrantFilter, lang WarrantLanguage) (infos []*WarrantInfo, err error)
WarrantIssuers obtain the quotes of HK warrants, and supports sorting and filtering. Reference: https://open.longportapp.com/en/docs/quote/pull/warrant-filter
Example:
qctx, err := quote.NewFromEnv()
list, err := qctx.WarrantList(context.Background(), "9988.HK", quote.WarrantFilter{
SortBy: quote.WarrantLastDone,
SortOrder quote.WarrantAsc,
SortOffset: 0,
SortCount: 20,
Type: []quote.WarrantType{quote.WarrantCall, quote.WarrantPut},
}, quote. WarrantZH_CN)
func (*QuoteContext) WarrantQuote ¶
func (c *QuoteContext) WarrantQuote(ctx context.Context, symbols []string) (warrantQuotes []*WarrantQuote, err error)
WarrantQuote obtain the real-time quotes of HK warrants, including the warrant-specific data. Reference: https://open.longportapp.com/en/docs/quote/pull/warrant-quote
Example:
qctx, err := quote.NewFromEnv()
warrantQuotes, err := qctx.WarrantQuote(context.Background(), []string{"9988.HK"})
func (*QuoteContext) WatchedGroups ¶
func (c *QuoteContext) WatchedGroups(ctx context.Context) (groupList []*WatchedGroup, err error)
type SecurityBrokers ¶
SecurityBrokers is security brokers details
type SecurityCalcIndex ¶
type SecurityCalcIndex struct {
Symbol string
LastDone *decimal.Decimal
ChangeVal *decimal.Decimal
ChangeRate *decimal.Decimal
Volume int64
Turnover *decimal.Decimal
YtdChangeRate *decimal.Decimal
TurnoverRate *decimal.Decimal
TotalMarketValue *decimal.Decimal
CapitalFlow *decimal.Decimal
Amplitude *decimal.Decimal
VolumeRatio *decimal.Decimal
PeTtmRatio *decimal.Decimal
PbRatio *decimal.Decimal
DividendRatioTtm *decimal.Decimal
FiveDayChangeRate *decimal.Decimal
TenDayChangeRate *decimal.Decimal
HalfYearChangeRate *decimal.Decimal
FiveMinutesChangeRate *decimal.Decimal
ExpiryDate string
StrikePrice *decimal.Decimal
UpperStrikePrice *decimal.Decimal
LowerStrikePrice *decimal.Decimal
OutstandingQty *decimal.Decimal
OutstandingRatio *decimal.Decimal
Premium *decimal.Decimal
ItmOtm *decimal.Decimal
ImpliedVolatility *decimal.Decimal
WarrantDelta *decimal.Decimal
CallPrice *decimal.Decimal
ToCallPrice *decimal.Decimal
EffectiveLeverage *decimal.Decimal
LeverageRatio *decimal.Decimal
ConversionRatio *decimal.Decimal
BalancePoint *decimal.Decimal
OpenInterest int64
Delta *decimal.Decimal
Gamma *decimal.Decimal
Theta *decimal.Decimal
Vega *decimal.Decimal
Rho *decimal.Decimal
}
SecurityCalcIndex the infomation of calculate indexes's security
type SecurityDepth ¶
SecurityDepth
type SecurityListCategory ¶ added in v0.12.0
type SecurityListCategory string
const (
Overnight SecurityListCategory = "Overnight"
)
type SecurityQuote ¶
type SecurityQuote struct {
Symbol string
LastDone *decimal.Decimal
PrevClose *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
PreMarketQuote *PrePostQuote
PostMarketQuote *PrePostQuote
OverNightQuote *PrePostQuote
}
SecurityQuote is quote details with pre market and post market
type StaticInfo ¶
type StaticInfo struct {
Symbol string
NameCn string
NameEn string
NameHk string
Exchange string
Currency string
LotSize int32
Eps *decimal.Decimal
EpsTtm *decimal.Decimal
Bps *decimal.Decimal
DividendYield string
StockDerivatives []int32
}
StaticInfo store static details
type StrikePriceInfo ¶
type StrikePriceInfo struct {
Price *decimal.Decimal
CallSymbol string
PutSymbol string
Standard bool
}
StrikePriceInfo is strike price details
type Trade ¶
type Trade struct {
Price string
Volume int64
Timestamp int64
// TradeType
// HK
//
// - `*` - Overseas trade
// - `D` - Odd-lot trade
// - `M` - Non-direct off-exchange trade
// - `P` - Late trade (Off-exchange previous day)
// - `U` - Auction trade
// - `X` - Direct off-exchange trade
// - `Y` - Automatch internalized
// - `<empty string>` - Automatch normal
//
// US
//
// - `<empty string>` - Regular sale
// - `A` - Acquisition
// - `B` - Bunched trade
// - `D` - Distribution
// - `F` - Intermarket sweep
// - `G` - Bunched sold trades
// - `H` - Price variation trade
// - `I` - Odd lot trade
// - `K` - Rule 155 trde(NYSE MKT)
// - `M` - Market center close price
// - `P` - Prior reference price
// - `Q` - Market center open price
// - `S` - Split trade
// - `V` - Contingent trade
// - `W` - Average price trade
// - `X` - Cross trade
// - `1` - Stopped stock(Regular trade)
TradeType string
Direction int32
TradeSession TradeSession
}
Trade store trade details
type TradeDate ¶
type TradeDate struct {
Date string
TradeDateType int32 // 0 full day, 1 morning only, 2 afternoon only(not happened before)
}
TradeDate
type TradePeriod ¶
type TradePeriod struct {
BegTime int32
EndTime int32
TradeSession TradeSession
}
TradePeriod
type TradeSession ¶
type TradeSession int32
type TradeSessionType ¶
type TradeSessionType int32
type TradeStatus ¶
type TradeStatus int32
type TradesData ¶
type UserProfile ¶ added in v0.16.0
type UserQuoteLevelDetail ¶ added in v0.16.0
type UserQuoteLevelDetail struct {
ByPackageKey map[string]*PackageDetail
ByMarketCode map[string]*MarketPackageDetail
}
type WarrantExpiryDateType ¶ added in v0.10.0
type WarrantExpiryDateType int32
const ( WarrantLT3 WarrantExpiryDateType = iota + 1 // Less than three months WarrantBT3_6 // between three and six months WarrantBT6_12 // between six and twelve months WarrantGT12 // greate than twelve months )
type WarrantExtend ¶
type WarrantExtend struct {
ImpliedVolatility string
ExpiryDate string
LastTradeDate string
OutstandingRatio string
OutstandingQty int64
ConversionRatio string
Category string
StrikePrice *decimal.Decimal
UpperStrikePrice *decimal.Decimal
LowerStrikePrice *decimal.Decimal
CallPrice *decimal.Decimal
UnderlyingSymbol string
}
WarrantExtend is warrant extended properties
type WarrantFilter ¶ added in v0.10.0
type WarrantFilter struct {
SortBy WarrantSortBy
SortOrder WarrantSortOrder
SortOffset int32
SortCount int32
Type []WarrantType
Issuer []int32
ExpiryDate []WarrantExpiryDateType
PriceType []WarrantInOutBoundsType
Status []WarrantStatus
Language WarrantLanguage
}
type WarrantInOutBoundsType ¶ added in v0.10.0
type WarrantInOutBoundsType int32
const ( WarrantInBounds WarrantInOutBoundsType = iota + 1 WarrantOutBounds )
type WarrantInfo ¶ added in v0.10.0
type WarrantInfo struct {
Symbol string
Name string
LastDone *decimal.Decimal
ChangeRate *decimal.Decimal
ChangeVal *decimal.Decimal
Volume int64
Turnover *decimal.Decimal
ExpiryDate string
StrikePrice *decimal.Decimal
UpperStrikePrice *decimal.Decimal
LowerStrikePrice *decimal.Decimal
OutstandingQty *decimal.Decimal
OutstandingRatio *decimal.Decimal
Premium *decimal.Decimal
ItmOtm *decimal.Decimal
ImpliedVolatility *decimal.Decimal
Delta *decimal.Decimal
CallPrice *decimal.Decimal
ToCallPrice *decimal.Decimal
EffectiveLeverage *decimal.Decimal
LeverageRatio *decimal.Decimal
ConversionRatio *decimal.Decimal
BalancePoint *decimal.Decimal
Status WarrantStatus
}
WarrantInfo is info of warrant asset
type WarrantLanguage ¶ added in v0.10.0
type WarrantLanguage int32
const ( WarrantZH_CN WarrantLanguage = iota WarrantEN WarrantHK_CN )
type WarrantQuote ¶
type WarrantQuote struct {
Symbol string
LastDone *decimal.Decimal
PrevClose *decimal.Decimal
Open *decimal.Decimal
High *decimal.Decimal
Low *decimal.Decimal
Timestamp int64
Volume int64
Turnover *decimal.Decimal
TradeStatus TradeStatus
WarrantExtend *WarrantExtend
}
WarrantQuote is warrant quote details
type WarrantSortBy ¶ added in v0.10.0
type WarrantSortBy int32
const ( WarrantLastDone WarrantSortBy = iota WarrantChangeRate WarrantChangeVal WarrantVolume WarrantTurnover WarrantExpiryDate WarrantStrikePrice WarrantUpperStrikePrice WarrantLowerStrikePrice WarrantOutstandingQty WarrantOutstandingRatio WarrantPremiun WarrantItmOtm WarrantImpliedVolatility WarrantDelta WarrantCallPrice WarrantToCallPrice WarrantEffectiveLeverage WarrantLeverageRatio WarrantConversionRatio WarrantBalancePoint WarrantSortStatus )
type WarrantSortOrder ¶ added in v0.10.0
type WarrantSortOrder int32
const ( WarrantAsc WarrantSortOrder = iota WarrantDesc )
type WarrantStatus ¶ added in v0.10.0
type WarrantStatus int32
const ( WarrantSuspend WarrantStatus = iota + 2 // can't trade WarrantPapareList // wait to be listed WarrantNormal // Tradable )
Warrant status
type WarrantType ¶ added in v0.10.0
type WarrantType int32
const ( WarrantCall WarrantType = iota WarrantPut WarrantBull WarrantBear WarrantInline )
type WatchedGroup ¶
type WatchedGroup struct {
Id int64 // group id
Name string // group name
Securites []*WatchedSecurity
}
WatchedGroup a group of the security is watched
type WatchedSecurity ¶
type WatchedSecurity struct {
Symbol string
Market string
Name string
Price *decimal.Decimal
WatchedAt int64 // timestamp
}
WatchedSecurity the security is watched
type WatchlistUpdateMode ¶ added in v0.12.0
type WatchlistUpdateMode string
const ( // AddWatchlist will add securities to watchlist group AddWatchlist WatchlistUpdateMode = "add" // RemoveWatchlist will remove securities from watchlist group RemoveWatchlist WatchlistUpdateMode = "remove" // ReplaceWatchlist will replace securities in watchlist group // For example: // If the original group contains APPL.US, BABA.US, TSLA.US, // and it is updated with ["BABA.US", "AAPL.US", "MSFT.US"], // it will become BABA.US, AAPL.US, MSFT.US, // removing TSLA.US and adding MSFT.US, while adjusting the order of BABA.US and AAPL.US. ReplaceWatchlist WatchlistUpdateMode = "replace" )