comdirect

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpRequestInfoHeaderKey        = "X-Http-Request-Info"
	OnceAuthenticationInfoHeaderKey = "X-Once-Authentication-Info"
	OnceAuthenticationHeaderKey     = "X-Once-Authentication"
	AuthorizationHeaderKey          = "Authorization"
	ContentTypeHeaderKey            = "Content-Type"
	AcceptHeaderKey                 = "Accept"

	Host           = "api.comdirect.de"
	ApiPath        = "/api"
	OAuthTokenPath = "/oauth/token"

	PasswordGrantType     = "password"
	SecondaryGrantType    = "cd_secondary"
	RefreshTokenGrantType = "refresh_token"

	DefaultHttpTimeout = time.Second * 30
	HttpsScheme        = "https"
	BearerPrefix       = "Bearer "

	PagingFirstQueryKey          = "paging-first"
	PagingCountQueryKey          = "paging-count"
	ProductTypeQueryKey          = "productType"
	TargetClientIDQueryKey       = "targetClientId"
	WithoutAttrQueryKey          = "without-attr"
	WithAttrQueryKey             = "with-attr"
	ClientConnectionTypeQueryKey = "clientConnectionType"
	OrderStatusQueryKey          = "orderStatus"
	VenueIDQueryKey              = "venueId"
	SideQueryKey                 = "side"
	OrderTypeQueryKey            = "orderType"
	InstrumentIDQueryKey         = "instrumentId"
	WKNQueryKey                  = "wkn"
	ISINQueryKey                 = "isin"
	TypeQueryKey                 = "type"
	BookingStatusQueryKey        = "bookingStatus"
	MaxBookingDateQueryKey       = "max-bookingDate"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"scope"`
	CustomerID   string `json:"kdnr"`
	BPID         int    `json:"bpid"`
	ContactID    int    `json:"kontaktId"`
}

AccessToken represents an OAuth2 token that is returned from the comdirect REST API.

type Account

type Account struct {
	AccountID        string      `json:"accountId"`
	AccountDisplayID string      `json:"accountDisplayId"`
	Currency         string      `json:"currency"`
	ClientID         string      `json:"clientId"`
	AccountType      AccountType `json:"accountType"`
	Iban             string      `json:"iban"`
	CreditLimit      AmountValue `json:"creditLimit"`
}

type AccountBalance

type AccountBalance struct {
	Account                Account     `json:"account"`
	AccountId              string      `json:"accountId"`
	Balance                AmountValue `json:"balance"`
	BalanceEUR             AmountValue `json:"balanceEUR"`
	AvailableCashAmount    AmountValue `json:"availableCashAmount"`
	AvailableCashAmountEUR AmountValue `json:"availableCashAmountEUR"`
}

type AccountBalances

type AccountBalances struct {
	Paging Paging           `json:"paging"`
	Values []AccountBalance `json:"values"`
}

type AccountTransaction

type AccountTransaction struct {
	Reference             string          `json:"reference"`
	BookingStatus         string          `json:"bookingStatus"`
	BookingDate           string          `json:"bookingDate"`
	Amount                AmountValue     `json:"amount"`
	Remitter              Remitter        `json:"remitter"`
	Deptor                string          `json:"deptor"`
	Creditor              Creditor        `json:"creditor"`
	ValutaDate            string          `json:"valutaDate"`
	DirectDebitCreditorID string          `json:"directDebitCreditorId"`
	DirectDebitMandateID  string          `json:"directDebitMandateId"`
	EndToEndReference     string          `json:"endToEndReference"`
	NewTransaction        bool            `json:"newTransaction"`
	RemittanceInfo        string          `json:"remittanceInfo"`
	TransactionType       TransactionType `json:"transactionType"`
}

type AccountTransactions

type AccountTransactions struct {
	Paging Paging               `json:"paging"`
	Values []AccountTransaction `json:"values"`
}

type AccountType

type AccountType struct {
	Key  string `json:"key"`
	Text string `json:"text"`
}

type AmountValue

type AmountValue struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type AuthOptions

type AuthOptions struct {
	Username     string
	Password     string
	ClientId     string
	ClientSecret string
}

AuthOptions encapsulates the information for authentication against the comdirect REST API.

type Authentication

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

Authentication represents an authentication object for the comdirect REST API.

func NewAuthentication

func NewAuthentication(accessToken AccessToken, sessionID string, time time.Time) *Authentication

func (*Authentication) AccessToken

func (a *Authentication) AccessToken() AccessToken

func (*Authentication) ExpiryTime

func (a *Authentication) ExpiryTime() time.Time

func (*Authentication) IsExpired

func (a *Authentication) IsExpired() bool

func (*Authentication) SessionID

func (a *Authentication) SessionID() string

type Authenticator

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

Authenticator is responsible for authenticating against the comdirect REST API. It uses the given AuthOptions for authentication and returns an AccessToken in case the authentication flow was successful. Authenticator is using golang's default http.Client.

func NewAuthenticator

func NewAuthenticator(options *AuthOptions) *Authenticator

NewAuthenticator creates a new Authenticator by passing AuthOptions and an http.Client with a timeout of DefaultHttpTimeout.

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(ctx context.Context) (*Authentication, error)

Authenticate authenticates against the comdirect REST API.

func (*Authenticator) Refresh

func (a *Authenticator) Refresh(auth Authentication) (Authentication, error)

func (*Authenticator) Revoke

func (a *Authenticator) Revoke(auth Authentication) error

type Client

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

func NewWithAuthOptions

func NewWithAuthOptions(options *AuthOptions) *Client

NewWithAuthOptions creates a new Client with given AuthOptions

func NewWithAuthentication

func NewWithAuthentication(authentication *Authentication) *Client

func NewWithAuthenticator

func NewWithAuthenticator(authenticator *Authenticator) *Client

NewWithAuthenticator creates a new Client with a given Authenticator

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) (*Authentication, error)

Authenticate uses the underlying Authenticator to authenticate against the comdirect REST API.

func (*Client) Balance

func (c *Client) Balance(ctx context.Context, accountId string) (*AccountBalance, error)

func (*Client) Balances

func (c *Client) Balances(ctx context.Context) (*AccountBalances, error)

func (*Client) CreateOrder

func (c *Client) CreateOrder(order OrderRequest, tan string)

func (*Client) CreateQuoteOrder

func (c *Client) CreateQuoteOrder()

func (*Client) CreateQuoteRequest

func (c *Client) CreateQuoteRequest()

func (*Client) CreateQuoteTicket

func (c *Client) CreateQuoteTicket()

func (*Client) DeleteOrder

func (c *Client) DeleteOrder(orderID string, tan string)

func (*Client) DepotPosition

func (c *Client) DepotPosition(depotID string, positionID string, options ...Options) (*DepotPosition, error)

DepotPosition retrieves a position by its ID from the depot specified by its ID.

func (*Client) DepotPositions

func (c *Client) DepotPositions(depotID string, options ...Options) (*DepotPositions, error)

DepotPositions retrieves all positions for a specific depot ID.

func (*Client) DepotTransactions

func (c *Client) DepotTransactions(depotID string, options ...Options) (*DepotTransactions, error)

DepotTransactions retrieves all transactions for a depot specified by its ID.

func (*Client) Depots

func (c *Client) Depots() (*Depots, error)

Depots retrieves all depots for the current Authentication.

func (*Client) Dimensions

func (c *Client) Dimensions() ([]Dimension, error)

func (*Client) Documents

func (c *Client) Documents(ctx context.Context, options ...Options) (*Documents, error)

func (*Client) DownloadDocument

func (c *Client) DownloadDocument(ctx context.Context, document *Document, folder string) error

func (*Client) ExAnteOrder

func (c *Client) ExAnteOrder()

func (*Client) GetAuthentication

func (c *Client) GetAuthentication() *Authentication

func (*Client) Instrument

func (c *Client) Instrument(instrument string) ([]Instrument, error)

Instrument retrieves instrument information by WKN, ISIN or mnemonic

func (*Client) Order

func (c *Client) Order(orderID string)

func (*Client) Orders

func (c *Client) Orders(depotID string)

func (*Client) PreValidateOrder

func (c *Client) PreValidateOrder()

func (*Client) Refresh

func (c *Client) Refresh() (*Authentication, error)

Refresh uses the underlying Authenticator to refresh an access token.

func (*Client) Reports

func (c *Client) Reports(ctx context.Context, options ...Options) (*Reports, error)

Reports returns the balance for all available accounts.

func (*Client) Revoke

func (c *Client) Revoke() error

Revoke uses the underlying Authenticator to revoke an access token.

func (*Client) SetAuthentication

func (c *Client) SetAuthentication(auth *Authentication) error

func (*Client) Transactions

func (c *Client) Transactions(ctx context.Context, accountId string, options ...Options) (*AccountTransactions, error)

func (*Client) UpdateOrder

func (c *Client) UpdateOrder(orderID string, tan string)

func (*Client) UpdateQuoteTicket

func (c *Client) UpdateQuoteTicket(quoteTicketID string)

func (*Client) ValidateOrder

func (c *Client) ValidateOrder()

func (*Client) ValidateOrderDeletion

func (c *Client) ValidateOrderDeletion(orderID string)

func (*Client) ValidateOrderUpdate

func (c *Client) ValidateOrderUpdate(order OrderRequest)

func (*Client) ValidateQuoteOrder

func (c *Client) ValidateQuoteOrder()

type Creditor

type Creditor struct {
	HolderName string `json:"holderName"`
	Iban       string `json:"iban"`
	Bic        string `json:"bic"`
}

type Depot

type Depot struct {
	DepotId                    string   `json:"depotId"`
	DepotDisplayId             string   `json:"depotDisplayId"`
	ClientId                   string   `json:"clientId"`
	DefaultSettlementAccountId string   `json:"defaultSettlementAccountId"`
	SettlementAccountIds       []string `json:"settlementAccountIds"`
	HolderName                 string   `json:"holderName"`
}

type DepotAggregated

type DepotAggregated struct {
	Depot                 Depot       `json:"depot"`
	PrevDayValue          AmountValue `json:"prevDayValue"`
	CurrentValue          AmountValue `json:"currentValue"`
	PurchaseValue         AmountValue `json:"purchaseValue"`
	ProfitLossPurchaseAbs AmountValue `json:"ProfitLossPurchaseAbs"`
	ProfitLossPurchaseRel string      `json:"profitLossPurchaseRel"`
	ProfitLossPrevDayAbs  AmountValue `json:"profitLossPrevDayAbs"`
	ProfitLossPrevDayRel  string      `json:"profitLossPrevDayRel"`
}

type DepotPosition

type DepotPosition struct {
	DepotId                  string      `json:"depotId"`
	PositionId               string      `json:"positionId"`
	Wkn                      string      `json:"wkn"`
	CustodyType              string      `json:"custodyType"`
	Quantity                 AmountValue `json:"quantity"`
	AvailableQuantity        AmountValue `json:"availableQuantity"`
	CurrentPrice             Price       `json:"currentPrice"`
	PrevDayPrice             Price       `json:"prevDayPrice"`
	CurrentValue             AmountValue `json:"currentValue"`
	PurchaseValue            AmountValue `json:"purchaseValue"`
	ProfitLossPurchaseAbs    AmountValue `json:"profitLossPurchaseAbs"`
	ProfitLossPurchaseRel    string      `json:"profitLossPurchaseRel"`
	ProfitLossPrevDayAbs     AmountValue `json:"profitLossPrevDayAbs"`
	ProfitLossPrevDayRel     string      `json:"profitLossPrevDayRel"`
	AvailableQuantityToHedge AmountValue `json:"availableQuantityToHedge"`
}

type DepotPositions

type DepotPositions struct {
	Paging     Paging          `json:"paging"`
	Aggregated DepotAggregated `json:"aggregated"`
	Values     []DepotPosition `json:"values"`
}

type DepotTransaction

type DepotTransaction struct {
	TransactionID        string      `json:"transactionId"`
	Instrument           Instrument  `json:"instrument"`
	ExecutionPrice       AmountValue `json:"executionPrice"`
	TransactionValue     AmountValue `json:"transactionValue"`
	TransactionDirection string      `json:"transactionDirection"`
	TransactionType      string      `json:"transactionType"`
	FXRate               string      `json:"fxRate"`
}

type DepotTransactions

type DepotTransactions struct {
	Paging Paging             `json:"paging"`
	Values []DepotTransaction `json:"values"`
}

type Depots

type Depots struct {
	Paging Paging  `json:"paging"`
	Values []Depot `json:"values"`
}

type Dimension

type Dimension struct {
	Venues []Venue `json:"venues"`
}

type Dimensions

type Dimensions struct {
	Values []Dimension
}

type Document

type Document struct {
	DocumentID       string           `json:"documentId"`
	Name             string           `json:"name"`
	DateCreation     string           `json:"dateCreation"`
	MimeType         string           `json:"mimeType"`
	Deletable        bool             `json:"deletable"`
	Advertisement    bool             `json:"advertisement"`
	DocumentMetaData DocumentMetaData `json:"documentMetaData"`
}

type DocumentMetaData

type DocumentMetaData struct {
	Archived          bool `json:"archived"`
	AlreadyRead       bool `json:"alreadyRead"`
	PreDocumentExists bool `json:"predocumentExists"`
}

type Documents

type Documents struct {
	Paging Paging     `json:"paging"`
	Values []Document `json:"values"`
}

type HTTPClient

type HTTPClient struct {
	http.Client
}

type Instrument

type Instrument struct {
	InstrumentID string     `json:"instrumentId"`
	WKN          string     `json:"wkn"`
	ISIN         string     `json:"isin"`
	Mnemonic     string     `json:"mnemonic"`
	Name         string     `json:"name"`
	ShortName    string     `json:"shortName"`
	StaticData   StaticData `json:"staticData"`
}

type Instruments

type Instruments struct {
	Values []Instrument `json:"values"`
}

type Options

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

func EmptyOptions

func EmptyOptions() Options

func (*Options) Add

func (o *Options) Add(key string, value string) *Options

func (*Options) Values

func (o *Options) Values() Values

func (*Options) WithValues

func (o *Options) WithValues(values Values) *Options

type OrderRequest

type OrderRequest struct {
	DepotID      string      `json:"depotId,omitempty"`
	OrderID      string      `json:"orderId,omitempty"`
	Side         string      `json:"side"`
	InstrumentID string      `json:"instrumentId"`
	OrderType    string      `json:"orderType"`
	Quantity     AmountValue `json:"quantity"`
	VenueID      string      `json:"venueId"`
	Limit        AmountValue `json:"limit"`
	ValidityType string      `json:"validityType"`
	Validity     string      `json:"validity"`
}

type OrderType

type OrderType struct {
	LimitExtensions     []string `json:"limitExtensions"`
	TradingRestrictions []string `json:"tradingRestrictions"`
}

type OrderTypes

type OrderTypes struct {
	Quote              OrderType `json:"QUOTE"`
	Market             OrderType `json:"MARKET"`
	StopMarket         OrderType `json:"STOP_MARKET"`
	NextOrder          OrderType `json:"NEXT_ORDER"`
	OneCancelsOther    OrderType `json:"ONE_CANCELS_ORDER"`
	Limit              OrderType `json:"LIMIT"`
	TrailingStopMarket OrderType `json:"TRAILING_STOP_MARKET"`
}

type Paging

type Paging struct {
	Index   int `json:"index"`
	Matches int `json:"matches"`
}

type Price

type Price struct {
	Price         AmountValue `json:"price"`
	PriceDateTime string      `json:"priceDateTime"`
}

type Remitter

type Remitter struct {
	HolderName string `json:"holderName"`
}

type Report

type Report struct {
	ProductID            string        `json:"productId"`
	ProductType          string        `json:"productType"`
	TargetClientID       string        `json:"targetClientId"`
	ClientConnectionType string        `json:"clientConnectionType"`
	Balance              ReportBalance `json:"balance"`
}

type ReportAggregated

type ReportAggregated struct {
	BalanceEUR             AmountValue `json:"balanceEUR"`
	AvailableCashAmountEUR AmountValue `json:"availableCashAmountEUR"`
}

type ReportBalance

type ReportBalance struct {
	Account                Account     `json:"account"`
	AccountId              string      `json:"accountId"`
	Balance                AmountValue `json:"balance"`
	BalanceEUR             AmountValue `json:"balanceEUR"`
	AvailableCashAmount    AmountValue `json:"availableCashAmount"`
	AvailableCashAmountEUR AmountValue `json:"availableCashAmountEUR"`
	Depot                  Depot       `json:"depot"`
	DepotID                string      `json:"depotId"`
	DateLastUpdate         string      `json:"dateLastUpdate"`
	PrevDayValue           AmountValue `json:"prevDayValue"`
}

type Reports

type Reports struct {
	Paging           Paging           `json:"paging"`
	ReportAggregated ReportAggregated `json:"Aggregated"`
	Values           []Report         `json:"values"`
}

type StaticData

type StaticData struct {
	Notation               string `json:"notation"`
	Currency               string `json:"currency"`
	InstrumentType         string `json:"instrumentType"`
	PriipsRelevant         bool   `json:"priipsRelevant"`
	KidAvailable           bool   `json:"kidAvailable"`
	ShippingWaiverRequired bool   `json:"shippingWaiverRequired"`
	FundRedemptionLimited  bool   `json:"fundRedemptionLimited"`
}

type TransactionType

type TransactionType struct {
	Key  string `json:"key"`
	Text string `json:"text"`
}

type Values

type Values map[string]string

type Venue

type Venue struct {
	Name          string     `json:"name"`
	VenueID       string     `json:"venueId"`
	Country       string     `json:"country"`
	Type          string     `json:"type"`
	Currencies    []string   `json:"currencies"`
	Sides         []string   `json:"sides"`
	ValidityTypes []string   `json:"validityTypes"`
	OrderTypes    OrderTypes `json:"orderTypes"`
}

Jump to

Keyboard shortcuts

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