Example #1
0
func GetWindowTrader(id int, trainer philoctetes.TrainerInt, curr string, collector charont.Int, unitsToUse, samplesToConsiderer, maxSecToWait int) (wt *windowTrader) {
	wt = &windowTrader{
		collector:           collector,
		trainer:             trainer,
		realOps:             false,
		curr:                curr,
		unitsToUse:          unitsToUse,
		samplesToConsiderer: samplesToConsiderer,
		maxSecToWait:        maxSecToWait,
		id:                  id,
		mutex:               new(sync.Mutex),
	}

	collector.AddListerner(curr, wt.NewPrices)

	return
}
Example #2
0
func GetHades(trainer philoctetes.TrainerInt, traders int, from int, collector charont.Int, unitsToUse, samplesToConsiderer, lastOpsToConsider, tradesThatCanPlay, maxSecsToWait int) (hades *Hades) {
	hades = &Hades{
		traders:           make([]hermes.Int, philoctetes.TrainersToRun*len(collector.GetCurrencies())),
		collector:         collector,
		tradesThatCanPlay: tradesThatCanPlay,
		lastOpsToConsider: lastOpsToConsider,
		tradersPlaying:    make(map[int]hermes.Int),
	}

	for i, curr := range collector.GetCurrencies() {
		for t := 0; t < philoctetes.TrainersToRun; t++ {
			log.Debug("Launching trader:", curr, "Id:", t, "TotalToLaunch:", len(hades.traders), i*t)
			hades.traders[i*philoctetes.TrainersToRun+t] = hermes.GetWindowTrader(t, trainer, curr, collector, unitsToUse, samplesToConsiderer, maxSecsToWait)
		}
	}

	go collector.Run()
	go hades.manageTraders()

	return
}