portfolio

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 7 Imported by: 0

README

GoCryptoTrader package Portfolio

Build Status Software License GoDoc Coverage Status Go Report Card

This portfolio package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Current Features for portfolio

  • This package allows for the monitoring of portfolio data.
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

View Source
const (

	// PortfolioAddressExchange is a label for an exchange address
	PortfolioAddressExchange = "Exchange"
	// PortfolioAddressPersonal is a label for a personal/offline address
	PortfolioAddressPersonal = "Personal"
)

Variables

View Source
var Verbose bool

Verbose allows for debug output when sending an http request

Functions

func GetCryptoIDAddress

func GetCryptoIDAddress(address string, coinType currency.Code) (float64, error)

GetCryptoIDAddress queries CryptoID for an address balance for a specified cryptocurrency

func GetRippleBalance

func GetRippleBalance(address string) (float64, error)

GetRippleBalance returns the value for a ripple address

func IsColdStorage

func IsColdStorage(address string) (ret bool)

IsColdStorage checks if address is a cold storage wallet

func IsExchangeSupported

func IsExchangeSupported(exchange, address string) (ret bool)

IsExchangeSupported checks if exchange is supported by portfolio address

func IsWhiteListed

func IsWhiteListed(address string) (ret bool)

IsWhiteListed checks if address is whitelisted for withdraw transfers

func StartPortfolioWatcher

func StartPortfolioWatcher()

StartPortfolioWatcher observes the portfolio object

Types

type AccountInfo

type AccountInfo struct {
	Name        string `json:"name"`
	Description string `json:"desc"`
	Account     string `json:"account"`
	Domain      string `json:"domain"`
	Twitter     string `json:"twitter"`
	Verified    bool   `json:"verified"`
}

AccountInfo is a XRPScan subtype for account associations

type Address

type Address struct {
	Address            string
	CoinType           currency.Code
	Balance            float64
	Description        string
	WhiteListed        bool
	ColdStorage        bool
	SupportedExchanges string
}

Address sub type holding address information for portfolio

type Base

type Base struct {
	Addresses []Address `json:"addresses"`
}

Base holds the portfolio base addresses

var Portfolio Base

Portfolio is variable store holding an array of portfolioAddress

func GetPortfolio

func GetPortfolio() *Base

GetPortfolio returns a pointer to the portfolio base

func (*Base) AddAddress

func (p *Base) AddAddress(address, description string, coinType currency.Code, balance float64) error

AddAddress adds an address to the portfolio base

func (*Base) AddExchangeAddress

func (p *Base) AddExchangeAddress(exchangeName string, coinType currency.Code, balance float64)

AddExchangeAddress adds an exchange address to the portfolio base

func (*Base) AddressExists

func (p *Base) AddressExists(address string) bool

AddressExists checks to see if there is an address associated with the portfolio base

func (*Base) ExchangeAddressExists

func (p *Base) ExchangeAddressExists(exchangeName string, coinType currency.Code) bool

ExchangeAddressExists checks to see if there is an exchange address associated with the portfolio base

func (*Base) ExchangeExists

func (p *Base) ExchangeExists(exchangeName string) bool

ExchangeExists checks to see if an exchange exists in the portfolio base

func (*Base) GetAddressBalance

func (p *Base) GetAddressBalance(address, description string, coinType currency.Code) (float64, bool)

GetAddressBalance acceses the portfolio base and returns the balance by passed in address, coin type and description

func (*Base) GetExchangePortfolio

func (p *Base) GetExchangePortfolio() map[currency.Code]float64

GetExchangePortfolio returns current portfolio base information

func (*Base) GetPersonalPortfolio

func (p *Base) GetPersonalPortfolio() map[currency.Code]float64

GetPersonalPortfolio returns current portfolio base information

func (*Base) GetPortfolioByExchange

func (p *Base) GetPortfolioByExchange(exchangeName string) map[currency.Code]float64

GetPortfolioByExchange returns currency portfolio amount by exchange

func (*Base) GetPortfolioGroupedCoin

func (p *Base) GetPortfolioGroupedCoin() map[currency.Code][]string

GetPortfolioGroupedCoin returns portfolio base information grouped by coin

func (*Base) GetPortfolioSummary

func (p *Base) GetPortfolioSummary() Summary

GetPortfolioSummary returns the complete portfolio summary, showing coin totals, offline and online summaries with their relative percentages.

func (*Base) RemoveAddress

func (p *Base) RemoveAddress(address, description string, coinType currency.Code) error

RemoveAddress removes an address when checked against the correct address and coinType

func (*Base) RemoveExchangeAddress

func (p *Base) RemoveExchangeAddress(exchangeName string, coinType currency.Code)

RemoveExchangeAddress removes an exchange address from the portfolio.

func (*Base) Seed

func (p *Base) Seed(port Base)

Seed appends a portfolio base object with another base portfolio addresses

func (*Base) UpdateAddressBalance

func (p *Base) UpdateAddressBalance(address string, amount float64)

UpdateAddressBalance updates the portfolio base balance

func (*Base) UpdateExchangeAddressBalance

func (p *Base) UpdateExchangeAddressBalance(exchangeName string, coinType currency.Code, balance float64)

UpdateExchangeAddressBalance updates the portfolio balance when checked against correct exchangeName and coinType.

