Documentation
¶
Overview ¶
Package api talks to Quantic's /api/v1 (design §2).
api.gen.go is generated from api/openapi.json, Quantic's own OpenAPI document, by oapi-codegen; never edit it by hand. templates/imports.tmpl keeps the generated file's header from becoming a second package comment. client.go and retry.go are the thin wrapper the commands use: one method per endpoint, typed errors, and retrying a rate-limited request.
To follow a change in the API:
curl -sf https://quantic.finance/api/v1/openapi.json -o api/openapi.json go generate ./internal/api
Index ¶
- func NewClient(server string, opts ...ClientOption) (*genClient, error)
- func NewGetCalendarRequest(server string, params *GetCalendarParams) (*http.Request, error)
- func NewGetIncomeRequest(server string, params *GetIncomeParams) (*http.Request, error)
- func NewGetMeRequest(server string) (*http.Request, error)
- func NewGetStockRequest(server string, symbol string) (*http.Request, error)
- func NewListDividendsRequest(server string, params *ListDividendsParams) (*http.Request, error)
- func NewListHoldingsRequest(server string, params *ListHoldingsParams) (*http.Request, error)
- func NewListPortfoliosRequest(server string) (*http.Request, error)
- func NewSearchStocksRequest(server string, params *SearchStocksParams) (*http.Request, error)
- type Calendar
- type Client
- func (c *Client) Calendar(ctx context.Context, days int) (*Calendar, error)
- func (c *Client) Dividends(ctx context.Context, params ListDividendsParams) (*DividendList, error)
- func (c *Client) Holdings(ctx context.Context, params ListHoldingsParams) (*HoldingList, error)
- func (c *Client) Income(ctx context.Context, params GetIncomeParams) (*Income, error)
- func (c *Client) Me(ctx context.Context) (*Me, error)
- func (c *Client) Portfolios(ctx context.Context) (*PortfolioList, error)
- func (c *Client) SearchStocks(ctx context.Context, query string) (*StockSearch, error)
- func (c *Client) Stock(ctx context.Context, symbol string) (*Stock, error)
- type ClientInterface
- type ClientOption
- type ClientWithResponses
- func (c *ClientWithResponses) GetCalendarWithResponse(ctx context.Context, params *GetCalendarParams, reqEditors ...RequestEditorFn) (*GetCalendarResponse, error)
- func (c *ClientWithResponses) GetIncomeWithResponse(ctx context.Context, params *GetIncomeParams, reqEditors ...RequestEditorFn) (*GetIncomeResponse, error)
- func (c *ClientWithResponses) GetMeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetMeResponse, error)
- func (c *ClientWithResponses) GetStockWithResponse(ctx context.Context, symbol string, reqEditors ...RequestEditorFn) (*GetStockResponse, error)
- func (c *ClientWithResponses) ListDividendsWithResponse(ctx context.Context, params *ListDividendsParams, ...) (*ListDividendsResponse, error)
- func (c *ClientWithResponses) ListHoldingsWithResponse(ctx context.Context, params *ListHoldingsParams, reqEditors ...RequestEditorFn) (*ListHoldingsResponse, error)
- func (c *ClientWithResponses) ListPortfoliosWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListPortfoliosResponse, error)
- func (c *ClientWithResponses) SearchStocksWithResponse(ctx context.Context, params *SearchStocksParams, reqEditors ...RequestEditorFn) (*SearchStocksResponse, error)
- type ClientWithResponsesInterface
- type Config
- type Dividend
- type DividendList
- type Error
- type ErrorErrorCode
- type GetCalendarParams
- type GetCalendarResponse
- func (r GetCalendarResponse) ContentType() string
- func (r GetCalendarResponse) GetBody() []byte
- func (r GetCalendarResponse) GetJSON200() *Calendar
- func (r GetCalendarResponse) GetJSON422() *Error
- func (r GetCalendarResponse) GetJSON429() *Error
- func (r GetCalendarResponse) Status() string
- func (r GetCalendarResponse) StatusCode() int
- type GetIncomeParams
- type GetIncomeResponse
- func (r GetIncomeResponse) ContentType() string
- func (r GetIncomeResponse) GetBody() []byte
- func (r GetIncomeResponse) GetJSON200() *Income
- func (r GetIncomeResponse) GetJSON401() *Error
- func (r GetIncomeResponse) GetJSON422() *Error
- func (r GetIncomeResponse) Status() string
- func (r GetIncomeResponse) StatusCode() int
- type GetMeResponse
- type GetStockResponse
- func (r GetStockResponse) ContentType() string
- func (r GetStockResponse) GetBody() []byte
- func (r GetStockResponse) GetJSON200() *Stock
- func (r GetStockResponse) GetJSON404() *Error
- func (r GetStockResponse) GetJSON429() *Error
- func (r GetStockResponse) Status() string
- func (r GetStockResponse) StatusCode() int
- type Holding
- type HoldingList
- type HttpRequestDoer
- type Income
- type ListDividendsParams
- type ListDividendsResponse
- func (r ListDividendsResponse) ContentType() string
- func (r ListDividendsResponse) GetBody() []byte
- func (r ListDividendsResponse) GetJSON200() *DividendList
- func (r ListDividendsResponse) GetJSON401() *Error
- func (r ListDividendsResponse) GetJSON422() *Error
- func (r ListDividendsResponse) Status() string
- func (r ListDividendsResponse) StatusCode() int
- type ListHoldingsParams
- type ListHoldingsResponse
- func (r ListHoldingsResponse) ContentType() string
- func (r ListHoldingsResponse) GetBody() []byte
- func (r ListHoldingsResponse) GetJSON200() *HoldingList
- func (r ListHoldingsResponse) GetJSON401() *Error
- func (r ListHoldingsResponse) GetJSON422() *Error
- func (r ListHoldingsResponse) Status() string
- func (r ListHoldingsResponse) StatusCode() int
- type ListPortfoliosResponse
- func (r ListPortfoliosResponse) ContentType() string
- func (r ListPortfoliosResponse) GetBody() []byte
- func (r ListPortfoliosResponse) GetJSON200() *PortfolioList
- func (r ListPortfoliosResponse) GetJSON401() *Error
- func (r ListPortfoliosResponse) Status() string
- func (r ListPortfoliosResponse) StatusCode() int
- type Me
- type Money
- type Portfolio
- type PortfolioList
- type RequestEditorFn
- type SearchStocksParams
- type SearchStocksResponse
- func (r SearchStocksResponse) ContentType() string
- func (r SearchStocksResponse) GetBody() []byte
- func (r SearchStocksResponse) GetJSON200() *StockSearch
- func (r SearchStocksResponse) GetJSON422() *Error
- func (r SearchStocksResponse) GetJSON429() *Error
- func (r SearchStocksResponse) Status() string
- func (r SearchStocksResponse) StatusCode() int
- type StatusError
- type Stock
- type StockDividendSafety
- type StockSearch
- type UnreachableError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(server string, opts ...ClientOption) (*genClient, error)
Creates a new genClient, with reasonable defaults
func NewGetCalendarRequest ¶
func NewGetCalendarRequest(server string, params *GetCalendarParams) (*http.Request, error)
NewGetCalendarRequest constructs an http.Request for the GetCalendar method
func NewGetIncomeRequest ¶
func NewGetIncomeRequest(server string, params *GetIncomeParams) (*http.Request, error)
NewGetIncomeRequest constructs an http.Request for the GetIncome method
func NewGetMeRequest ¶
NewGetMeRequest constructs an http.Request for the GetMe method
func NewGetStockRequest ¶
NewGetStockRequest constructs an http.Request for the GetStock method
func NewListDividendsRequest ¶
func NewListDividendsRequest(server string, params *ListDividendsParams) (*http.Request, error)
NewListDividendsRequest constructs an http.Request for the ListDividends method
func NewListHoldingsRequest ¶
func NewListHoldingsRequest(server string, params *ListHoldingsParams) (*http.Request, error)
NewListHoldingsRequest constructs an http.Request for the ListHoldings method
func NewListPortfoliosRequest ¶
NewListPortfoliosRequest constructs an http.Request for the ListPortfolios method
func NewSearchStocksRequest ¶
func NewSearchStocksRequest(server string, params *SearchStocksParams) (*http.Request, error)
NewSearchStocksRequest constructs an http.Request for the SearchStocks method
Types ¶
type Calendar ¶
type Calendar struct {
Days int `json:"days"`
// From Today, UTC.
From openapi_types.Date `json:"from"`
// Stocks Soonest ex-date first.
Stocks []struct {
ExDividendDate openapi_types.Date `json:"ex_dividend_date"`
Name *string `json:"name,omitempty"`
// PaymentFrequency Example: quarterly
PaymentFrequency *string `json:"payment_frequency,omitempty"`
Sector *string `json:"sector,omitempty"`
Symbol string `json:"symbol"`
} `json:"stocks"`
}
Calendar defines model for Calendar.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is what the commands call: one method per endpoint, each returning the decoded 200 response or one of the errors below.
func (*Client) Calendar ¶
Calendar is GET /api/v1/calendar: stocks going ex-dividend in the next days days. Public. Quantic clamps days to 1–120.
func (*Client) Dividends ¶
func (c *Client) Dividends(ctx context.Context, params ListDividendsParams) (*DividendList, error)
Dividends is GET /api/v1/dividends: dividends received, newest first. Needs a token.
func (*Client) Holdings ¶
func (c *Client) Holdings(ctx context.Context, params ListHoldingsParams) (*HoldingList, error)
Holdings is GET /api/v1/holdings, in every portfolio or the one named. Needs a token.
func (*Client) Income ¶
Income is GET /api/v1/income: forward income and its projection. Needs a token.
func (*Client) Portfolios ¶
func (c *Client) Portfolios(ctx context.Context) (*PortfolioList, error)
Portfolios is GET /api/v1/portfolios. Needs a token.
func (*Client) SearchStocks ¶
SearchStocks is GET /api/v1/stocks?q=: up to about 10 matches by ticker or name. Public.
type ClientInterface ¶
type ClientInterface interface {
// GetCalendar Upcoming ex-dividend dates
//
// Every stock Quantic tracks going ex-dividend in the next `days` days, soonest first. Public: no token needed. Buy before the ex-date to receive the next dividend.
//
// Corresponds with GET /api/v1/calendar (the `GetCalendar` operationId).
GetCalendar(ctx context.Context, params *GetCalendarParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// ListDividends Your received dividends
//
// Dividends paid to you, newest first.
//
// Corresponds with GET /api/v1/dividends (the `ListDividends` operationId).
ListDividends(ctx context.Context, params *ListDividendsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// ListHoldings Your holdings
//
// Each position's shares and average cost, from the ledger: cost basis, no live prices.
//
// Corresponds with GET /api/v1/holdings (the `ListHoldings` operationId).
ListHoldings(ctx context.Context, params *ListHoldingsParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetIncome Your dividend income outlook
//
// Forward annual dividend income at today's rates, in your preferred currency, gross and net of estimated foreign withholding; the holdings it comes from; a year-by-year projection; and how a typical year's income falls across the months.
//
// Corresponds with GET /api/v1/income (the `GetIncome` operationId).
GetIncome(ctx context.Context, params *GetIncomeParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetMe The user the token belongs to
//
// Also the cheapest way to check that a token works.
//
// Corresponds with GET /api/v1/me (the `GetMe` operationId).
GetMe(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
// ListPortfolios Your portfolios
//
// Corresponds with GET /api/v1/portfolios (the `ListPortfolios` operationId).
ListPortfolios(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
// SearchStocks Search stocks
//
// By ticker or company name, up to about 10 matches. Anonymous callers search the stocks Quantic already tracks; with a token the search also asks the market-data provider.
//
// Corresponds with GET /api/v1/stocks (the `SearchStocks` operationId).
SearchStocks(ctx context.Context, params *SearchStocksParams, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetStock One stock
//
// Identity, price, dividend profile, dividend safety and the 0–10 scores. With a token the price is live; without one it is the last price Quantic stored, with its time.
//
// Corresponds with GET /api/v1/stocks/{symbol} (the `GetStock` operationId).
GetStock(ctx context.Context, symbol string, reqEditors ...RequestEditorFn) (*http.Response, error)
}
The interface specification for the client above.
type ClientOption ¶
type ClientOption func(*genClient) error
ClientOption allows setting custom parameters during construction
func WithHTTPClient ¶
func WithHTTPClient(doer HttpRequestDoer) ClientOption
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.
func WithRequestEditorFn ¶
func WithRequestEditorFn(fn RequestEditorFn) ClientOption
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.
type ClientWithResponses ¶
type ClientWithResponses struct {
ClientInterface
}
ClientWithResponses builds on ClientInterface to offer response payloads
func NewClientWithResponses ¶
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling
func (*ClientWithResponses) GetCalendarWithResponse ¶
func (c *ClientWithResponses) GetCalendarWithResponse(ctx context.Context, params *GetCalendarParams, reqEditors ...RequestEditorFn) (*GetCalendarResponse, error)
GetCalendarWithResponse Upcoming ex-dividend dates
Every stock Quantic tracks going ex-dividend in the next `days` days, soonest first. Public: no token needed. Buy before the ex-date to receive the next dividend.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/calendar (the `GetCalendar` operationId).
func (*ClientWithResponses) GetIncomeWithResponse ¶
func (c *ClientWithResponses) GetIncomeWithResponse(ctx context.Context, params *GetIncomeParams, reqEditors ...RequestEditorFn) (*GetIncomeResponse, error)
GetIncomeWithResponse Your dividend income outlook
Forward annual dividend income at today's rates, in your preferred currency, gross and net of estimated foreign withholding; the holdings it comes from; a year-by-year projection; and how a typical year's income falls across the months.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/income (the `GetIncome` operationId).
func (*ClientWithResponses) GetMeWithResponse ¶
func (c *ClientWithResponses) GetMeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetMeResponse, error)
GetMeWithResponse The user the token belongs to
Also the cheapest way to check that a token works.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/me (the `GetMe` operationId).
func (*ClientWithResponses) GetStockWithResponse ¶
func (c *ClientWithResponses) GetStockWithResponse(ctx context.Context, symbol string, reqEditors ...RequestEditorFn) (*GetStockResponse, error)
GetStockWithResponse One stock
Identity, price, dividend profile, dividend safety and the 0–10 scores. With a token the price is live; without one it is the last price Quantic stored, with its time.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/stocks/{symbol} (the `GetStock` operationId).
func (*ClientWithResponses) ListDividendsWithResponse ¶
func (c *ClientWithResponses) ListDividendsWithResponse(ctx context.Context, params *ListDividendsParams, reqEditors ...RequestEditorFn) (*ListDividendsResponse, error)
ListDividendsWithResponse Your received dividends
Dividends paid to you, newest first.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/dividends (the `ListDividends` operationId).
func (*ClientWithResponses) ListHoldingsWithResponse ¶
func (c *ClientWithResponses) ListHoldingsWithResponse(ctx context.Context, params *ListHoldingsParams, reqEditors ...RequestEditorFn) (*ListHoldingsResponse, error)
ListHoldingsWithResponse Your holdings
Each position's shares and average cost, from the ledger: cost basis, no live prices.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/holdings (the `ListHoldings` operationId).
func (*ClientWithResponses) ListPortfoliosWithResponse ¶
func (c *ClientWithResponses) ListPortfoliosWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListPortfoliosResponse, error)
ListPortfoliosWithResponse Your portfolios
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/portfolios (the `ListPortfolios` operationId).
func (*ClientWithResponses) SearchStocksWithResponse ¶
func (c *ClientWithResponses) SearchStocksWithResponse(ctx context.Context, params *SearchStocksParams, reqEditors ...RequestEditorFn) (*SearchStocksResponse, error)
SearchStocksWithResponse Search stocks
By ticker or company name, up to about 10 matches. Anonymous callers search the stocks Quantic already tracks; with a token the search also asks the market-data provider.
Returns a wrapper object for the known response body format(s).
Corresponds with GET /api/v1/stocks (the `SearchStocks` operationId).
type ClientWithResponsesInterface ¶
type ClientWithResponsesInterface interface {
// GetCalendarWithResponse Upcoming ex-dividend dates
//
// Every stock Quantic tracks going ex-dividend in the next `days` days, soonest first. Public: no token needed. Buy before the ex-date to receive the next dividend.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/calendar (the `GetCalendar` operationId).
GetCalendarWithResponse(ctx context.Context, params *GetCalendarParams, reqEditors ...RequestEditorFn) (*GetCalendarResponse, error)
// ListDividendsWithResponse Your received dividends
//
// Dividends paid to you, newest first.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/dividends (the `ListDividends` operationId).
ListDividendsWithResponse(ctx context.Context, params *ListDividendsParams, reqEditors ...RequestEditorFn) (*ListDividendsResponse, error)
// ListHoldingsWithResponse Your holdings
//
// Each position's shares and average cost, from the ledger: cost basis, no live prices.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/holdings (the `ListHoldings` operationId).
ListHoldingsWithResponse(ctx context.Context, params *ListHoldingsParams, reqEditors ...RequestEditorFn) (*ListHoldingsResponse, error)
// GetIncomeWithResponse Your dividend income outlook
//
// Forward annual dividend income at today's rates, in your preferred currency, gross and net of estimated foreign withholding; the holdings it comes from; a year-by-year projection; and how a typical year's income falls across the months.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/income (the `GetIncome` operationId).
GetIncomeWithResponse(ctx context.Context, params *GetIncomeParams, reqEditors ...RequestEditorFn) (*GetIncomeResponse, error)
// GetMeWithResponse The user the token belongs to
//
// Also the cheapest way to check that a token works.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/me (the `GetMe` operationId).
GetMeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetMeResponse, error)
// ListPortfoliosWithResponse Your portfolios
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/portfolios (the `ListPortfolios` operationId).
ListPortfoliosWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListPortfoliosResponse, error)
// SearchStocksWithResponse Search stocks
//
// By ticker or company name, up to about 10 matches. Anonymous callers search the stocks Quantic already tracks; with a token the search also asks the market-data provider.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/stocks (the `SearchStocks` operationId).
SearchStocksWithResponse(ctx context.Context, params *SearchStocksParams, reqEditors ...RequestEditorFn) (*SearchStocksResponse, error)
// GetStockWithResponse One stock
//
// Identity, price, dividend profile, dividend safety and the 0–10 scores. With a token the price is live; without one it is the last price Quantic stored, with its time.
//
// Returns a wrapper object for the known response body format(s).
//
// Corresponds with GET /api/v1/stocks/{symbol} (the `GetStock` operationId).
GetStockWithResponse(ctx context.Context, symbol string, reqEditors ...RequestEditorFn) (*GetStockResponse, error)
}
ClientWithResponsesInterface is the interface specification for the client with responses above.
type Config ¶
type Config struct {
// BaseURL is where Quantic is: https://quantic.finance, or a local
// Phoenix server in development. The API's paths are added to it.
BaseURL string
// UserAgent names the client in Quantic's logs, e.g. "quantic-cli/v0.1.0".
UserAgent string
// Token is sent as "Authorization: Bearer …" on every request; zero
// means signed out. Go's http.Client drops the header if a redirect
// leads to another host, so it only ever goes to BaseURL's.
Token auth.Secret
// Transport sends the requests; nil means http.DefaultTransport. Tests
// replace it to count or break requests.
Transport http.RoundTripper
}
Config is what New needs. Only BaseURL is required.
type Dividend ¶
type Dividend struct {
// Amount Gross.
Amount Money `json:"amount"`
// Date Pay date.
Date openapi_types.Date `json:"date"`
Isin *string `json:"isin,omitempty"`
Name *string `json:"name,omitempty"`
// Net What reached you.
Net Money `json:"net"`
// Portfolio Which portfolio, when you have more than one and didn't pick one.
Portfolio *string `json:"portfolio,omitempty"`
// Quantity Shares it was paid on.
Quantity *int `json:"quantity,omitempty"`
// Source How it was recorded, e.g. manual or an import.
Source *string `json:"source,omitempty"`
// Symbol Example: KO
Symbol string `json:"symbol"`
// WithholdingTax Withheld abroad.
WithholdingTax *Money `json:"withholding_tax,omitempty"`
}
Dividend A dividend paid to you. All amounts are in the currency it was paid in.
type DividendList ¶
type DividendList struct {
Dividends []Dividend `json:"dividends"`
}
DividendList defines model for DividendList.
type Error ¶
type Error struct {
Error struct {
// Code Stable, for programs to branch on.
Code ErrorErrorCode `json:"code"`
// Message For humans; may change.
Message string `json:"message"`
} `json:"error"`
}
Error defines model for Error.
type ErrorErrorCode ¶
type ErrorErrorCode string
ErrorErrorCode Stable, for programs to branch on.
const ( BadRequest ErrorErrorCode = "bad_request" Forbidden ErrorErrorCode = "forbidden" InvalidParams ErrorErrorCode = "invalid_params" NotFound ErrorErrorCode = "not_found" RateLimited ErrorErrorCode = "rate_limited" )
Defines values for ErrorErrorCode.
func (ErrorErrorCode) Valid ¶
func (e ErrorErrorCode) Valid() bool
Valid indicates whether the value is a known member of the ErrorErrorCode enum.
type GetCalendarParams ¶
type GetCalendarParams struct {
// Days How far ahead, 1 to 120. Default 45.
Days *int `form:"days,omitempty" json:"days,omitempty"`
}
GetCalendarParams defines parameters for GetCalendar.
type GetCalendarResponse ¶
type GetCalendarResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *Calendar
// JSON422 the response for an HTTP 422 `application/json` response
JSON422 *Error
// JSON429 the response for an HTTP 429 `application/json` response
JSON429 *Error
}
func ParseGetCalendarResponse ¶
func ParseGetCalendarResponse(rsp *http.Response) (*GetCalendarResponse, error)
ParseGetCalendarResponse parses an HTTP response from a GetCalendarWithResponse call
func (GetCalendarResponse) ContentType ¶
func (r GetCalendarResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (GetCalendarResponse) GetBody ¶
func (r GetCalendarResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (GetCalendarResponse) GetJSON200 ¶
func (r GetCalendarResponse) GetJSON200() *Calendar
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (GetCalendarResponse) GetJSON422 ¶
func (r GetCalendarResponse) GetJSON422() *Error
GetJSON422 returns the response for an HTTP 422 `application/json` response
func (GetCalendarResponse) GetJSON429 ¶
func (r GetCalendarResponse) GetJSON429() *Error
GetJSON429 returns the response for an HTTP 429 `application/json` response
func (GetCalendarResponse) Status ¶
func (r GetCalendarResponse) Status() string
Status returns HTTPResponse.Status
func (GetCalendarResponse) StatusCode ¶
func (r GetCalendarResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type GetIncomeParams ¶
type GetIncomeParams struct {
// Years Projection horizon, 1 to 50. Default 10.
Years *int `form:"years,omitempty" json:"years,omitempty"`
// Drip Compound reinvested dividends. Default false.
Drip *bool `form:"drip,omitempty" json:"drip,omitempty"`
// Portfolio A portfolio name or slug, case-insensitive. Omitted: all portfolios.
Portfolio *string `form:"portfolio,omitempty" json:"portfolio,omitempty"`
}
GetIncomeParams defines parameters for GetIncome.
type GetIncomeResponse ¶
type GetIncomeResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *Income
// JSON401 the response for an HTTP 401 `application/json` response
JSON401 *Error
// JSON422 the response for an HTTP 422 `application/json` response
JSON422 *Error
}
func ParseGetIncomeResponse ¶
func ParseGetIncomeResponse(rsp *http.Response) (*GetIncomeResponse, error)
ParseGetIncomeResponse parses an HTTP response from a GetIncomeWithResponse call
func (GetIncomeResponse) ContentType ¶
func (r GetIncomeResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (GetIncomeResponse) GetBody ¶
func (r GetIncomeResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (GetIncomeResponse) GetJSON200 ¶
func (r GetIncomeResponse) GetJSON200() *Income
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (GetIncomeResponse) GetJSON401 ¶
func (r GetIncomeResponse) GetJSON401() *Error
GetJSON401 returns the response for an HTTP 401 `application/json` response
func (GetIncomeResponse) GetJSON422 ¶
func (r GetIncomeResponse) GetJSON422() *Error
GetJSON422 returns the response for an HTTP 422 `application/json` response
func (GetIncomeResponse) Status ¶
func (r GetIncomeResponse) Status() string
Status returns HTTPResponse.Status
func (GetIncomeResponse) StatusCode ¶
func (r GetIncomeResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type GetMeResponse ¶
type GetMeResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *Me
// JSON401 the response for an HTTP 401 `application/json` response
JSON401 *Error
}
func ParseGetMeResponse ¶
func ParseGetMeResponse(rsp *http.Response) (*GetMeResponse, error)
ParseGetMeResponse parses an HTTP response from a GetMeWithResponse call
func (GetMeResponse) ContentType ¶
func (r GetMeResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (GetMeResponse) GetBody ¶
func (r GetMeResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (GetMeResponse) GetJSON200 ¶
func (r GetMeResponse) GetJSON200() *Me
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (GetMeResponse) GetJSON401 ¶
func (r GetMeResponse) GetJSON401() *Error
GetJSON401 returns the response for an HTTP 401 `application/json` response
func (GetMeResponse) Status ¶
func (r GetMeResponse) Status() string
Status returns HTTPResponse.Status
func (GetMeResponse) StatusCode ¶
func (r GetMeResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type GetStockResponse ¶
type GetStockResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *Stock
// JSON404 the response for an HTTP 404 `application/json` response
JSON404 *Error
// JSON429 the response for an HTTP 429 `application/json` response
JSON429 *Error
}
func ParseGetStockResponse ¶
func ParseGetStockResponse(rsp *http.Response) (*GetStockResponse, error)
ParseGetStockResponse parses an HTTP response from a GetStockWithResponse call
func (GetStockResponse) ContentType ¶
func (r GetStockResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (GetStockResponse) GetBody ¶
func (r GetStockResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (GetStockResponse) GetJSON200 ¶
func (r GetStockResponse) GetJSON200() *Stock
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (GetStockResponse) GetJSON404 ¶
func (r GetStockResponse) GetJSON404() *Error
GetJSON404 returns the response for an HTTP 404 `application/json` response
func (GetStockResponse) GetJSON429 ¶
func (r GetStockResponse) GetJSON429() *Error
GetJSON429 returns the response for an HTTP 429 `application/json` response
func (GetStockResponse) Status ¶
func (r GetStockResponse) Status() string
Status returns HTTPResponse.Status
func (GetStockResponse) StatusCode ¶
func (r GetStockResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type Holding ¶
type Holding struct {
// AverageCost Per share, in the currency the position trades in; full precision.
AverageCost Money `json:"average_cost"`
InstrumentType *string `json:"instrument_type,omitempty"`
Isin *string `json:"isin,omitempty"`
Name *string `json:"name"`
// Portfolio Which portfolio, when you have more than one and didn't pick one.
Portfolio *string `json:"portfolio,omitempty"`
Sector *string `json:"sector,omitempty"`
Shares string `json:"shares"`
// Symbol Example: KO
Symbol string `json:"symbol"`
}
Holding defines model for Holding.
type HoldingList ¶
type HoldingList struct {
Holdings []Holding `json:"holdings"`
}
HoldingList defines model for HoldingList.
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type Income ¶
type Income struct {
// AnnualIncome Forward, at today's rates, gross.
AnnualIncome Money `json:"annual_income"`
// CurrentYieldPct A percentage.
CurrentYieldPct *float64 `json:"current_yield_pct,omitempty"`
Drip bool `json:"drip"`
// GrowthRate Income-weighted dividend growth, a fraction.
GrowthRate *float64 `json:"growth_rate,omitempty"`
// Holdings Where the income comes from, biggest first.
Holdings []struct {
// Cagr5y A fraction.
Cagr5y *float64 `json:"cagr_5y,omitempty"`
// Growth A fraction.
Growth *float64 `json:"growth,omitempty"`
// Income An amount and its currency. The amount is a decimal string, never a float.
Income Money `json:"income"`
// NetIncome An amount and its currency. The amount is a decimal string, never a float.
NetIncome Money `json:"net_income"`
// Streak Consecutive years of increases.
Streak *int `json:"streak,omitempty"`
Symbol string `json:"symbol"`
} `json:"holdings"`
// IncomeYear How a typical year's income falls across the months. Null for a portfolio too small for the shape to mean anything.
IncomeYear *struct {
// AverageMonth An amount and its currency. The amount is a decimal string, never a float.
AverageMonth *Money `json:"average_month,omitempty"`
BiggestMonths *[]int `json:"biggest_months,omitempty"`
// BiggestMonthsShare Share of the year in the biggest months. 0.25 is perfectly even.
BiggestMonthsShare *float64 `json:"biggest_months_share,omitempty"`
// ByMonth Keyed by month, "1" to "12", every month present.
ByMonth *map[string]Money `json:"by_month,omitempty"`
EmptyMonths *[]int `json:"empty_months,omitempty"`
NetOfWithholding *bool `json:"net_of_withholding,omitempty"`
// ThinMonths Below average, thinnest first.
ThinMonths *[]int `json:"thin_months,omitempty"`
} `json:"income_year,omitempty"`
// NetAnnualIncome The same, net of estimated foreign withholding.
NetAnnualIncome Money `json:"net_annual_income"`
// Projection One entry per year, from 0 (now) to `years`.
Projection []struct {
// Income An amount and its currency. The amount is a decimal string, never a float.
Income Money `json:"income"`
// NetIncome An amount and its currency. The amount is a decimal string, never a float.
NetIncome Money `json:"net_income"`
YearOffset int `json:"year_offset"`
} `json:"projection"`
Years int `json:"years"`
}
Income Money is in your preferred currency throughout. Rates are fractions: 0.05 is 5%.
type ListDividendsParams ¶
type ListDividendsParams struct {
// Symbol Only this ticker. An unknown one matches nothing.
Symbol *string `form:"symbol,omitempty" json:"symbol,omitempty"`
// From Paid on or after.
From *openapi_types.Date `form:"from,omitempty" json:"from,omitempty"`
// To Paid on or before.
To *openapi_types.Date `form:"to,omitempty" json:"to,omitempty"`
// Portfolio A portfolio name or slug, case-insensitive. Omitted: all portfolios, and each row says which one it is in when you have more than one.
Portfolio *string `form:"portfolio,omitempty" json:"portfolio,omitempty"`
}
ListDividendsParams defines parameters for ListDividends.
type ListDividendsResponse ¶
type ListDividendsResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *DividendList
// JSON401 the response for an HTTP 401 `application/json` response
JSON401 *Error
// JSON422 the response for an HTTP 422 `application/json` response
JSON422 *Error
}
func ParseListDividendsResponse ¶
func ParseListDividendsResponse(rsp *http.Response) (*ListDividendsResponse, error)
ParseListDividendsResponse parses an HTTP response from a ListDividendsWithResponse call
func (ListDividendsResponse) ContentType ¶
func (r ListDividendsResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (ListDividendsResponse) GetBody ¶
func (r ListDividendsResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (ListDividendsResponse) GetJSON200 ¶
func (r ListDividendsResponse) GetJSON200() *DividendList
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (ListDividendsResponse) GetJSON401 ¶
func (r ListDividendsResponse) GetJSON401() *Error
GetJSON401 returns the response for an HTTP 401 `application/json` response
func (ListDividendsResponse) GetJSON422 ¶
func (r ListDividendsResponse) GetJSON422() *Error
GetJSON422 returns the response for an HTTP 422 `application/json` response
func (ListDividendsResponse) Status ¶
func (r ListDividendsResponse) Status() string
Status returns HTTPResponse.Status
func (ListDividendsResponse) StatusCode ¶
func (r ListDividendsResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type ListHoldingsParams ¶
type ListHoldingsParams struct {
// Portfolio A portfolio name or slug, case-insensitive. Omitted: all portfolios, and each row says which one it is in when you have more than one.
Portfolio *string `form:"portfolio,omitempty" json:"portfolio,omitempty"`
}
ListHoldingsParams defines parameters for ListHoldings.
type ListHoldingsResponse ¶
type ListHoldingsResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *HoldingList
// JSON401 the response for an HTTP 401 `application/json` response
JSON401 *Error
// JSON422 the response for an HTTP 422 `application/json` response
JSON422 *Error
}
func ParseListHoldingsResponse ¶
func ParseListHoldingsResponse(rsp *http.Response) (*ListHoldingsResponse, error)
ParseListHoldingsResponse parses an HTTP response from a ListHoldingsWithResponse call
func (ListHoldingsResponse) ContentType ¶
func (r ListHoldingsResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (ListHoldingsResponse) GetBody ¶
func (r ListHoldingsResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (ListHoldingsResponse) GetJSON200 ¶
func (r ListHoldingsResponse) GetJSON200() *HoldingList
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (ListHoldingsResponse) GetJSON401 ¶
func (r ListHoldingsResponse) GetJSON401() *Error
GetJSON401 returns the response for an HTTP 401 `application/json` response
func (ListHoldingsResponse) GetJSON422 ¶
func (r ListHoldingsResponse) GetJSON422() *Error
GetJSON422 returns the response for an HTTP 422 `application/json` response
func (ListHoldingsResponse) Status ¶
func (r ListHoldingsResponse) Status() string
Status returns HTTPResponse.Status
func (ListHoldingsResponse) StatusCode ¶
func (r ListHoldingsResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type ListPortfoliosResponse ¶
type ListPortfoliosResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *PortfolioList
// JSON401 the response for an HTTP 401 `application/json` response
JSON401 *Error
}
func ParseListPortfoliosResponse ¶
func ParseListPortfoliosResponse(rsp *http.Response) (*ListPortfoliosResponse, error)
ParseListPortfoliosResponse parses an HTTP response from a ListPortfoliosWithResponse call
func (ListPortfoliosResponse) ContentType ¶
func (r ListPortfoliosResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (ListPortfoliosResponse) GetBody ¶
func (r ListPortfoliosResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (ListPortfoliosResponse) GetJSON200 ¶
func (r ListPortfoliosResponse) GetJSON200() *PortfolioList
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (ListPortfoliosResponse) GetJSON401 ¶
func (r ListPortfoliosResponse) GetJSON401() *Error
GetJSON401 returns the response for an HTTP 401 `application/json` response
func (ListPortfoliosResponse) Status ¶
func (r ListPortfoliosResponse) Status() string
Status returns HTTPResponse.Status
func (ListPortfoliosResponse) StatusCode ¶
func (r ListPortfoliosResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type Me ¶
type Me struct {
Email string `json:"email"`
Id openapi_types.UUID `json:"id"`
Name *string `json:"name,omitempty"`
// PreferredCurrency ISO 4217; the currency aggregates are reported in.
//
// Example: EUR
PreferredCurrency string `json:"preferred_currency"`
}
Me The user the token belongs to.
type Money ¶
type Money struct {
// Amount Example: 12.34
Amount string `json:"amount"`
// Currency ISO 4217
//
// Example: EUR
Currency string `json:"currency"`
}
Money An amount and its currency. The amount is a decimal string, never a float.
type Portfolio ¶
type Portfolio struct {
Default bool `json:"default"`
Name string `json:"name"`
// Slug Present only when the portfolio is shared.
Slug *string `json:"slug,omitempty"`
}
Portfolio Pass its name (or slug) as `portfolio` to narrow the ledger endpoints to it; without it they aggregate across all portfolios.
type PortfolioList ¶
type PortfolioList struct {
Portfolios []Portfolio `json:"portfolios"`
}
PortfolioList defines model for PortfolioList.
type RequestEditorFn ¶
RequestEditorFn is the function signature for the RequestEditor callback function
type SearchStocksParams ¶
type SearchStocksParams struct {
// Q Ticker or name.
Q string `form:"q" json:"q"`
}
SearchStocksParams defines parameters for SearchStocks.
type SearchStocksResponse ¶
type SearchStocksResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *StockSearch
// JSON422 the response for an HTTP 422 `application/json` response
JSON422 *Error
// JSON429 the response for an HTTP 429 `application/json` response
JSON429 *Error
}
func ParseSearchStocksResponse ¶
func ParseSearchStocksResponse(rsp *http.Response) (*SearchStocksResponse, error)
ParseSearchStocksResponse parses an HTTP response from a SearchStocksWithResponse call
func (SearchStocksResponse) ContentType ¶
func (r SearchStocksResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (SearchStocksResponse) GetBody ¶
func (r SearchStocksResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (SearchStocksResponse) GetJSON200 ¶
func (r SearchStocksResponse) GetJSON200() *StockSearch
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (SearchStocksResponse) GetJSON422 ¶
func (r SearchStocksResponse) GetJSON422() *Error
GetJSON422 returns the response for an HTTP 422 `application/json` response
func (SearchStocksResponse) GetJSON429 ¶
func (r SearchStocksResponse) GetJSON429() *Error
GetJSON429 returns the response for an HTTP 429 `application/json` response
func (SearchStocksResponse) Status ¶
func (r SearchStocksResponse) Status() string
Status returns HTTPResponse.Status
func (SearchStocksResponse) StatusCode ¶
func (r SearchStocksResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type StatusError ¶
StatusError is an answer from Quantic that isn't a 200: Status is the HTTP status, Code the API's stable error code ("not_found", "rate_limited"…) when the body had one, and Message what it said, for people.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type Stock ¶
type Stock struct {
// Currency The currency it trades in.
Currency string `json:"currency"`
Dividend struct {
// Annual Per share, per year, from the live quote. Null without a token.
Annual *Money `json:"annual,omitempty"`
// Cagr5y A fraction.
Cagr5y *float64 `json:"cagr_5y,omitempty"`
ExDividendDate *openapi_types.Date `json:"ex_dividend_date,omitempty"`
// Frequency Example: quarterly
Frequency *string `json:"frequency,omitempty"`
PaymentMonths []int `json:"payment_months"`
Safety StockDividendSafety `json:"safety"`
// StreakYears Consecutive years of increases.
StreakYears *int `json:"streak_years,omitempty"`
// YieldAvg5yPct The average yield over about 5 years, a percentage.
YieldAvg5yPct *float64 `json:"yield_avg_5y_pct,omitempty"`
// YieldPct A percentage.
YieldPct *float64 `json:"yield_pct,omitempty"`
} `json:"dividend"`
Industry *string `json:"industry,omitempty"`
// InstrumentType Example: equity
InstrumentType *string `json:"instrument_type,omitempty"`
Name *string `json:"name,omitempty"`
// Price Money, plus whether it is live. Live with a token; without one, the last price Quantic stored and when. Null when there is neither.
Price *struct {
// Amount Example: 12.34
Amount string `json:"amount"`
// AsOf When the stored price was seen. Null for a live price.
AsOf *time.Time `json:"as_of,omitempty"`
// Currency ISO 4217
//
// Example: EUR
Currency string `json:"currency"`
Live bool `json:"live"`
} `json:"price"`
// Scores Quantic's 0–10 lenses.
Scores struct {
Momentum *float64 `json:"momentum,omitempty"`
Rating *float64 `json:"rating,omitempty"`
Value *float64 `json:"value,omitempty"`
} `json:"scores"`
Sector *string `json:"sector,omitempty"`
// Symbol Example: KO
Symbol string `json:"symbol"`
}
Stock defines model for Stock.
type StockDividendSafety ¶
type StockDividendSafety string
StockDividendSafety defines model for Stock.Dividend.Safety.
const ( AtRisk StockDividendSafety = "at_risk" Safe StockDividendSafety = "safe" Unknown StockDividendSafety = "unknown" Watch StockDividendSafety = "watch" )
Defines values for StockDividendSafety.
func (StockDividendSafety) Valid ¶
func (e StockDividendSafety) Valid() bool
Valid indicates whether the value is a known member of the StockDividendSafety enum.
type StockSearch ¶
type StockSearch struct {
Results []struct {
Exchange *string `json:"exchange,omitempty"`
Name *string `json:"name,omitempty"`
Symbol string `json:"symbol"`
// Tracked Quantic has data for it, so /api/v1/stocks/{symbol} answers.
Tracked bool `json:"tracked"`
// Type Example: EQUITY
Type *string `json:"type,omitempty"`
} `json:"results"`
}
StockSearch defines model for StockSearch.
type UnreachableError ¶
UnreachableError means there was no answer at all: no network, a refused connection, a name that doesn't resolve, or no answer before the deadline. errors.Is(err, context.DeadlineExceeded) tells the last one apart.
func (*UnreachableError) Error ¶
func (e *UnreachableError) Error() string
func (*UnreachableError) Unwrap ¶
func (e *UnreachableError) Unwrap() error