portfolio

package
Version: v0.0.0-...-a2c5123 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 5 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 progresss 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:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

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

This section is empty.

Functions

func GetCryptoIDAddress

func GetCryptoIDAddress(address string, coinType string) (float64, error)

GetCryptoIDAddress queries CryptoID for an address balance for a specified cryptocurrency

func StartPortfolioWatcher

func StartPortfolioWatcher()

StartPortfolioWatcher observes the portfolio object

Types

type Address

type Address struct {
	Address     string
	CoinType    string
	Balance     float64
	Description string
}

Address sub type holding address information for portfolio

type Base

type Base struct {
	Addresses []Address
}

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, coinType, description string, balance float64)

AddAddress adds an address to the portfolio base

func (*Base) AddExchangeAddress

func (p *Base) AddExchangeAddress(exchangeName, coinType string, 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, coinType string) 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, coinType, description string) (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[string]float64

GetExchangePortfolio returns current portfolio base information

func (*Base) GetPersonalPortfolio

func (p *Base) GetPersonalPortfolio() map[string]float64

GetPersonalPortfolio returns current portfolio base information

func (*Base) GetPortfolioByExchange

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

GetPortfolioByExchange returns currency portfolio amount by exchange

func (*Base) GetPortfolioGroupedCoin

func (p *Base) GetPortfolioGroupedCoin() map[string][]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, coinType, description string)

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

func (*Base) RemoveExchangeAddress

func (p *Base) RemoveExchangeAddress(exchangeName, coinType string)

RemoveExchangeAddress removes an exchange address from the portfolio.

func (*Base) SeedPortfolio

func (p *Base) SeedPortfolio(port Base)

SeedPortfolio 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, coinType string, balance float64)

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

func (*Base) UpdatePortfolio

func (p *Base) UpdatePortfolio(addresses []string, coinType string) bool

UpdatePortfolio adds to the portfolio addresses by coin type

type Coin

type Coin struct {
	Coin       string  `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"`
			Ts       int    `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[string][]OfflineCoinSummary         `json:"offline_summary"`
	Online         []Coin                                  `json:"coins_online"`
	OnlineSummary  map[string]map[string]OnlineCoinSummary `json:"online_summary"`
}

Summary Stores the entire portfolio summary

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL