Documentation
¶
Index ¶
- Variables
- type Candlestick
- type List
- func (l List) Extract(start, end time.Time, limit uint) *List
- func (l *List) FillMissing(start, end time.Time, filling Candlestick) error
- func (l List) First() (Candlestick, bool)
- func (l List) GetMissingRange(start, end time.Time, limit uint) []timeseries.TimeRange
- func (l List) GetMissingTimes(start, end time.Time, limit uint) []time.Time
- func (l List) GetUncompleteRange() []timeseries.TimeRange
- func (l List) GetUncompleteTimes() []time.Time
- func (l List) Last() (Candlestick, bool)
- func (l *List) Loop(f func(Candlestick) (bool, error)) error
- func (l *List) Merge(l2 *List, options *timeseries.MergeOptions) error
- func (l *List) MustSet(c Candlestick) *List
- func (l *List) ReplaceUncomplete(l2 *List)
- func (l *List) Set(c Candlestick) error
- func (l List) String() string
- func (l List) ToArray() []Candlestick
- type ListMetadata
- type PriceType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPeriodMismatch is returned when the period of the candlestick does not // match the period of the list. ErrPeriodMismatch = errors.New("period-mismatch") // ErrCandlestickType is returned when the struct is not a candlestick. ErrCandlestickType = errors.New("struct-not-candlestick") // ErrExchangeMismatch is returned when the exchange of the list does not // match the exchange of the list to merge. ErrExchangeMismatch = errors.New("exchange-mismatch") // ErrPairMismatch is returned when the pair of the list does not match the // pair of the list to merge. ErrPairMismatch = errors.New("pair-mismatch") )
var ( // ErrInvalidPriceType is returned when the price type is invalid. ErrInvalidPriceType = errors.New("invalid-price-type") )
var PriceTypes = []PriceType{ PriceTypeIsOpen, PriceTypeIsHigh, PriceTypeIsLow, PriceTypeIsClose, }
PriceTypes is the list of all available price types.
Functions ¶
This section is empty.
Types ¶
type Candlestick ¶
type Candlestick struct {
Time time.Time `bson:"time" json:"time,omitempty"`
Open float64 `bson:"open" json:"open,omitempty"`
High float64 `bson:"high" json:"high,omitempty"`
Low float64 `bson:"low" json:"low,omitempty"`
Close float64 `bson:"close" json:"close,omitempty"`
Volume float64 `bson:"volume" json:"volume,omitempty"`
Uncomplete bool `bson:"uncomplete" json:"uncomplete,omitempty"`
}
Candlestick is a candlestick with the time, open, high, low, close and volume. Uncomplete is true if the candlestick is not closed yet or have not been updated since it was closed.
func MergeListIntoOneCandlestick ¶
MergeListIntoOneCandlestick will merge all the candlesticks of the list into one candlestick. The time of the candlestick will be the first time of the list, rounded to the period. The high will be the highest high, the low the lowest low, the volume the sum of all volumes and the close the close of the last candlestick.
func (Candlestick) Equal ¶
func (cs Candlestick) Equal(b Candlestick) bool
Equal checks equality between the candlesticks.
func (Candlestick) Price ¶
func (cs Candlestick) Price(p PriceType) float64
Price is the price of the candlestick depending on the price type.
func (Candlestick) String ¶
func (cs Candlestick) String() string
String is a string representation of the candlestick.
type List ¶
type List struct {
Metadata ListMetadata
Data timeseries.TimeSerie[Candlestick]
}
List is a list of candlesticks with some metadata.
func NewListWithMetadata ¶
func NewListWithMetadata(md ListMetadata) *List
NewListWithMetadata creates a new list of candlesticks with the same metadata as the given list.
func (List) Extract ¶
Extract will extract a new list from the current list with the given time range and limit.
func (*List) FillMissing ¶
func (l *List) FillMissing(start, end time.Time, filling Candlestick) error
FillMissing will add the 'filling' candlestick at each interval between 'start' included and 'end' included when there is a missing candlestick at the tested interval.
func (List) First ¶
func (l List) First() (Candlestick, bool)
First will return the first candlestick of the list.
func (List) GetMissingRange ¶
GetMissingRange returns an array of missing time range in the candlestick list.
func (List) GetMissingTimes ¶
GetMissingTimes returns an array of missing time in the candlestick list.
func (List) GetUncompleteRange ¶
func (l List) GetUncompleteRange() []timeseries.TimeRange
GetUncompleteRange returns an array of time range from candlesticks that are marked as uncomplete (i.e. data pulled when candlestick covering time was not complete).
func (List) GetUncompleteTimes ¶
GetUncompleteTimes returns an array of time from candlesticks that are marked as uncomplete (i.e. data pulled when candlestick covering time was not complete).
func (List) Last ¶
func (l List) Last() (Candlestick, bool)
Last will return the last candlestick of the list.
func (*List) Loop ¶
func (l *List) Loop(f func(Candlestick) (bool, error)) error
Loop will loop over the candlesticks of the list and call the given function for each candlestick. If the function returns true, the loop will stop.
func (*List) Merge ¶
func (l *List) Merge(l2 *List, options *timeseries.MergeOptions) error
Merge will merge the given list into the current list.
func (*List) MustSet ¶
func (l *List) MustSet(c Candlestick) *List
MustSet will set the candlestick in the list and panic if there is an error.
func (*List) ReplaceUncomplete ¶
ReplaceUncomplete will replace the uncomplete candlesticks of the current list with the candlesticks of the given list.
func (*List) Set ¶
func (l *List) Set(c Candlestick) error
Set will set the candlestick in the list.
func (List) ToArray ¶
func (l List) ToArray() []Candlestick
ToArray returns an array of candlesticks from the list.
type ListMetadata ¶
ListMetadata is the metadata of a list of candlesticks.
type PriceType ¶
type PriceType string
PriceType is the type of price to use.
const ( // PriceTypeIsOpen is the open price. PriceTypeIsOpen PriceType = "open" // PriceTypeIsHigh is the high price. PriceTypeIsHigh PriceType = "high" // PriceTypeIsLow is the low price. PriceTypeIsLow PriceType = "low" // PriceTypeIsClose is the close price. PriceTypeIsClose PriceType = "close" )