Documentation ¶
Index ¶
- Constants
- type AccountEntry
- type AccountLog
- func (acc *AccountLog) Clone() TransactionEntry
- func (acc *AccountLog) EnsureAccounts(prototype AccountStatus) AccountEntry
- func (acc *AccountLog) GetAccountStatus() AccountStatus
- func (acc *AccountLog) GetAssetPair() AssetPair
- func (acc *AccountLog) GetAssetSize() float64
- func (acc *AccountLog) GetCreatedAt() time.Time
- func (acc *AccountLog) GetExchange() string
- func (acc *AccountLog) GetFee() float64
- func (acc *AccountLog) GetID() string
- func (acc *AccountLog) GetPricePerUnit() float64
- func (acc *AccountLog) GetSide() SideType
- func (acc *AccountLog) GetSideIdentifier() string
- func (acc *AccountLog) GetTotalPrice() float64
- func (acc *AccountLog) GetTranslatedAssets() []AssetType
- func (acc *AccountLog) GetTranslatedFee(asset AssetType) float64
- func (acc *AccountLog) GetTranslatedTotalPrice(asset AssetType) float64
- func (acc *AccountLog) SplitSize(size float64) (sized TransactionEntry, overflow TransactionEntry)
- type AccountStatus
- type AssetPair
- type AssetType
- type CostUnitTranslations
- type DequeueUntilResult
- type ExchangeAccountStatus
- type FIFOTxQueue
- type Flushable
- type MultiAccountTxProcessor
- type Processor
- type SideType
- type TransactionEntry
- type TransactionLog
- func (tx *TransactionLog) Clone() TransactionEntry
- func (tx *TransactionLog) GetAssetPair() AssetPair
- func (tx *TransactionLog) GetAssetSize() float64
- func (tx *TransactionLog) GetCreatedAt() time.Time
- func (tx *TransactionLog) GetExchange() string
- func (tx *TransactionLog) GetFee() float64
- func (tx *TransactionLog) GetID() string
- func (tx *TransactionLog) GetPricePerUnit() float64
- func (tx *TransactionLog) GetSide() SideType
- func (tx *TransactionLog) GetSideIdentifier() string
- func (tx *TransactionLog) GetTotalPrice() float64
- func (tx *TransactionLog) GetTranslatedAssets() []AssetType
- func (tx *TransactionLog) GetTranslatedFee(asset AssetType) float64
- func (tx *TransactionLog) GetTranslatedTotalPrice(asset AssetType) float64
- func (tx *TransactionLog) SplitSize(size float64) (sized TransactionEntry, overflow TransactionEntry)
- type TransactionLogReader
- type TxAssetFIFOQueues
- func (q *TxAssetFIFOQueues) Deq(asset AssetType) TransactionEntry
- func (q *TxAssetFIFOQueues) DequeueAll() []TransactionEntry
- func (q *TxAssetFIFOQueues) DequeueUntil(asset AssetType, accept func(tx TransactionEntry) DequeueUntilResult) ([]TransactionEntry, DequeueUntilResult)
- func (q *TxAssetFIFOQueues) Enq(asset AssetType, n TransactionEntry) *TxAssetFIFOQueues
- func (q *TxAssetFIFOQueues) IsEmpty(asset AssetType) bool
- func (q *TxAssetFIFOQueues) Len(asset AssetType) int
- func (q *TxAssetFIFOQueues) PutBack(asset AssetType, n TransactionEntry) *TxAssetFIFOQueues
- func (q *TxAssetFIFOQueues) Reset() *TxAssetFIFOQueues
- func (q *TxAssetFIFOQueues) TotalLen() int
- type TxBuyGroupLog
- func (txg *TxBuyGroupLog) AddTransactionEntry(tx TransactionEntry) *TxGroupEntry
- func (txg *TxBuyGroupLog) Clone() TransactionEntry
- func (txg *TxBuyGroupLog) GetAssetSize() float64
- func (txg *TxBuyGroupLog) GetFee() float64
- func (txg *TxBuyGroupLog) GetMostProminentSizeTransactionLog() TransactionEntry
- func (txg *TxBuyGroupLog) GetPricePerUnit() float64
- func (txg *TxBuyGroupLog) GetTotalPrice() float64
- func (txg *TxBuyGroupLog) GetTranslatedTotalPrice(asset AssetType) float64
- func (txg *TxBuyGroupLog) IsMultiAsset() bool
- type TxBuySellEntry
- type TxBuySellLog
- type TxEntryProcessor
- type TxFIFOQueue
- func (q *TxFIFOQueue) Deq() TransactionEntry
- func (q *TxFIFOQueue) DequeueUntil(accept func(tx TransactionEntry) DequeueUntilResult) ([]TransactionEntry, DequeueUntilResult)
- func (q *TxFIFOQueue) Enq(n TransactionEntry) FIFOTxQueue
- func (q *TxFIFOQueue) IsEmpty() bool
- func (q *TxFIFOQueue) Len() int
- func (q *TxFIFOQueue) PutBack(n TransactionEntry) FIFOTxQueue
- type TxFlushableEntryProcessor
- type TxGroupEntry
- func (txg *TxGroupEntry) AddTransactionEntry(tx TransactionEntry) *TxGroupEntry
- func (txg *TxGroupEntry) Clone() TransactionEntry
- func (txg *TxGroupEntry) FindBySize(size float64, closest bool) int
- func (txg *TxGroupEntry) GetAssetPair() AssetPair
- func (txg *TxGroupEntry) GetAssetSize() float64
- func (txg *TxGroupEntry) GetCreatedAt() time.Time
- func (txg *TxGroupEntry) GetExchange() string
- func (txg *TxGroupEntry) GetFee() float64
- func (txg *TxGroupEntry) GetMostProminentSizeTransactionLog() TransactionEntry
- func (txg *TxGroupEntry) GetPricePerUnit() float64
- func (txg *TxGroupEntry) GetSide() SideType
- func (txg *TxGroupEntry) GetSideIdentifier() string
- func (txg *TxGroupEntry) GetTotalPrice() float64
- func (txg *TxGroupEntry) GetTransactionEntries() []TransactionEntry
- func (txg *TxGroupEntry) GetTranslatedAssets() []AssetType
- func (txg *TxGroupEntry) GetTranslatedFee(asset AssetType) float64
- func (txg *TxGroupEntry) GetTranslatedTotalPrice(asset AssetType) float64
- func (txg *TxGroupEntry) SplitSize(size float64) (sized TransactionEntry, overflow TransactionEntry)
- type TxGroupProcessor
- type TxLBuyGroupEntry
- type TxLogGroup
- type TxLogProcessor
- type TxOHCHistory
- func (ohc *TxOHCHistory) GetAssetPair() AssetPair
- func (ohc *TxOHCHistory) GetClose() float64
- func (ohc *TxOHCHistory) GetDateTime() time.Time
- func (ohc *TxOHCHistory) GetExchange() string
- func (ohc *TxOHCHistory) GetHigh() float64
- func (ohc *TxOHCHistory) GetID() string
- func (ohc *TxOHCHistory) GetLow() float64
- func (ohc *TxOHCHistory) GetOpen() float64
- func (ohc *TxOHCHistory) GetResolution() int
- func (ohc *TxOHCHistory) GetVolumeAsset() float64
- func (ohc *TxOHCHistory) GetVolumeCostUnit() float64
- type TxOHCHistoryEntry
- type TxOHCReader
Constants ¶
const ( // ExchangeAll represents all exchanges ExchangeAll string = "all" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountEntry ¶
type AccountEntry interface { // Derives from TransactionEntry since it is attached to it. TransactionEntry // GetAccountStatus returns the current value in the account. GetAccountStatus() AccountStatus // EnsureAccountsjust makes sure that all `AssetType`(s) do exist // in account status based on the _prototype_. EnsureAccounts(prototype AccountStatus) AccountEntry }
AccountEntry is a single line in the accounting.
Each entry may contain one or more `AssetType` with it's current value. E.g. _EUR 100, LTC 150.02, BTC 1.00_.
The `TransactionEntry` that was the reason for this account entry (a change in the account) is always included. Hence a set of `TransactionEntry` will have a corresponding `AccountEntry`.
type AccountLog ¶
type AccountLog struct {
// contains filtered or unexported fields
}
func NewAccountLog ¶
func NewAccountLog(tx TransactionEntry) *AccountLog
NewAccountLog creates a new `AccountLog` with `AccountLog.Status` initialied.
func NextAccountLog ¶
func NextAccountLog(previous AccountEntry, tx TransactionEntry) *AccountLog
NextAccountLog creates a new `AccountLog` based on _tx_ but copies all `Status` values into the new one and substract or add to `Status` based on the _tx_.
If _previous_ is `nil`, it will invoke the `NewAccountLog` instead. If the `HasTransaction` returns `false` on _previous_, it will only be used to copy the `AssetPair`(s).
func (*AccountLog) Clone ¶
func (acc *AccountLog) Clone() TransactionEntry
func (*AccountLog) EnsureAccounts ¶
func (acc *AccountLog) EnsureAccounts(prototype AccountStatus) AccountEntry
func (*AccountLog) GetAccountStatus ¶
func (acc *AccountLog) GetAccountStatus() AccountStatus
func (*AccountLog) GetAssetPair ¶
func (acc *AccountLog) GetAssetPair() AssetPair
func (*AccountLog) GetAssetSize ¶
func (acc *AccountLog) GetAssetSize() float64
func (*AccountLog) GetCreatedAt ¶
func (acc *AccountLog) GetCreatedAt() time.Time
func (*AccountLog) GetExchange ¶
func (acc *AccountLog) GetExchange() string
func (*AccountLog) GetFee ¶
func (acc *AccountLog) GetFee() float64
func (*AccountLog) GetID ¶
func (acc *AccountLog) GetID() string
func (*AccountLog) GetPricePerUnit ¶
func (acc *AccountLog) GetPricePerUnit() float64
func (*AccountLog) GetSide ¶
func (acc *AccountLog) GetSide() SideType
func (*AccountLog) GetSideIdentifier ¶
func (acc *AccountLog) GetSideIdentifier() string
func (*AccountLog) GetTotalPrice ¶
func (acc *AccountLog) GetTotalPrice() float64
func (*AccountLog) GetTranslatedAssets ¶
func (acc *AccountLog) GetTranslatedAssets() []AssetType
func (*AccountLog) GetTranslatedFee ¶
func (acc *AccountLog) GetTranslatedFee(asset AssetType) float64
func (*AccountLog) GetTranslatedTotalPrice ¶
func (acc *AccountLog) GetTranslatedTotalPrice(asset AssetType) float64
func (*AccountLog) SplitSize ¶
func (acc *AccountLog) SplitSize( size float64, ) (sized TransactionEntry, overflow TransactionEntry)
type AccountStatus ¶
AccountStatus contains all assets and their current status.
type AssetPair ¶
type AssetPair struct { Asset AssetType `csv:"asset" json:"asset"` CostUnit AssetType `csv:"costunit" json:"costunit"` }
func ParseAssetPair ¶
type AssetType ¶
type AssetType string
AssetType is the name of an asset e.g. EUR, BTC, XLM etc.
const ( AssetTypeUnknown AssetType = "UNK" AssetTypeEuro AssetType = "EUR" AssetTypeSvenskKrona AssetType = "SEK" AssetTypeUsDollar AssetType = "USD" AssetTypeUSDT AssetType = "USDT" AssetTypeBTC AssetType = "BTC" AssetTypeLTC AssetType = "LTC" AssetTypeETH AssetType = "ETH" AssetTypeETC AssetType = "ETC" AssetTypeXRP AssetType = "XRP" AssetTypeCVC AssetType = "CVC" AssetTypeXLM AssetType = "XLM" AssetTypeDASH AssetType = "DASH" AssetTypeLSK AssetType = "LSK" AssetTypeXVG AssetType = "XVG" AssetTypePOWR AssetType = "POWR" AssetTypeBCH AssetType = "BCH" AssetTypeSALT AssetType = "SALT" )
func (AssetType) IsTether ¶
IsTether returns `true` if the _asset_ is a tether (fake crypto _FIAT_) such as _USDT_.
type CostUnitTranslations ¶
type CostUnitTranslations interface { // TranslatedTotalPrice returns zero or positive value // for translated values (if needed) to the specified // `AssetType` for `GetTotalPrice`. // // NOTE: It may need be processed by a cost unit processor // before any valid values may be returned. GetTranslatedTotalPrice(asset AssetType) float64 // TranslatedFee is the same as `TranslatedTotalPrice` // but reflects the `GetFee`. GetTranslatedFee(asset AssetType) float64 // GetTranslatedAssets returns all `AssetType`s that can be used in // `GetTranslatedTotalPrice` and `GetTranslatedFee` GetTranslatedAssets() []AssetType }
type DequeueUntilResult ¶
type DequeueUntilResult int
const ( // DequeueUntilResultContinue denotes that it should continue it dequeue and add the entry to // the dequeue result. DequeueUntilResultContinue DequeueUntilResult = 0 // DequeueUntilResultOverflow specifies that the last entry should be added, but it will overflow // the actual amount. // // This is useful, when partial `common.TransactionEntry` must be used by the client. DequeueUntilResultOverflow DequeueUntilResult = 1 // DequeueUntilResultDone will make the `DequeueUntil` to stop with Success status. It will // add the last dequeue item onto the result. DequeueUntilResultDone DequeueUntilResult = 2 // DequeueUntilResultUnderflow is when not enough entries where captured to satisfy the accept function. DequeueUntilResultUnderflow DequeueUntilResult = 3 )
type ExchangeAccountStatus ¶
type ExchangeAccountStatus map[string]AccountStatus
ExchangeAccountStatus contains the account status for each exchange. The _"all"_, the the complete account status.
type FIFOTxQueue ¶
type FIFOTxQueue interface { Enq(n TransactionEntry) FIFOTxQueue PutBack(n TransactionEntry) FIFOTxQueue Deq() TransactionEntry DequeueUntil( accept func(tx TransactionEntry) DequeueUntilResult, ) ([]TransactionEntry, DequeueUntilResult) IsEmpty() bool Len() int }
type Flushable ¶
type Flushable interface {
Flush() []TransactionEntry
}
type MultiAccountTxProcessor ¶
type MultiAccountTxProcessor interface { Processor Process(tx TransactionEntry) ProcessMany(tx []TransactionEntry) Flush() map[string][]TransactionEntry }
MultiAccountTxProcessor will keep account records for each exchange and a set of global `ExchangeAll` accounts.
type Processor ¶
type Processor interface {
// Reset will clear any state in the processor, i.e. it enter its initialization state.
Reset()
}
type SideType ¶
type SideType string
const ( SideTypeUnknown SideType = "UNKNOWN" SideTypeBuy SideType = "BUY" SideTypeSell SideType = "SELL" SideTypeReceive SideType = "RECEIVE" SideTypeTransfer SideType = "TRANSFER" // SideTypeBuySell is a paired transaction where it will contain // both one or more transaction that represents a _BUY_ that // accumulates to one _SELL_ transaction. // // However, the buy side may contain both `SideTypeBuy` *and* `SideTypeSell`. // The latter is when a _SELL_ transaction resulted in some crypto currency // that later got sold for _FIAT_. SideTypeBuySell SideType = "BUYSELL" )
type TransactionEntry ¶
type TransactionEntry interface { CostUnitTranslations GetID() string GetExchange() string GetSide() SideType GetSideIdentifier() string GetCreatedAt() time.Time GetAssetSize() float64 GetPricePerUnit() float64 GetFee() float64 GetTotalPrice() float64 GetAssetPair() AssetPair Clone() TransactionEntry // SplitSize will split the current `TransactionEntry` by creating one by _size_ and // the other _overflow_ with the rest. All data is recalculated on each side, _split_ and _overflow_ // so adding up both will have the same sums as the current one. SplitSize(size float64) (sized TransactionEntry, overflow TransactionEntry) }
type TransactionLog ¶
type TransactionLog struct { ID string `csv:"id" json:"id"` Exchange string `csv:"exchange" json:"exchange"` Side SideType `csv:"side" json:"side"` SideIdentifier string `csv:"sideid" json:"sideid,omitempty"` CreatedAt time.Time `csv:"created" json:"created"` AssetSize float64 `csv:"size" json:"size"` PricePerUnit float64 `csv:"price" json:"price"` Fee float64 `csv:"fee" json:"fee"` TotalPrice float64 `csv:"total" json:"total"` TranslatedTotalPrice map[string]float64 ` json:"translatedprice"` TranslatedFee map[string]float64 ` json:"translatedfee"` AssetPair }
TransactionLog represents a single transaction
func (*TransactionLog) Clone ¶
func (tx *TransactionLog) Clone() TransactionEntry
func (*TransactionLog) GetAssetPair ¶
func (tx *TransactionLog) GetAssetPair() AssetPair
func (*TransactionLog) GetAssetSize ¶
func (tx *TransactionLog) GetAssetSize() float64
func (*TransactionLog) GetCreatedAt ¶
func (tx *TransactionLog) GetCreatedAt() time.Time
func (*TransactionLog) GetExchange ¶
func (tx *TransactionLog) GetExchange() string
func (*TransactionLog) GetFee ¶
func (tx *TransactionLog) GetFee() float64
func (*TransactionLog) GetID ¶
func (tx *TransactionLog) GetID() string
func (*TransactionLog) GetPricePerUnit ¶
func (tx *TransactionLog) GetPricePerUnit() float64
func (*TransactionLog) GetSide ¶
func (tx *TransactionLog) GetSide() SideType
func (*TransactionLog) GetSideIdentifier ¶
func (tx *TransactionLog) GetSideIdentifier() string
func (*TransactionLog) GetTotalPrice ¶
func (tx *TransactionLog) GetTotalPrice() float64
func (*TransactionLog) GetTranslatedAssets ¶
func (tx *TransactionLog) GetTranslatedAssets() []AssetType
func (*TransactionLog) GetTranslatedFee ¶
func (tx *TransactionLog) GetTranslatedFee(asset AssetType) float64
func (*TransactionLog) GetTranslatedTotalPrice ¶
func (tx *TransactionLog) GetTranslatedTotalPrice(asset AssetType) float64
func (*TransactionLog) SplitSize ¶
func (tx *TransactionLog) SplitSize( size float64, ) (sized TransactionEntry, overflow TransactionEntry)
SplitSize will split the current `TransactionEntry` by creating one by _size_ and the other _overflow_ with the rest. All data is recalculated on each side, _split_ and _overflow_ so adding up both will have the same sums as the current one.
type TransactionLogReader ¶
type TransactionLogReader interface { Unmarshal(data []byte) []TransactionLog SetExchange(name string) TransactionLogReader }
type TxAssetFIFOQueues ¶
type TxAssetFIFOQueues struct {
// contains filtered or unexported fields
}
func NewTxAssetFIFOQueues ¶
func NewTxAssetFIFOQueues() *TxAssetFIFOQueues
func (*TxAssetFIFOQueues) Deq ¶
func (q *TxAssetFIFOQueues) Deq(asset AssetType) TransactionEntry
Deq will dequeue the first pushed `TransactionLog` onto the _asset_ queue.
func (*TxAssetFIFOQueues) DequeueAll ¶
func (q *TxAssetFIFOQueues) DequeueAll() []TransactionEntry
DequeueAll will dequeue assets entries, from the queue
func (*TxAssetFIFOQueues) DequeueUntil ¶
func (q *TxAssetFIFOQueues) DequeueUntil( asset AssetType, accept func(tx TransactionEntry) DequeueUntilResult, ) ([]TransactionEntry, DequeueUntilResult)
func (*TxAssetFIFOQueues) Enq ¶
func (q *TxAssetFIFOQueues) Enq(asset AssetType, n TransactionEntry) *TxAssetFIFOQueues
Enq will enqueue the `TransactionLog` into the _asset_ queue.
func (*TxAssetFIFOQueues) IsEmpty ¶
func (q *TxAssetFIFOQueues) IsEmpty(asset AssetType) bool
func (*TxAssetFIFOQueues) Len ¶
func (q *TxAssetFIFOQueues) Len(asset AssetType) int
func (*TxAssetFIFOQueues) PutBack ¶
func (q *TxAssetFIFOQueues) PutBack(asset AssetType, n TransactionEntry) *TxAssetFIFOQueues
PutBack will enqueue the `TransactionEntry` but make it available on subsequent `Deq` (ordinary it would be last, since last enqueued)
func (*TxAssetFIFOQueues) Reset ¶
func (q *TxAssetFIFOQueues) Reset() *TxAssetFIFOQueues
func (*TxAssetFIFOQueues) TotalLen ¶
func (q *TxAssetFIFOQueues) TotalLen() int
type TxBuyGroupLog ¶
type TxBuyGroupLog struct { TxGroupEntry // contains filtered or unexported fields }
TxBuyGroupLog is exactly the same as `TxGroupEntry` but functions has been overridden to cope with _BUY_ *and* _SELL_ transactions in same group.
This is due to that a sell may include buys that was _really_ a sell from one crypto currency to another, and that _"another"_ is now sold.
func NewTxBuyGroupLog ¶
func NewTxBuyGroupLog(entries []TransactionEntry) *TxBuyGroupLog
func (*TxBuyGroupLog) AddTransactionEntry ¶
func (txg *TxBuyGroupLog) AddTransactionEntry(tx TransactionEntry) *TxGroupEntry
func (*TxBuyGroupLog) Clone ¶
func (txg *TxBuyGroupLog) Clone() TransactionEntry
func (*TxBuyGroupLog) GetAssetSize ¶
func (txg *TxBuyGroupLog) GetAssetSize() float64
GetAssetSize will iterate all entries and sum the asset sizes.
If the direction is BUY it will use `GetAssetSize`, if it is sell it will use `GetTotalPrice` since it is a _BUY_ of a crypto currency that has been sold now (in `TxBuySellLog`).
func (*TxBuyGroupLog) GetFee ¶
func (txg *TxBuyGroupLog) GetFee() float64
GetFee returns the sum of all fees.
Since _SELL_ entries do have fee in incorrect cost unit, it is calculated using `GetFee() / GetPricePerUnit()`.
CAUTION: It does not support multi asset entries!
func (*TxBuyGroupLog) GetMostProminentSizeTransactionLog ¶
func (txg *TxBuyGroupLog) GetMostProminentSizeTransactionLog() TransactionEntry
func (*TxBuyGroupLog) GetPricePerUnit ¶
func (txg *TxBuyGroupLog) GetPricePerUnit() float64
GetPricePerUnit returns the weighetd price per unit for all entires.
Since _SELL_ transactions have incorrect cost unit, it will calculate the price using `GetAssetSize() / (GetTotalPrice() - GetFee())`.
CAUTION: It does not support multi asset entries!
func (*TxBuyGroupLog) GetTotalPrice ¶
func (txg *TxBuyGroupLog) GetTotalPrice() float64
GetTotalPrice calculates the total price.
On _BUY_ it uses the `GetTotalPrice` but on _SELL_, it uses the `GetAssetSize` since that denotes the price.
CAUTION: It does not support multi asset entries!
func (*TxBuyGroupLog) GetTranslatedTotalPrice ¶
func (txg *TxBuyGroupLog) GetTranslatedTotalPrice(asset AssetType) float64
GetTranslatedTotalPrice is overloaded due to that we need to set the sell total price as negative since it is, in this `TxBuyGroup` counted as it where a sort of a _BUY_.
func (*TxBuyGroupLog) IsMultiAsset ¶
func (txg *TxBuyGroupLog) IsMultiAsset() bool
IsMultiAsset checks if all transactions do have the same `AssetType`. If not it will return `false`.
NOTE: When _SELL_ transactions it will check _CostUnit_ instead of _Asset_.
type TxBuySellEntry ¶
type TxBuySellEntry interface { TransactionEntry GetBuy() *TxBuyGroupLog GetSell() TransactionEntry }
type TxBuySellLog ¶
type TxBuySellLog struct { TransactionLog SellTx TransactionEntry BuyTx TxBuyGroupLog }
TxBuySellLog is a _SELL_ that have corresponding _BUYs_
All of the _BUY_ `TransactionEntry` instances are encapsulated in a `TxBuyGroup` where functions are overloaded to handle both _BUY_ and _SELL_ transactions.
It may contain _SELL_ transactions that gained a certain `AssetType` that is now sold. For example _SELL_ 100LT -> 1BTC and then _SELL_ 1BTC -> 20.0000EUR. Thus the former sell is part of the buy array.
Since _SELL_ transaction is quite different, therefore be cautious when e.g. sum up all buy transactions etc. This has been accommodated in the `TxBuyGroupLog` overrides.
func NewTxBuySellLog ¶
func NewTxBuySellLog( sellTx TransactionEntry, buyTx []TransactionEntry, ) *TxBuySellLog
func (*TxBuySellLog) Clone ¶
func (tx *TxBuySellLog) Clone() TransactionEntry
func (*TxBuySellLog) GetBuy ¶
func (tx *TxBuySellLog) GetBuy() *TxBuyGroupLog
func (*TxBuySellLog) GetSell ¶
func (tx *TxBuySellLog) GetSell() TransactionEntry
type TxEntryProcessor ¶
type TxEntryProcessor interface { Processor Process(tx TransactionEntry) ProcessMany(tx []TransactionEntry) }
type TxFIFOQueue ¶
type TxFIFOQueue struct {
// contains filtered or unexported fields
}
func NewTxFIFOQueue ¶
func NewTxFIFOQueue() *TxFIFOQueue
func (*TxFIFOQueue) Deq ¶
func (q *TxFIFOQueue) Deq() TransactionEntry
Deq will dequeue the first pushed `TransactionEntry`.
func (*TxFIFOQueue) DequeueUntil ¶
func (q *TxFIFOQueue) DequeueUntil( accept func(tx TransactionEntry) DequeueUntilResult, ) ([]TransactionEntry, DequeueUntilResult)
func (*TxFIFOQueue) Enq ¶
func (q *TxFIFOQueue) Enq(n TransactionEntry) FIFOTxQueue
Enq will enqueue the `TransactionLog`
func (*TxFIFOQueue) IsEmpty ¶
func (q *TxFIFOQueue) IsEmpty() bool
func (*TxFIFOQueue) Len ¶
func (q *TxFIFOQueue) Len() int
func (*TxFIFOQueue) PutBack ¶
func (q *TxFIFOQueue) PutBack(n TransactionEntry) FIFOTxQueue
PutBack will enqueue the `TransactionEntry` but make it available on subsequent `Deq` (ordinary it would be last, since last enqueued)
type TxFlushableEntryProcessor ¶
type TxFlushableEntryProcessor interface { TxEntryProcessor Flushable }
type TxGroupEntry ¶
type TxGroupEntry struct { // Not used, just derivation TransactionLog Tx []TransactionEntry `json:"logs"` }
func (*TxGroupEntry) AddTransactionEntry ¶
func (txg *TxGroupEntry) AddTransactionEntry(tx TransactionEntry) *TxGroupEntry
func (*TxGroupEntry) Clone ¶
func (txg *TxGroupEntry) Clone() TransactionEntry
func (*TxGroupEntry) FindBySize ¶
func (txg *TxGroupEntry) FindBySize(size float64, closest bool) int
func (*TxGroupEntry) GetAssetPair ¶
func (txg *TxGroupEntry) GetAssetPair() AssetPair
func (*TxGroupEntry) GetAssetSize ¶
func (txg *TxGroupEntry) GetAssetSize() float64
func (*TxGroupEntry) GetCreatedAt ¶
func (txg *TxGroupEntry) GetCreatedAt() time.Time
func (*TxGroupEntry) GetExchange ¶
func (txg *TxGroupEntry) GetExchange() string
func (*TxGroupEntry) GetFee ¶
func (txg *TxGroupEntry) GetFee() float64
func (*TxGroupEntry) GetMostProminentSizeTransactionLog ¶
func (txg *TxGroupEntry) GetMostProminentSizeTransactionLog() TransactionEntry
func (*TxGroupEntry) GetPricePerUnit ¶
func (txg *TxGroupEntry) GetPricePerUnit() float64
func (*TxGroupEntry) GetSide ¶
func (txg *TxGroupEntry) GetSide() SideType
func (*TxGroupEntry) GetSideIdentifier ¶
func (txg *TxGroupEntry) GetSideIdentifier() string
func (*TxGroupEntry) GetTotalPrice ¶
func (txg *TxGroupEntry) GetTotalPrice() float64
func (*TxGroupEntry) GetTransactionEntries ¶
func (txg *TxGroupEntry) GetTransactionEntries() []TransactionEntry
func (*TxGroupEntry) GetTranslatedAssets ¶
func (txg *TxGroupEntry) GetTranslatedAssets() []AssetType
func (*TxGroupEntry) GetTranslatedFee ¶
func (txg *TxGroupEntry) GetTranslatedFee(asset AssetType) float64
func (*TxGroupEntry) GetTranslatedTotalPrice ¶
func (txg *TxGroupEntry) GetTranslatedTotalPrice(asset AssetType) float64
func (*TxGroupEntry) SplitSize ¶
func (txg *TxGroupEntry) SplitSize( size float64, ) (sized TransactionEntry, overflow TransactionEntry)
type TxGroupProcessor ¶
type TxGroupProcessor interface { Processor Process(tx TxGroupEntry) ProcessMany(tx []TxGroupEntry) Flush() []TxGroupEntry }
TxGroupProcessor is same as `TxEntryProcessor` except that it handles `TxGroupEntry` instances instead.
type TxLBuyGroupEntry ¶
type TxLBuyGroupEntry interface { // IsMultiAsset returns `true` if any of the `AssetType`. // // Depending on entry `SideType.Buy` or `SideType.Sell` it will // use the asset or cost unit to determine equality of `AssetType` // amongst the entries. IsMultiAsset() bool }
type TxLogGroup ¶
type TxLogGroup interface { TransactionEntry // GetTransactionEntries returns all underlying `TransactionLog` instances that // is reflected in the `TransactionEntry` interface methods GetTransactionEntries() []TransactionEntry // AddTransactionEntry adds a single entry to the `TransactionLog` array AddTransactionEntry(tx TransactionEntry) *TxGroupEntry // GetMostProminentSizeTransactionLog get the `TransactionLog` of largest `AssetSize` // in the all of the `TransactionLog` instances. GetMostProminentSizeTransactionLog() TransactionEntry }
TxLogGroup is a slice of the `TransactionLog` that have been grouped.
IMPORTANT: The `ID` must be set explicitly on a entry, since it should represent a unique group _ID_.
It is represented as a `TransactionEntry` where all properties are sum of all in the `TransactionLog` slice. The underlying `TransactionLog` instances may be obtained by the `GetTransactionEntries`.
The only value that is not a sum, is the `GetPricePerUnit()`. Instead it is a weighted price where the each `TransactionLog` contributes with its price proportional to it's contributing `AssetSize`.
.Two Logs Contributing with Different Price ==== 1. Asset (1) Size: 0.3, Price: 87.00 EUR 2. Asset (2) Size: 0.6, Price: 90.00 EUR 3. Total Size: 0.9 => 4. Asset 1 Contribution 0,3 / 0.9 = 1/3 5. Asset 2 Contribution 0,6 / 0.9 = 2/3 6 PricePer Unit (1,2) => 87 * 1/3 + 90 * 2/3 = 29 + 60 = 89 7. Verify Cost: 0,3 * 87 + 0,6 * 90 = 80,1 vs 0,9 * 89 = 80,1 i.e. match ====
type TxLogProcessor ¶
type TxLogProcessor interface { Processor // Processes a transaction. Process(tx TransactionLog) // ProcessMany is *exactly* the same as `Process` but it will accept an array of entries instead. // // It is quite possible that the implementation just iterates these and calls `Process` underneath. ProcessMany(tx []TransactionLog) // Flush will make sure so any non committed to account `Transaction` instances is processed // // It will return all current flushed entries (including all earlier). Flush() []TransactionLog }
type TxOHCHistory ¶
type TxOHCHistory struct { ID string `csv:"id" json:"id"` Resolution int `csv:"resolution" json:"resolution"` Exchange string `csv:"exchange" json:"exchange"` DateTime time.Time `csv:"time" json:"time"` Open float64 `csv:"open" json:"open"` High float64 `csv:"high" json:"high"` Low float64 `csv:"low" json:"low"` Close float64 `csv:"close" json:"close"` AssetVolume float64 `csv:"asset volume" json:"assetvolume"` CostUnitVolume float64 `csv:"cost-unit volume" json:"cuvolume"` AssetPair }
func (*TxOHCHistory) GetAssetPair ¶
func (ohc *TxOHCHistory) GetAssetPair() AssetPair
func (*TxOHCHistory) GetClose ¶
func (ohc *TxOHCHistory) GetClose() float64
func (*TxOHCHistory) GetDateTime ¶
func (ohc *TxOHCHistory) GetDateTime() time.Time
func (*TxOHCHistory) GetExchange ¶
func (ohc *TxOHCHistory) GetExchange() string
func (*TxOHCHistory) GetHigh ¶
func (ohc *TxOHCHistory) GetHigh() float64
func (*TxOHCHistory) GetID ¶
func (ohc *TxOHCHistory) GetID() string
func (*TxOHCHistory) GetLow ¶
func (ohc *TxOHCHistory) GetLow() float64
func (*TxOHCHistory) GetOpen ¶
func (ohc *TxOHCHistory) GetOpen() float64
func (*TxOHCHistory) GetResolution ¶
func (ohc *TxOHCHistory) GetResolution() int
func (*TxOHCHistory) GetVolumeAsset ¶
func (ohc *TxOHCHistory) GetVolumeAsset() float64
func (*TxOHCHistory) GetVolumeCostUnit ¶
func (ohc *TxOHCHistory) GetVolumeCostUnit() float64
type TxOHCHistoryEntry ¶
type TxOHCHistoryEntry interface { GetID() string // GetResolution returns the number of minutes for entry // // 1, 5, 15, 30, 60 (1h), 240 (4h), 1440 (1D), 10080 (1W) GetResolution() int GetExchange() string GetDateTime() time.Time GetOpen() float64 GetHigh() float64 GetLow() float64 GetClose() float64 GetVolumeAsset() float64 GetVolumeCostUnit() float64 GetAssetPair() AssetPair }
TxOHCHistoryEntry represents a single historic transaction entry for a single exchange.
If not bound to a exchage, the `ExchangeAll` is used.
type TxOHCReader ¶
type TxOHCReader interface { Read(pair AssetPair, since time.Time, interval time.Duration) []TxOHCHistory // SetExchangeName alters the default name. SetExchangeName(name string) }
TxOHCReader reads from it's datasource and returns the result.