Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TransactionTypeToAction = map[string]Action{ "Buy": BUY, "Sell": SELL, "Paid for an order": SELL, "Send": SELL, "Convert": SELL, "Coinbase Earn": BUY, }
TransactionTypeToAction converts Coinbase transaction types into BUY or SELL Actions
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
Holdings map[string]*LotHistory
}
Account is a Coinbase account, containing a LotHistory per crypto asset
func (*Account) ProcessTransaction ¶
func (a *Account) ProcessTransaction(t *Transaction, sales chan<- *Sale) error
ProcessTransaction replays a transaction in the account, sending any resulting Sales to the sales channel
type Lot ¶
Lot is an amount of crypto purchased in a single event. Used for calculating cost basis and date purchased for accounting purposes.
type LotHistory ¶
LotHistory is a queue data structure that is used to account for all lots of a specific crypto asset.
func (*LotHistory) Quantity ¶
func (h *LotHistory) Quantity() decimal.Decimal
Quantity returns the total number of shares in the LotHistory
func (*LotHistory) Sell ¶
func (h *LotHistory) Sell(quantity decimal.Decimal, spot decimal.Decimal, date time.Time, sales chan<- *Sale) error
Sell processes a transaction against this LotHistory, adding any resulting Sale events to the sales channel
func (*LotHistory) TotalCost ¶
func (h *LotHistory) TotalCost() decimal.Decimal
TotalCost returns the total cost (in USD) of the shares in the LotHistory
type NegativeQuantityErr ¶
type NegativeQuantityErr struct{}
NegativeQuantityErr is an error for a transaction with a negative quantity
func (*NegativeQuantityErr) Error ¶
func (m *NegativeQuantityErr) Error() string
type NegativeSpotErr ¶
type NegativeSpotErr struct{}
NegativeSpotErr is an error for a transaction with a negative spot price
func (*NegativeSpotErr) Error ¶
func (m *NegativeSpotErr) Error() string
type Sale ¶
type Sale struct {
Asset string
SaleDate time.Time
PurchaseDate time.Time
Quantity decimal.Decimal
FifoCost decimal.Decimal
Proceeds decimal.Decimal
}
Sale is a taxable sale event
type Transaction ¶
type Transaction struct {
Timestamp time.Time
Action Action
Asset string
Quantity decimal.Decimal
Spot decimal.Decimal
Currency string
}
Transaction is a crypto transaction as reported by Coinbase
func (Transaction) ToLot ¶
func (t Transaction) ToLot() *Lot
ToLot converts a transaction to a Lot used for accounting purposes