tr

package
v0.0.0-...-a2a535d Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRADEREPUBLICURL = "https://api.traderepublic.com"
	TRADEREPUBLIWSS  = "wss://api.traderepublic.com"
)

Look into https://gitlab.com/marzzzello/pytr/-/blob/master/pytr/account.py https://github.com/Zarathustra2/TradeRepublicApi

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	Creds     *LoginCreds
	ProcessID string
	Session   []*http.Cookie
	Client    *http.Client
	WebSocket *wsconnector.WSConnector

	URL       string
	WSURL     string
	TLSConfig *tls.Config
	// contains filtered or unexported fields
}

func NewAPIClient

func NewAPIClient() *APIClient

func (*APIClient) AddWatchList

func (api *APIClient) AddWatchList(isin string) (int, error)

func (*APIClient) AllTimeline

func (api *APIClient) AllTimeline() (int, error)

func (*APIClient) CancelOrder

func (api *APIClient) CancelOrder(order_id string) (int, error)

func (*APIClient) CancelPriceAlarm

func (api *APIClient) CancelPriceAlarm(price_alarm_id string) (int, error)

func (*APIClient) CancelSavingsPlan

func (api *APIClient) CancelSavingsPlan(savings_plan_id string) (int, error)

func (*APIClient) CashAvailableforOrder

func (api *APIClient) CashAvailableforOrder() (int, error)

func (*APIClient) CashAvailableforPayout

func (api *APIClient) CashAvailableforPayout() (int, error)

func (*APIClient) ChangeSavingsPlan

func (api *APIClient) ChangeSavingsPlan(savings_plan_id string, isin string, amount float64, interval string, start_date string, start_date_type string, start_date_value string, warnings_shown []string) (int, error)

func (*APIClient) CompactPortfolio

func (api *APIClient) CompactPortfolio() (int, error)

func (*APIClient) CreatePriceAlarm

func (api *APIClient) CreatePriceAlarm(isin string, price float64) (int, error)

func (*APIClient) CreateSavingsPlan

func (api *APIClient) CreateSavingsPlan(isin string, amount float64, interval string, start_date string, start_date_type string, start_date_value string, warnings_shown []string) (int, error)

func (*APIClient) Experience

func (api *APIClient) Experience() (int, error)

func (*APIClient) GetProcessID

func (api *APIClient) GetProcessID() string

func (*APIClient) InstrumentDetails

func (api *APIClient) InstrumentDetails(isin string) (int, error)

func (*APIClient) InstrumentSuitability

func (api *APIClient) InstrumentSuitability(isin string) (int, error)

func (*APIClient) LimitedOrder

func (api *APIClient) LimitedOrder(isin string, exchange string, order_type string, size int, limit float64, expiry string, expiry_date string, warnings_shown []string) (int, error)

func (*APIClient) Login

func (api *APIClient) Login() error

func (*APIClient) MarketOrder

func (api *APIClient) MarketOrder(isin string, exchange string, order_type string, size int, expiry string, expiry_date string, warnings_shown []string) (int, error)

func (*APIClient) MessageOfTheDay

func (api *APIClient) MessageOfTheDay() (int, error)

func (*APIClient) NeonCards

func (api *APIClient) NeonCards() (int, error)

func (*APIClient) NeonSearch

func (api *APIClient) NeonSearch(query string, tags []string, page int, pageSize int) (int, error)

func (*APIClient) NeonSearchSuggestedTags

func (api *APIClient) NeonSearchSuggestedTags(query string) (int, error)

func (*APIClient) NeonSearchTags

func (api *APIClient) NeonSearchTags() (int, error)

func (*APIClient) NewWebSocketConnection

func (api *APIClient) NewWebSocketConnection(dataChan chan Message) error

func (*APIClient) News

func (api *APIClient) News(isin string) (int, error)

func (*APIClient) NewsSubscriptions

func (api *APIClient) NewsSubscriptions() (int, error)

func (*APIClient) NextSubscriptionId

func (api *APIClient) NextSubscriptionId() int

func (*APIClient) OrderOverview

func (api *APIClient) OrderOverview() (int, error)

func (*APIClient) OrderPrice

func (api *APIClient) OrderPrice(isin string, exchange string, order_type string) (int, error)

func (*APIClient) OrderSize

func (api *APIClient) OrderSize(isin string, exchange string) (int, error)

func (*APIClient) Performance

func (api *APIClient) Performance(isin string, exchange string) (int, error)

func (*APIClient) PerformanceHistory

func (api *APIClient) PerformanceHistory(isin string, timeframe string, exchange string, resolution string) (int, error)

func (*APIClient) Portfolio deprecated

func (api *APIClient) Portfolio() (int, error)

Deprecated: Use CompactPortfolio instead

func (*APIClient) PortfolioHistory

func (api *APIClient) PortfolioHistory(timeframe string) (int, error)

func (*APIClient) PortfolioStatus

func (api *APIClient) PortfolioStatus() (int, error)

func (*APIClient) PriceAlarmOverview

func (api *APIClient) PriceAlarmOverview() (int, error)

func (*APIClient) RemoveWatchList

func (api *APIClient) RemoveWatchList(isin string) (int, error)

func (*APIClient) SavingsPlanOverview

func (api *APIClient) SavingsPlanOverview() (int, error)

func (*APIClient) SavingsPlanParameters

func (api *APIClient) SavingsPlanParameters(isin string) (int, error)

func (*APIClient) SearchDerivative

func (api *APIClient) SearchDerivative(underlying_isin string, product_type string) (int, error)

func (*APIClient) SetBaseURL

func (api *APIClient) SetBaseURL(url string)

func (*APIClient) SetCredentials

func (api *APIClient) SetCredentials(number, pin string)

func (*APIClient) SetHTTPClient

func (api *APIClient) SetHTTPClient(client *http.Client)

func (*APIClient) SetLocal

func (api *APIClient) SetLocal(local string)

func (*APIClient) SetTLSConfig

func (api *APIClient) SetTLSConfig(config *tls.Config)

func (*APIClient) SetWSBaseURL

func (api *APIClient) SetWSBaseURL(url string)

func (*APIClient) StockDetails

func (api *APIClient) StockDetails(isin string) (int, error)

func (*APIClient) StopMarketOrder

func (api *APIClient) StopMarketOrder(isin string, exchange string, order_type string, size int, limit float64, stop float64, expiry string, expiry_date string, warnings_shown []string) (int, error)

func (*APIClient) Subscribe

func (api *APIClient) Subscribe(payload map[string]interface{}) (int, error)

func (*APIClient) SubscribeNews

func (api *APIClient) SubscribeNews(isin string) (int, error)

func (*APIClient) Ticker

func (api *APIClient) Ticker(isin string, exchange string) (int, error)

func (*APIClient) Timeline

func (api *APIClient) Timeline(after string) (int, error)

func (*APIClient) TimelineDetail

func (api *APIClient) TimelineDetail(timelineId string) (int, error)

func (*APIClient) TimelineDetailOrder

func (api *APIClient) TimelineDetailOrder(order_id int) (int, error)

func (*APIClient) TimelineDetailSavingsPlan

func (api *APIClient) TimelineDetailSavingsPlan(savings_plan_id int) (int, error)

func (*APIClient) Unsubscribe

func (api *APIClient) Unsubscribe(subscriptionId int)

func (*APIClient) UnsubscribeNews

func (api *APIClient) UnsubscribeNews(isin string) (int, error)

func (*APIClient) VerifyLogin

func (api *APIClient) VerifyLogin(verifyCode int) error

func (*APIClient) Watchlist

func (api *APIClient) Watchlist() (int, error)

type Action

type Action struct {
	Type    string      `json:"type,omitempty"`
	Payload interface{} `json:"payload,omitempty"`
}

type Doc

type Doc struct {
	Title  string `json:"title"`
	Detail string `json:"detail"`
	Action struct {
		Type    string `json:"type"`
		Payload string `json:"payload"`
	} `json:"action"`
	ID          string `json:"id"`
	PostboxType string `json:"postboxType"`
}

type Downloader

type Downloader struct {
	TR             *APIClient
	OutputPath     string
	HistoryFile    string
	FilenameFmt    string
	FilePaths      []string
	DocUrls        []string
	DocUrlsHistory []string
	TimeLine       *TimeLine
}

func NewDownloader

func NewDownloader(client *APIClient) *Downloader

func (*Downloader) CreateOutputDir

func (d *Downloader) CreateOutputDir() error

func (*Downloader) Download

func (d *Downloader) Download(doc Doc, titleText string, subTitleText string, subFolder string) error

func (*Downloader) DownloadAll

func (d *Downloader) DownloadAll(ctx context.Context, data chan Message) error

func (*Downloader) DownloadDocument

func (d *Downloader) DownloadDocument(docUrl string, filePath string) error

func (*Downloader) DownloadTimeLineDetails

func (d *Downloader) DownloadTimeLineDetails(response TimelineDetail, maxAgeTimestamp int64, isSavingsPlan bool) error

func (*Downloader) ExportAccountTransactionsCSV

func (d *Downloader) ExportAccountTransactionsCSV() error

func (*Downloader) ExportTransactionsJSON

func (d *Downloader) ExportTransactionsJSON() error

func (*Downloader) ReadHistoryFile

func (d *Downloader) ReadHistoryFile() error

func (*Downloader) SetFilenameFmt

func (d *Downloader) SetFilenameFmt(fmt string)

func (*Downloader) SetHistoryFile

func (d *Downloader) SetHistoryFile(path string)

func (*Downloader) SetOutputPath

func (d *Downloader) SetOutputPath(path string)

func (*Downloader) WriteFile

func (d *Downloader) WriteFile(data []TimeLineEvent, filename string) error

func (*Downloader) WriteHistoryFile

func (d *Downloader) WriteHistoryFile(docUrl string) error

type LoginCreds

type LoginCreds struct {
	Number string `json:"phoneNumber"`
	Pin    string `json:"pin"`
}

type Message

type Message struct {
	SubscriptionId int
	Subscription   map[string]interface{}
	Payload        map[string]interface{}
}

Example: "0 C {payload}"

type Portfolio

type Portfolio struct {
	Positions []Position `json:"positions"`
}

func (*Portfolio) GetPositions

func (p *Portfolio) GetPositions() []Position

func (*Portfolio) GetPositionsAsBytes

func (p *Portfolio) GetPositionsAsBytes() ([]byte, error)

type PortfolioLoader

type PortfolioLoader struct {
	Client *APIClient
	Portfolio
}

func NewPortfolioLoader

func NewPortfolioLoader(client *APIClient) *PortfolioLoader

func (*PortfolioLoader) LoadPortfolio

func (p *PortfolioLoader) LoadPortfolio(ctx context.Context, data chan Message) error

type Position

type Position struct {
	InstrumentID string  `json:"instrumentId"`
	NetSize      float64 `json:"netSize"`
	AverageBuyIn float64 `json:"averageBuyIn"`
}

type RawSavingsPlans

type RawSavingsPlans struct {
	SavingsPlans []struct {
		ID           string  `json:"id"`
		CreatedAt    int64   `json:"createdAt"`
		InstrumentID string  `json:"instrumentId"`
		Amount       float64 `json:"amount"`
		Interval     string  `json:"interval"`
		StartDate    struct {
			Type              string `json:"type"`
			Value             int    `json:"value"`
			NextExecutionDate string `json:"nextExecutionDate"`
		} `json:"startDate"`
		FirstExecutionDate           interface{} `json:"firstExecutionDate"`
		NextExecutionDate            string      `json:"nextExecutionDate"`
		PreviousExecutionDate        string      `json:"previousExecutionDate"`
		VirtualPreviousExecutionDate string      `json:"virtualPreviousExecutionDate"`
		FinalExecutionDate           interface{} `json:"finalExecutionDate"`
		PaymentMethodID              interface{} `json:"paymentMethodId"`
		PaymentMethodCode            interface{} `json:"paymentMethodCode"`
		LastPaymentExecutionDate     interface{} `json:"lastPaymentExecutionDate"`
		Paused                       bool        `json:"paused"`
	} `json:"savingsPlans"`
}

type RawTimeline

type RawTimeline struct {
	Data    []TimeLineEvent `json:"data"`
	Cursors struct {
		Before string `json:"before,omitempty"`
		After  string `json:"after,omitempty"`
	} `json:"cursors"`
}

type Response

type Response struct {
	Status  int         `json:"status"`
	Payload interface{} `json:"payload,omitempty"`
}

type SavingsPlan

type SavingsPlan struct {
	ID           string  `json:"id"`
	CreatedAt    int64   `json:"createdAt"`
	InstrumentID string  `json:"instrumentId"`
	Amount       float64 `json:"amount"`
	Interval     string  `json:"interval"`
	StartDate    struct {
		Type              string `json:"type"`
		Value             int    `json:"value"`
		NextExecutionDate string `json:"nextExecutionDate"`
	} `json:"startDate"`
	FirstExecutionDate           interface{} `json:"firstExecutionDate"`
	NextExecutionDate            string      `json:"nextExecutionDate"`
	PreviousExecutionDate        string      `json:"previousExecutionDate"`
	VirtualPreviousExecutionDate string      `json:"virtualPreviousExecutionDate"`
	FinalExecutionDate           interface{} `json:"finalExecutionDate"`
	PaymentMethodID              interface{} `json:"paymentMethodId"`
	PaymentMethodCode            interface{} `json:"paymentMethodCode"`
	LastPaymentExecutionDate     interface{} `json:"lastPaymentExecutionDate"`
	Paused                       bool        `json:"paused"`
}

type SavingsPlaner

type SavingsPlaner struct {
	Client *APIClient
	Plans  []SavingsPlan
}

func NewSavingsPlan

func NewSavingsPlan(client *APIClient) *SavingsPlaner

func (*SavingsPlaner) GetAddedAmountForMonth

func (s *SavingsPlaner) GetAddedAmountForMonth() (float64, error)

func (*SavingsPlaner) GetAllSavingPlansIDs

func (s *SavingsPlaner) GetAllSavingPlansIDs() []string

