thesis_forecasting_website / loaders /indicator_loader.go
tebakaja's picture
deployment
37f31d4
raw
history blame
621 Bytes
package loaders
import (
"os"
"encoding/json"
)
type Indicator struct {
Date string `json:"date"`
FullDate string `json:"full_date"`
MFI float64 `json:"MFI"`
RSI float64 `json:"RSI"`
MACD float64 `json:"MACD"`
}
type IndicatorsWrapper struct {
Indicators []Indicator `json:"indicators"`
}
func IndicatorLoader(path string) ([]Indicator, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var data IndicatorsWrapper
if err := json.Unmarshal(file, &data); err != nil {
return nil, err
}
return data.Indicators, nil
}