Пример #1
0
func RunStrategy(w http.ResponseWriter, r *http.Request) {

	fastAvg := 241
	slowAvg := 316
	firstAllowedBuyDate := time.Date(2010, time.January, 1, 0, 0, 0, 0, time.UTC)
	unitPrices := metric.ReadMetricFromYahooCsv("sampledata/ivv_history.csv")

	outcome := strategy.RunMovingAverageCrossover(fastAvg, slowAvg, firstAllowedBuyDate, unitPrices)

	if err := json.NewEncoder(w).Encode(outcome); err != nil {
		panic(err)
	}
}
Пример #2
0
func RunMovingAverage(firstAllowedBuyDate time.Time, datafile string) *[]strategy.StrategyOutcomes {

	outComes := make([]strategy.StrategyOutcomes, 0)

	unitPrices := metric.ReadMetricFromYahooCsv(datafile)

	for firstAvg := 1; firstAvg < 400; firstAvg += 5 {

		for secondAvg := firstAvg + 5; secondAvg < 400; secondAvg += 5 {

			so := strategy.RunMovingAverageCrossover(firstAvg, secondAvg, firstAllowedBuyDate, unitPrices)
			outComes = append(outComes, *so)
		}

	}

	//fmt.Println()
	//for _, so := range (outComes) {
	//	fmt.Printf("Final value: %v, NumTrades, %v, Settings: %v\n", so.FinalValue, len(so.Positions), so.Settings)
	//}

	return &outComes
}