当前位置: 首页>>代码示例>>Python>>正文


Python Pool.showStrategies方法代码示例

本文整理汇总了Python中pool.Pool.showStrategies方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.showStrategies方法的具体用法?Python Pool.showStrategies怎么用?Python Pool.showStrategies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pool.Pool的用法示例。


在下文中一共展示了Pool.showStrategies方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: runStrategy

# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import showStrategies [as 别名]
def runStrategy(in_prices):
	global prices, mas, emas, smas, lwmas, vmas, vemas, vsmas, vlwmas
	log.debug('beginning vma strategy ...')
	prices = in_prices
	
	vols = [p['vol'] for p in prices]
	
	vmalength = const.VMA_MAX + 1
	vmas = [0] * vmalength
	vemas = [0] * vmalength
	vsmas = [0] * vmalength
	vlwmas = [0] * vmalength
	for period in range(1, vmalength):
		vmas[period] = ma.calc_ma(vols, period)
		vemas[period] = ma.calc_ema(vols, period)
		vsmas[period] = ma.calc_sma(vols, period)
		vlwmas[period] = ma.calc_lwma(vols, period)
		
	ps = [p['close'] for p in prices]
	
	malength = const.MA_MAX + 1
	mas = [0] * malength
	emas = [0] * malength
	smas = [0] * malength
	lwmas = [0] * malength
	for period in range(1, malength):
		mas[period] = ma.calc_ma(ps, period)
		emas[period] = ma.calc_ema(ps, period)
		smas[period] = ma.calc_sma(ps, period)
		lwmas[period] = ma.calc_lwma(ps, period)
	
	log.debug('running ma strategy ...')
	starttime = datetime.datetime.now()
	
	pool = Pool(const.POOL_SIZE)
	
	for vft, vf in [(matype, period) for matype in const.VMA_TYPES for period in const.VMA_FAST]:
		for vst, vs in [(matype, period) for matype in const.VMA_TYPES for period in const.VMA_SLOW]:
			if vs != 0 and vs <= vf: continue
			poola = Pool(const.POOL_SIZE)
			poolb = Pool(const.POOL_SIZE)
			
			for ft, f in [(matype, period) for matype in const.MA_TYPES for period in const.MA_FAST]:
				for s1t, s1 in [(matype, period) for matype in const.MA_TYPES for period in const.MA_SLOW1]:
					if s1 != 0 and s1 <= f: continue
					elapsed = (datetime.datetime.now() - starttime).seconds
					log.debug('== ' + str(elapsed) + ',' + vft + '_' + str(vf) + ',' + vst + '_' + str(vs) + ',' + ft + '_' + str(f) + ',' + s1t + '_' + str(s1) + ' ==')
					
					doTrade(poola, vft, vf, vst, vs, ft, f, s1t, s1, '', 0, '', 0)
					doTrade(poolb, vft, vf, vst, vs, '', 0, '', 0, ft, f, s1t, s1)
			
			for ia in range(len(poola.strategies)):
				for ib in range(len(poolb.strategies)):
					sa = poola.strategies[ia]
					sb = poolb.strategies[ib]
					if sa[0] == 0 or sb[0] == 0: continue
					t = doTrade(pool, vft, vf, vst, vs, sa[0].args[0], sa[0].args[1], sa[0].args[2], sa[0].args[3], sb[0].args[4], sb[0].args[5], sb[0].args[6], sb[0].args[7])
				
	pool.showStrategies()
	return pool.strategies[0][0]
开发者ID:ongbe,项目名称:pymisc,代码行数:62,代码来源:vmaStrategy.py

示例2: runStrategy

# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import showStrategies [as 别名]
def runStrategy(in_prices):
	global mas, emas, smas, lwmas, std, prices
	log.debug('beginning ma strategy ...')
	
	prices = in_prices
	ps = [p['close'] for p in prices]
	
	std = [0] * 51
	l = len(prices)
	for period in range(2, 51):
		std[period] = [0] * l
		for i in range(period - 1, l):
			std[period][i] = np.std(ps[i-period+1 : i+1], dtype=np.float64, ddof=0)
	
	malength = const.MA_MAX + 1
	mas = [0] * malength
	emas = [0] * malength
	smas = [0] * malength
	lwmas = [0] * malength
	for period in range(1, malength):
		mas[period] = ma.calc_ma(ps, period)
		emas[period] = ma.calc_ema(ps, period)
		smas[period] = ma.calc_sma(ps, period)
		lwmas[period] = ma.calc_lwma(ps, period)
	
	log.debug('running ma strategy ...')
	starttime = datetime.datetime.now()
	
	matypes = ['MA', 'EMA', 'SMA', 'LWMA']
	
	pool = Pool(const.POOL_SIZE)
	for ft, f in [(matype, period) for matype in matypes for period in const.MA_FAST]:
		for s1t, s1 in [(matype, period) for matype in matypes for period in const.MA_SLOW1]:
			if s1 != 0 and s1 <= f: continue
			elapsed = (datetime.datetime.now() - starttime).seconds
			log.debug('== ' + str(elapsed) + ',' + ft + '_' + str(f) + ',' + s1t + '_' + str(s1) + ' ==')
			for s2t, s2 in [(matype, period) for matype in matypes for period in const.MA_SLOW2]:
				if s2 != 0 and s2 <= s1: continue
				#run 
				doTrade(pool, ft, f, s1t, s1, s2t, s2)
				
	pool.showStrategies()
	return pool.strategies[0][0]
开发者ID:ongbe,项目名称:pymisc,代码行数:45,代码来源:maStrategy.py

示例3: runStrategy

# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import showStrategies [as 别名]
def runStrategy(in_prices):
	global prices, ps
	log.debug('beginning pattern strategy ...')
	
	prices = in_prices
	ps = [p['close'] for p in prices]
	
	starttime = datetime.datetime.now()
	
	pool = Pool(const.POOL_SIZE)
	
	for i in range(20, 81)[::5]:
		for j in range(1, 6)[::1]:
			if i < j: continue
			for f in range(5, 16)[::2]:
				elapsed = (datetime.datetime.now() - starttime).seconds
				log.debug('== ' + str(elapsed) + ', ' + str(i) + ',' + str(j) + ',' + str(f) + ' ==')
				for sl in range(15, 31)[::3]:
					for si in range(3, 16)[::2]:
						doTrade(pool, i, j, f, sl, si)
		
	pool.showStrategies()
	return pool.strategies[0][0]
开发者ID:ongbe,项目名称:pymisc,代码行数:25,代码来源:patternStrategy.py

示例4: Pool

# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import showStrategies [as 别名]
	#finalPool.estimate(tr)
	#q.put(tr)

if __name__ == "__main__":
	rwlogging.clearLog()
	
	if const.SOURCE_TYPE < 3:
		prices = dataloader.importData(const.SOURCE_TYPE, const.DATA_FILE)
		strategy.runStrategy(prices)
	
	if const.SOURCE_TYPE == 3:
		stocks = dataloader.importStockList(const.LIST_FILE)
		for stock in stocks:
			dataloader.downloadStockData(stock)
	
	if const.SOURCE_TYPE == 4:
		stocks = dataloader.importStockList(const.LIST_FILE)
		finalPool = Pool(100)
		with concurrent.futures.ProcessPoolExecutor(max_workers=const.MAX_PROCESS_NUM) as executor:
			trs = executor.map(processStrategy, stocks)
			for tr in trs:
				try:
					if tr: finalPool.estimate(tr)
				except:
					pass
		
		const.currentSecId = 'FINAL'
		finalPool.showStrategies()
		
	
开发者ID:ongbe,项目名称:pymisc,代码行数:30,代码来源:main.py


注:本文中的pool.Pool.showStrategies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。