func (*Base) UpdatePortfolio

func (p *Base) UpdatePortfolio(addresses []string, coinType currency.Code) error

UpdatePortfolio adds to the portfolio addresses by coin type

type Coin

type Coin struct {
	Coin       currency.Code `json:"coin"`
	Balance    float64       `json:"balance"`
	Address    string        `json:"address,omitempty"`
	Percentage float64       `json:"percentage,omitempty"`
}

Coin stores a coin type, balance, address and percentage relative to the total amount.

type EtherchainBalanceResponse

type EtherchainBalanceResponse struct {
	Status int `json:"status"`
	Data   []struct {
		Address   string      `json:"address"`
		Balance   float64     `json:"balance"`
		Nonce     interface{} `json:"nonce"`
		Code      string      `json:"code"`
		Name      interface{} `json:"name"`
		Storage   interface{} `json:"storage"`
		FirstSeen interface{} `json:"firstSeen"`
	} `json:"data"`
}

EtherchainBalanceResponse holds JSON incoming and outgoing data for Etherchain

type EthplorerResponse

type EthplorerResponse struct {
	Address string `json:"address"`
	ETH     struct {
		Balance  float64 `json:"balance"`
		TotalIn  float64 `json:"totalIn"`
		TotalOut float64 `json:"totalOut"`
	} `json:"ETH"`
	CountTxs     int `json:"countTxs"`
	ContractInfo struct {
		CreatorAddress  string `json:"creatorAddress"`
		TransactionHash string `json:"transactionHash"`
		Timestamp       int    `json:"timestamp"`
	} `json:"contractInfo"`
	TokenInfo struct {
		Address        string `json:"address"`
		Name           string `json:"name"`
		Decimals       int    `json:"decimals"`
		Symbol         string `json:"symbol"`
		TotalSupply    string `json:"totalSupply"`
		Owner          string `json:"owner"`
		LastUpdated    int    `json:"lastUpdated"`
		TotalIn        int64  `json:"totalIn"`
		TotalOut       int64  `json:"totalOut"`
		IssuancesCount int    `json:"issuancesCount"`
		HoldersCount   int    `json:"holdersCount"`
		Image          string `json:"image"`
		Description    string `json:"description"`
		Price          struct {
			Rate      int    `json:"rate"`
			Diff      int    `json:"diff"`
			Timestamp int64  `json:"ts"`
			Currency  string `json:"currency"`
		} `json:"price"`
	} `json:"tokenInfo"`
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

EthplorerResponse holds JSON address data for Ethplorer

func GetEthereumBalance

func GetEthereumBalance(address string) (EthplorerResponse, error)

GetEthereumBalance single or multiple address information as EtherchainBalanceResponse

type ExchangeAccountCurrencyInfo

type ExchangeAccountCurrencyInfo struct {
	CurrencyName string
	TotalValue   float64
	Hold         float64
}

ExchangeAccountCurrencyInfo : Sub type to store currency name and value

type ExchangeAccountInfo

type ExchangeAccountInfo struct {
	ExchangeName string
	Currencies   []ExchangeAccountCurrencyInfo
}

ExchangeAccountInfo : Generic type to hold each exchange's holdings in all enabled currencies

type OfflineCoinSummary

type OfflineCoinSummary struct {
	Address    string  `json:"address"`
	Balance    float64 `json:"balance"`
	Percentage float64 `json:"percentage,omitempty"`
}

OfflineCoinSummary stores a coin types address, balance and percentage relative to the total amount.

type OnlineCoinSummary

type OnlineCoinSummary struct {
	Balance    float64 `json:"balance"`
	Percentage float64 `json:"percentage,omitempty"`
}

OnlineCoinSummary stores a coin types balance and percentage relative to the total amount.

type Summary

type Summary struct {
	Totals         []Coin                                         `json:"coin_totals"`
	Offline        []Coin                                         `json:"coins_offline"`
	OfflineSummary map[currency.Code][]OfflineCoinSummary         `json:"offline_summary"`
	Online         []Coin                                         `json:"coins_online"`
	OnlineSummary  map[string]map[currency.Code]OnlineCoinSummary `json:"online_summary"`
}

Summary Stores the entire portfolio summary

type XRPScanAccount

type XRPScanAccount struct {
	Sequence                                  int     `json:"sequence"`
	XRPBalance                                float64 `json:"xrpBalance,string"`
	OwnerCount                                int     `json:"ownerCount"`
	PreviousAffectingTransactionID            string  `json:"previousAffectingTransactionID"`
	PreviousAffectingTransactionLedgerVersion int     `json:"previousAffectingTransactionLedgerVersion"`
	Settings                                  struct {
		RequireDestinationTag bool   `json:"requireDestinationTag"`
		EmailHash             string `json:"emailHash"`
		Domain                string `json:"domain"`
	} `json:"settings"`
	Account        string      `json:"account"`
	Parent         string      `json:"parent"`
	InitialBalance float64     `json:"initial_balance"`
	Inception      time.Time   `json:"inception"`
	LedgerIndex    int         `json:"ledger_index"`
	TxHash         string      `json:"tx_hash"`
	AccountName    AccountInfo `json:"accountName"`
	ParentName     AccountInfo `json:"parentName"`
	Advisory       interface{} `json:"advisory"`
}

XRPScanAccount defines the return type for account data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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