package module
v0.0.0-...-c1181c0 Latest Latest

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 13 Imported by: 0



go-degiro is a Go client library for the unofficial Degiro API & Vwd streaming API


go get


Degiro API
    client := degiro.NewClient(http.DefaultClient)
    client.UpdatePeriod = 2 * time.Second
    client.HistoricalPositionUpdatePeriod = 1 * time.Minute
    client.StreamingUpdatePeriod = 1 * time.Second

    err := client.Login("username", "password")
    if err != nil {
    time.Sleep(2 * time.Second) // let time for first update

    // Balance
    balance := client.GetBalance()
    fmt.Printf("%+v\n", balance)

    // Get streaming quote for product
    if product, ok, err := client.SearchProduct("APPLE"); err == nil && ok {
        err = client.SubscribeQuotes([]string{product.VwdId})
        time.Sleep(2 * time.Second) // let time to update quote
        quote := client.GetQuote(product.VwdId)
        fmt.Printf("%+v\n", quote)


MIT License




This section is empty.


This section is empty.


func GetPru

func GetPru(transactions []Transaction) decimal.Decimal


type ActionType

type ActionType string
const (
	Buy  ActionType = "BUY"
	Sell ActionType = "SELL"

type Balance

type Balance struct {
	Cash                decimal.Decimal
	FreeSpaceNewInEuros decimal.Decimal
	ReportPortfValue    decimal.Decimal
	ReportNetliq        decimal.Decimal

type BalanceCache

type BalanceCache struct {
	// contains filtered or unexported fields

func (*BalanceCache) Get

func (c *BalanceCache) Get() Balance

func (*BalanceCache) Set

func (c *BalanceCache) Set(balance Balance)

type Client

type Client struct {
	UpdatePeriod                   time.Duration
	StreamingUpdatePeriod          time.Duration
	TryReloginOn401                bool
	HistoricalPositionUpdatePeriod time.Duration
	// contains filtered or unexported fields

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) DeleteOrder

func (c *Client) DeleteOrder(orderid string) error

func (*Client) GetAllHistoricalPositions

func (c *Client) GetAllHistoricalPositions() []HistoricalPosition

func (*Client) GetBalance

func (c *Client) GetBalance() Balance

func (*Client) GetOpenedHistoricalPositionForProduct

func (c *Client) GetOpenedHistoricalPositionForProduct(productid string) (HistoricalPosition, bool)

func (*Client) GetOpenedPositionForProduct

func (c *Client) GetOpenedPositionForProduct(productId string) (Position, bool)

func (*Client) GetPendingOrders

func (c *Client) GetPendingOrders(productId int) []Order

func (*Client) GetProduct

func (c *Client) GetProduct(productId string) (Product, bool)

func (*Client) GetProducts

func (c *Client) GetProducts(productIds []string) []Product

func (*Client) GetQuote

func (c *Client) GetQuote(productvwid string) streaming.ProductQuote

func (*Client) GetTransactions

func (c *Client) GetTransactions(fromDate time.Time, toDate time.Time) ([]Transaction, error)

func (*Client) Login

func (c *Client) Login(username string, password string) error

func (*Client) NewStreamingClient

func (c *Client) NewStreamingClient(httpclient *http.Client, updatePeriod time.Duration) *streaming.Client

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(input PlaceOrderInput) (string, error)

func (*Client) ReceiveSuccessReloginOn401

func (c *Client) ReceiveSuccessReloginOn401(s *sling.Sling, successV interface{}) (*http.Response, error)

func (*Client) SearchProduct

func (c *Client) SearchProduct(searchtext string) (*Product, bool, error)

func (*Client) SearchProducts

func (c *Client) SearchProducts(options SearchProductsOptions) ([]Product, error)

func (*Client) SubscribeQuotes

func (c *Client) SubscribeQuotes(idlist []string) error

func (*Client) UnSubscribeQuotes

func (c *Client) UnSubscribeQuotes(idlist []string) error

type Configuration

type Configuration struct {
	ClientId               int    `json:"clientId"`
	SessionId              string `json:"sessionId"`
	TradingUrl             string `json:"tradingUrl"`
	I18NUrl                string `json:"i18nUrl"`
	PaymentServiceUrl      string `json:"paymentServiceUrl"`
	ReportingUrl           string `json:"reportingUrl"`
	PaUrl                  string `json:"paUrl"`
	VwdQuotecastServiceUrl string `json:"vwdQuotecastServiceUrl"`
	ProductSearchUrl       string `json:"productSearchUrl"`
	DictionaryUrl          string `json:"dictionaryUrl"`
	TaskManagerUrl         string `json:"taskManagerUrl"`
	FirstLoginWizardUrl    string `json:"firstLoginWizardUrl"`
	VwdGossipsUrl          string `json:"vwdGossipsUrl"`
	CompaniesServiceUrl    string `json:"companiesServiceUrl"`
	ProductTypesUrl        string `json:"productTypesUrl"`
	VwdNewsUrl             string `json:"vwdNewsUrl"`
	LoginUrl               string `json:"loginUrl"`

type Fee

type Fee struct {
	Id       int             `json:"id"`
	Amount   decimal.Decimal `json:"amount"`
	Currency string          `json:"currency"`

type HistoricalPosition

type HistoricalPosition struct {
	ProductId int
	// contains filtered or unexported fields

func (*HistoricalPosition) AddTransaction

func (p *HistoricalPosition) AddTransaction(transaction Transaction)

func (*HistoricalPosition) GetCurrentPerformance

func (p *HistoricalPosition) GetCurrentPerformance(quote streaming.ProductQuote) decimal.Decimal

func (*HistoricalPosition) GetCurrentPerformanceInPercent

func (p *HistoricalPosition) GetCurrentPerformanceInPercent(quote streaming.ProductQuote) decimal.Decimal

func (*HistoricalPosition) GetFirstTransactionDate

func (p *HistoricalPosition) GetFirstTransactionDate() time.Time

func (*HistoricalPosition) GetLastTransactionDate

func (p *HistoricalPosition) GetLastTransactionDate() time.Time

func (*HistoricalPosition) GetPastPerformance

func (p *HistoricalPosition) GetPastPerformance() decimal.Decimal

func (*HistoricalPosition) GetPastPerformanceInPercent

func (p *HistoricalPosition) GetPastPerformanceInPercent() decimal.Decimal

func (*HistoricalPosition) GetPastPerformanceSince

func (p *HistoricalPosition) GetPastPerformanceSince(since time.Time) decimal.Decimal

func (*HistoricalPosition) GetPru

func (p *HistoricalPosition) GetPru() decimal.Decimal

func (*HistoricalPosition) GetSize

func (p *HistoricalPosition) GetSize() int

func (*HistoricalPosition) GetTotalBuyAmount

func (p *HistoricalPosition) GetTotalBuyAmount() decimal.Decimal

func (*HistoricalPosition) GetTransactionCount

func (p *HistoricalPosition) GetTransactionCount() int

type LoginParams

type LoginParams struct {
	Username           string `json:"username"`
	Password           string `json:"password"`
	IsRedirectToMobile bool   `json:"isRedirectToMobile"`

type LoginResponse

type LoginResponse struct {
	IsPassCodeEnabled bool   `json:"isPassCodeEnabled"`
	Locale            string `json:"locale"`
	RedirectUrl       string `json:"redirectUrl"`
	SessionId         string `json:"sessionId"`
	Status            int    `json:"status"`
	StatusText        string `json:"statusText"`

type Order

type Order struct {
	Id              string
	Date            time.Time
	ProductId       int
	ProductName     string
	ContractType    int
	ContractSize    decimal.Decimal
	Currency        string
	BuySell         ActionType
	Size            int
	Quantity        int
	Price           decimal.Decimal
	StopPrice       decimal.Decimal
	TotalOrderValue decimal.Decimal
	OrderType       OrderType
	TimeType        TimeType
	IsModifiable    bool
	IsDeletable     bool

type OrderCache

type OrderCache struct {
	// contains filtered or unexported fields

func (*OrderCache) Add

func (c *OrderCache) Add(orders []Order)

func (*OrderCache) Clear

func (c *OrderCache) Clear()

func (*OrderCache) Get

func (c *OrderCache) Get(productId int) []Order

func (*OrderCache) Remove

func (c *OrderCache) Remove(orderIds []string)

func (*OrderCache) Update

func (c *OrderCache) Update(orders []Order)

type OrderType

type OrderType int
const (
	Limited     OrderType = 0
	MarketOrder OrderType = 2
	StopLoss    OrderType = 3
	StopLimited OrderType = 1

type PlaceOrderInput

type PlaceOrderInput struct {
	BuySell   ActionType      `json:"buySell"`
	OrderType OrderType       `json:"orderType"`
	ProductId string          `json:"productId"`
	Quantity  int             `json:"size"`
	TimeType  TimeType        `json:"timeType"`
	Price     decimal.Decimal `json:"price"`
	StopPrice decimal.Decimal `json:"stopPrice"`

type Position

type Position struct {
	ProductId string
	Size      int

type PositionCache

type PositionCache struct {
	// contains filtered or unexported fields

func (*PositionCache) Add

func (c *PositionCache) Add(positions []Position)

func (*PositionCache) Clear

func (c *PositionCache) Clear()

func (*PositionCache) Get

func (c *PositionCache) Get(productId string) []Position

func (*PositionCache) Remove

func (c *PositionCache) Remove(positionsIds []string)

func (*PositionCache) Update

func (c *PositionCache) Update(positions []Position)

type Product

type Product struct {
	Id                       string          `json:"id"`
	Name                     string          `json:"name"`
	Isin                     string          `json:"isin"`
	Symbol                   string          `json:"symbol"`
	ContractSize             decimal.Decimal `json:"contractSize"`
	ProductTypeName          string          `json:"productType"`
	ProductTypeId            int             `json:"productTypeId"`
	Tradable                 bool            `json:"tradable"`
	Category                 string          `json:"category"`
	Currency                 string          `json:"currency"`
	StrikePrice              decimal.Decimal `json:"strikePrice"`
	ExchangeId               string          `json:"exchangeId"`
	TimeTypes                []string        `json:"orderTimeTypes"`
	GtcAllowed               bool            `json:"gtcAllowed"`
	BuyOrderTypes            []string        `json:"buyOrderTypes"`
	SellOrderTypes           []string        `json:"sellOrderTypes"`
	MarketAllowed            bool            `json:"marketAllowed"`
	LimitHitOrderAllowed     bool            `json:"limitHitOrderAllowed"`
	StopLossAllowed          bool            `json:"stoplossAllowed"`
	StopLimitOrderAllowed    bool            `json:"stopLimitOrderAllowed"`
	JoinOrderAllowed         bool            `json:"joinOrderAllowed"`
	TrailingStopOrderAllowed bool            `json:"trailingStopOrderAllowed"`
	CombinedOrderAllowed     bool            `json:"combinedOrderAllowed"`
	SellAmountAllowed        bool            `json:"sellAmountAllowed"`
	IsFund                   bool            `json:"isFund"`
	ClosePrice               decimal.Decimal `json:"closePrice"`
	ClosePriceDate           productTime     `json:"closePriceDate"`
	FeedQuality              string          `json:"feedQuality"`
	OrderBookDepth           int             `json:"orderBookDepth"`
	VwdIdentifierType        string          `json:"vwdIdentifierType"`
	VwdId                    string          `json:"vwdId"`
	QualitySwitchable        bool            `json:"qualitySwitchable"`
	QualitySwitchFree        bool            `json:"qualitySwitchFree"`
	VwdModuleId              int             `json:"vwdModuleId"`
	ExpirationDate           productTime     `json:"expirationDate"`
	FinancingLevel           decimal.Decimal `json:"financingLevel"`
	Leverage                 decimal.Decimal `json:"leverage"`
	Ratio                    decimal.Decimal `json:"ratio"`
	ShortLong                string          `json:"shortlong"`
	StopLoss                 decimal.Decimal `json:"stoploss"`

type ProductCache

type ProductCache struct {

	CacheInvalidationDuration time.Duration
	// contains filtered or unexported fields

func (*ProductCache) GetProduct

func (c *ProductCache) GetProduct(productId string) (Product, bool)

func (*ProductCache) GetProducts

func (c *ProductCache) GetProducts(productids []string) []Product

type ProductCacheItem

type ProductCacheItem struct {
	Product    Product
	LastUpdate time.Time

type ProductType

type ProductType int
const (
	Fund      ProductType = 13
	Leveraged ProductType = 14
	Index     ProductType = 180
	Etf       ProductType = 131
	Stock     ProductType = 1
	Bond      ProductType = 2
	Cash      ProductType = 311
	Currency  ProductType = 3
	Future    ProductType = 7
	Cfd       ProductType = 535
	Warrant   ProductType = 536
	Option    ProductType = 8

type SearchProductsOptions

type SearchProductsOptions struct {
	SearchText  string
	Limit       int
	ProductType ProductType

type TimeType

type TimeType int
const (
	Day       TimeType = 1
	Permanent TimeType = 3

type Transaction

type Transaction struct {
	BuySell                    string          `json:"buysell"`
	Quantity                   int             `json:"quantity"`
	OrderType                  OrderType       `json:"orderTypeId"`
	CounterParty               string          `json:"counterParty"`
	TotalInBaseCurrency        decimal.Decimal `json:"totalInBaseCurrency"`
	FeeInBaseCurrency          decimal.Decimal `json:"feeInBaseCurrency"`
	TotalPlusFeeInBaseCurrency decimal.Decimal `json:"totalPlusFeeInBaseCurrency"`
	Transfered                 bool            `json:"transfered"`
	ProductId                  int             `json:"productId"`
	Price                      decimal.Decimal `json:"price"`
	Date                       time.Time       `json:"date"`
	Total                      decimal.Decimal `json:"total"`
	Id                         int             `json:"id"`

type TransactionCache

type TransactionCache struct {
	// contains filtered or unexported fields

func (*TransactionCache) GetAllHistoricalPositions

func (c *TransactionCache) GetAllHistoricalPositions() []HistoricalPosition

func (*TransactionCache) GetHistoricalPositionsForProduct

func (c *TransactionCache) GetHistoricalPositionsForProduct(productid string) []HistoricalPosition

func (*TransactionCache) GetOpenedHistoricalPositionForProduct

func (c *TransactionCache) GetOpenedHistoricalPositionForProduct(productid string) (HistoricalPosition, bool)

func (*TransactionCache) Merge

func (c *TransactionCache) Merge(transactions []Transaction)

type UserConfiguration

type UserConfiguration struct {
	ClientId              int    `json:"id"`
	AccountId             int64  `json:"intAccount"`
	ClientRole            string `json:"clientRole"`
	EffectiveClientRole   string `json:"effectiveClientRole"`
	ContractType          string `json:"contractType"`
	Username              string `json:"username"`
	DisplayName           string `json:"displayName"`
	Email                 string `json:"email"`
	CellphoneNumber       string `json:"cellphoneNumber"`
	Locale                string `json:"locale"`
	Language              string `json:"language"`
	Culture               string `json:"culture"`
	MemberCode            string `json:"memberCode"`
	CanUpgrade            bool   `json:"canUpgrade"`
	IsAllocationAvailable bool   `json:"isAllocationAvailable"`
	IsCollectivePortfolio bool   `json:"isCollectivePortfolio"`
	IsAmClientActive      bool   `json:"isAmClientActive"`
	IsIskClient           bool   `json:"isIskClient"`
	IsWithdrawalAvailable bool   `json:"isWithdrawalAvailable"`
	FirstContact          struct {
		FirstName      string `json:"firstName"`
		LastName       string `json:"lastName"`
		DisplayName    string `json:"displayName"`
		Nationality    string `json:"nationality"`
		Gender         string `json:"gender"`
		DateOfBirth    string `json:"dateOfBirth"`
		PlaceOfBirth   string `json:"placeOfBirth"`
		CountryOfBirth string `json:"countryOfBirth"`
		Birthday       string `json:"birthday"`
	} `json:"firstContact"`
	Address struct {
		StreetAddress       string `json:"streetAddress"`
		StreetAddressNumber string `json:"streetAddressNumber"`
		Zip                 string `json:"zip"`
		City                string `json:"city"`
		Country             string `json:"country"`
	} `json:"address"`
	BankAccount struct {
		Iban          string `json:"iban"`
		Bic           string `json:"bic"`
		Name          string `json:"name"`
		BankAccountId int    `json:"bankAccountId"`
	} `json:"bankAccount"`


Path Synopsis

Jump to

Keyboard shortcuts

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