func (*SavingsPlaner) GetAmountForMonth

func (s *SavingsPlaner) GetAmountForMonth(id string) (float64, error)

func (*SavingsPlaner) GetSavingsPlan

func (s *SavingsPlaner) GetSavingsPlan(id string) (SavingsPlan, error)

func (*SavingsPlaner) GetSavingsPlanAmount

func (s *SavingsPlaner) GetSavingsPlanAmount(id string) (float64, error)

func (*SavingsPlaner) GetSavingsPlanAsBytes

func (s *SavingsPlaner) GetSavingsPlanAsBytes(id string) ([]byte, error)

func (*SavingsPlaner) GetSavingsPlans

func (s *SavingsPlaner) GetSavingsPlans() []SavingsPlan

func (*SavingsPlaner) GetSavingsPlansAsBytes

func (s *SavingsPlaner) GetSavingsPlansAsBytes() ([]byte, error)

func (*SavingsPlaner) LoadSavingsplans

func (s *SavingsPlaner) LoadSavingsplans(ctx context.Context, data chan Message) error

type TimeLine

type TimeLine struct {
	Client                    *APIClient
	ReceivedDetail            int
	RequestedDetail           int
	NumberofTimlineDetails    int
	NumberofTimline           int
	SinceTimestamp            int64
	TimeLineEvents            []TimeLineEvent
	TimeLineEventsWithDocs    []TimeLineEvent
	TimelineEventsWithoutDocs []TimeLineEvent
	TimelineDetails           []TimelineDetail
}

func NewTimeLine

func NewTimeLine(client *APIClient) *TimeLine

func (*TimeLine) FindTimeLineEventsWithDocs

func (t *TimeLine) FindTimeLineEventsWithDocs(event TimeLineEvent, maxAgeTimestamp int64) bool

func (*TimeLine) GetTimeLineDetails

func (t *TimeLine) GetTimeLineDetails() []TimelineDetail

func (*TimeLine) GetTimeLineDetailsAsBytes

func (t *TimeLine) GetTimeLineDetailsAsBytes() ([]byte, error)

func (*TimeLine) GetTimeLineEvents

func (t *TimeLine) GetTimeLineEvents() []TimeLineEvent

func (*TimeLine) GetTimeLineEventsAsBytes

func (t *TimeLine) GetTimeLineEventsAsBytes() ([]byte, error)

func (*TimeLine) GetTimeLineEventsWithDocs

func (t *TimeLine) GetTimeLineEventsWithDocs() []TimeLineEvent

func (*TimeLine) GetTimeLineEventsWithoutDocs

func (t *TimeLine) GetTimeLineEventsWithoutDocs() []TimeLineEvent

func (*TimeLine) LoadNextTimeline

func (t *TimeLine) LoadNextTimeline(response map[string]interface{}, maxAgeTimestamp int64) (int, error)

func (*TimeLine) LoadTimeLine

func (t *TimeLine) LoadTimeLine(ctx context.Context, data chan Message) error

func (*TimeLine) LoadTimeLineDetails

func (t *TimeLine) LoadTimeLineDetails(ctx context.Context, data chan Message) error

func (*TimeLine) RequestTimeLineDetails

func (t *TimeLine) RequestTimeLineDetails(numToRequest *int, maxAgeTimestamp int64) (int, error)

func (*TimeLine) SetSinceTimestamp

func (t *TimeLine) SetSinceTimestamp(sinceTimestamp int64)

func (*TimeLine) SumTotalOfTimeLineEventsWDocsAndWithoutDocs

func (t *TimeLine) SumTotalOfTimeLineEventsWDocsAndWithoutDocs() int

type TimeLineEvent

type TimeLineEvent struct {
	Type string `json:"type"`
	Data struct {
		ID        string `json:"id"`
		Timestamp int64  `json:"timestamp"`
		Icon      string `json:"icon"`
		Title     string `json:"title"`
		Body      string `json:"body"`
		Action    struct {
			Type    string      `json:"type,omitempty"`
			Payload interface{} `json:"payload,omitempty"`
		} `json:"action,omitempty"`
		ActionLabel      string        `json:"actionLabel,omitempty"`
		Attributes       []interface{} `json:"attributes"`
		Month            string        `json:"month"`
		CashChangeAmount float64       `json:"cashChangeAmount,omitempty"`
	} `json:"data"`
}

type TimelineDetail

type TimelineDetail struct {
	ID           string `json:"id"`
	TitleText    string `json:"titleText"`
	SubtitleText string `json:"subtitleText"`
	Sections     []struct {
		Data      []interface{}
		Type      string `json:"type"`
		Title     string `json:"title"`
		Documents []Doc  `json:"documents"`
	} `json:"sections"`
}

Jump to

Keyboard shortcuts

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