func (csvFPSP *CSVDOHLCVRecordParser) ParseRecord(csvRecord []string,
	dateColumnIndex int,
	openPriceColumnIndex int,
	highPriceColumnIndex int,
	lowPriceColumnIndex int,
	closePriceColumnIndex int,
	volumeColumnIndex int,
	dateParser TextDateParser) (dholcv gotrade.DOHLCV, err error) {

	// parse the record based on the supplied indexes and date func
	recordLength := len(csvRecord)

	// date
	var date time.Time
	if dateColumnIndex != -1 && recordLength > dateColumnIndex {

		date, err = dateParser(csvRecord[dateColumnIndex])
	}

	// open
	var open float64
	if openPriceColumnIndex != -1 && recordLength > openPriceColumnIndex {
		open, err = strconv.ParseFloat(csvRecord[openPriceColumnIndex], 64)
	}

	// high
	var high float64
	if recordLength > highPriceColumnIndex {
		high, err = strconv.ParseFloat(csvRecord[highPriceColumnIndex], 64)
	}

	// low
	var low float64
	if recordLength > lowPriceColumnIndex {
		low, err = strconv.ParseFloat(csvRecord[lowPriceColumnIndex], 64)
	}

	// close
	var close float64
	if recordLength > closePriceColumnIndex {
		close, err = strconv.ParseFloat(csvRecord[closePriceColumnIndex], 64)
	}

	// volume
	var volume float64
	if recordLength > volumeColumnIndex {
		volume, err = strconv.ParseFloat(csvRecord[volumeColumnIndex], 64)
	}

	dohlcv := gotrade.NewDOHLCVDataItem(date, open, high, low, close, volume)

	return dohlcv, err
}
	"github.com/thetruetrade/gotrade"
	"github.com/thetruetrade/gotrade/feeds"
	"github.com/thetruetrade/gotrade/indicators"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
	"testing"
	"time"
)

var (
	csvFeed          *feeds.CSVFileFeed
	sourceData       []float64        = []float64{5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0}
	sourceDOHLCVData []gotrade.DOHLCV = []gotrade.DOHLCV{gotrade.NewDOHLCVDataItem(time.Now(), 0.0, 0.0, 0.0, 5.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 7.0, 8.0, 5.0, 6.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 8.0, 9.0, 6.0, 7.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 9.0, 10.0, 7.0, 8.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 10.0, 11.0, 8.0, 9.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 11.0, 12.0, 9.0, 10.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 12.0, 13.0, 10.0, 11.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 13.0, 14.0, 11.0, 12.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 14.0, 15.0, 12.0, 13.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 15.0, 16.0, 13.0, 14.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 16.0, 17.0, 14.0, 15.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 17.0, 18.0, 15.0, 16.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 18.0, 19.0, 16.0, 17.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 19.0, 20.0, 17.0, 18.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 20.0, 21.0, 18.0, 19.0, 0.0),
		gotrade.NewDOHLCVDataItem(time.Now(), 21.0, 22.0, 19.0, 20.0, 0.0),