@@ -45,6 +45,7 @@ func NewTimeStamp(timeframe TimeFrame, capacity int) TimeStamp {
45
45
func (t * TimeStamp ) Timeframe () TimeFrame {
46
46
return t .timeframe
47
47
}
48
+
48
49
// At returns the time at the specified index within the TimeStamp.
49
50
func (t TimeStamp ) At (index int ) time.Time {
50
51
return t .Timestamp [index ]
@@ -109,6 +110,7 @@ func NewCandle(open, high, low, c, volume float64, timeClose time.Time) *Candle
109
110
TimeClose : timeClose ,
110
111
}
111
112
}
113
+
112
114
// InstrumentCandle represents a candlestick data point with an associated financial instrument.
113
115
// It combines the detailed candlestick information such as OHLCV with the specific instrument
114
116
// for which this data is relevant. This data structure is commonly used in trading strategies
@@ -187,6 +189,7 @@ func (c *Chart) Slice(period Period) Chart {
187
189
Timestamp : c .Timestamp .Slice (start , stop ),
188
190
}
189
191
}
192
+
190
193
// Len returns the number of timestamps (and hence the number of candles) in the Chart.
191
194
func (c * Chart ) Len () int {
192
195
return len (c .Timestamp .Timestamp )
@@ -195,10 +198,13 @@ func (c *Chart) Len() int {
195
198
// CandleByIndex retrieves the candle at the specified index from the Chart.
196
199
// If the index is out of range, an error is returned.
197
200
// Parameters:
198
- // index - The index of the candle to retrieve.
201
+ //
202
+ // index - The index of the candle to retrieve.
203
+ //
199
204
// Returns:
200
- // pointer to a Candle and nil error if successful, or
201
- // nil pointer and an OutOfIndexError if the index is invalid.
205
+ //
206
+ // pointer to a Candle and nil error if successful, or
207
+ // nil pointer and an OutOfIndexError if the index is invalid.
202
208
func (c * Chart ) CandleByIndex (index int ) (* Candle , error ) {
203
209
if index >= c .Len () {
204
210
return nil , errors .NewOutOfIndexError (index )
@@ -213,6 +219,7 @@ func (c *Chart) CandleByIndex(index int) (*Candle, error) {
213
219
c .Timestamp .At (index ),
214
220
), nil
215
221
}
222
+
216
223
// ChartContainer represents a collection of instruments and their corresponding charts.
217
224
// It can be used to inform your trading system about your investment universe during testing and training.
218
225
type ChartContainer map [Instrument ]Chart
0 commit comments