package types var LossEmoji = "🔥" var ProfitEmoji = "💰" type Interval string func (i Interval) Minutes() (int64, bool) { m, ok := SupportedIntervals[i] if !ok || m <= 0 { return m, false } return m / 60, true } func (i Interval) Seconds() (int64, bool) { m, ok := SupportedIntervals[i] if !ok || m <= 0 { return m, false } return m, true } func (i Interval) Milliseconds() (int64, bool) { m, ok := SupportedIntervals[i] if !ok || m <= 0 { return m, false } return m * 1000, true } var ( Interval1s = Interval("1s") Interval1m = Interval("1m") Interval3m = Interval("3m") Interval5m = Interval("5m") Interval15m = Interval("15m") Interval30m = Interval("30m") Interval1h = Interval("1h") Interval2h = Interval("2h") Interval4h = Interval("4h") Interval6h = Interval("6h") Interval12h = Interval("12h") Interval1d = Interval("1d") Interval2d = Interval("2d") Interval3d = Interval("3d") Interval5d = Interval("5d") Interval1w = Interval("1w") Interval1mo = Interval("1mo") Interval3mo = Interval("3mo") ) // IntervalWindow is used by the indicators type IntervalWindow struct { // The interval of kline Interval Interval `json:"interval"` // The windows size of the indicator (for example, EWMA and SMA) Window int `json:"window"` // RightWindow is used by the pivot indicator RightWindow *int `json:"rightWindow"` } type IntervalMap map[Interval]int64 var SupportedIntervals = IntervalMap{ Interval1s: 1, Interval1m: 1 * 60, Interval3m: 3 * 60, Interval5m: 5 * 60, Interval15m: 15 * 60, Interval30m: 30 * 60, Interval1h: 60 * 60, Interval2h: 60 * 60 * 2, Interval4h: 60 * 60 * 4, Interval6h: 60 * 60 * 6, Interval12h: 60 * 60 * 12, Interval1d: 60 * 60 * 24, Interval2d: 60 * 60 * 24 * 2, Interval3d: 60 * 60 * 24 * 3, Interval5d: 60 * 60 * 24 * 5, Interval1w: 60 * 60 * 24 * 7, // Interval1mo: 60 * 60 * 24 * 30, // Interval3mo: 60 * 60 * 24 * 30 * 3, }