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


Python History.norm方法代码示例

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


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

示例1: examine

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import norm [as 别名]
def examine(lines, pic_kind):
    resolve = [-36, -5, 97, 44, -24]
    length, same, deltaes,days,opens,actuals,expecteds = 0, 0, [],[],[],[],[]
    for line in lines:
        record = History.get_from_historyline(line)
	record = History.norm(record)
	expected = get_expected(resolve, record)
	actual = record.closed_today 
	delta = expected - actual
	deltaes.append(delta)
	days.append(record.day)
	opens.append(record.open_price)
	actuals.append(actual)
	expecteds.append(expected)
	print 'open: %s,actual: %s, expected: %s, delta: %s' % (record.open_price, actual, expected, delta)

	if (expected - record.open_price) * (actual - record.open_price) > 0:
	    same += 1
	length += 1
    print 'direction_same: %d, length: %d, direction_same/length: %s' % (same, length, float(same)/length)
    x = [ i + 1 for i in range(len(opens))]
    if pic_kind == 'delta':
        pydrawer.draw(x, deltaes, 'bo')
    if pic_kind == 'lines':
        pydrawer.draw(x, opens,'k', x, actuals,'r-', x, expecteds,'bo')
开发者ID:wdggat,项目名称:agau,代码行数:27,代码来源:ag_history_price_predict.py

示例2: anneal_reducer

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import norm [as 别名]
def anneal_reducer(lines):
    # 开盘价, 昨结算, 最高价, 最低价
    domain = [(-100, 100), (-100, 100), (-100, 100), (-100, 100), (-2000, 2000)]
    records = set()
    for line in lines:
        history_record = History.get_from_historyline(line)
	history_record = History.norm(history_record)
	records.add(history_record)

    while(True):
        best_cost, best_resolve = optimizations.annealing(domain, get_best_solution(records))
	ave_cost = best_cost / len(records)
	if ave_cost < 3000:
            print 'best_cost: %s, best_resolve: %s, best_ave_cost: %f' % (best_cost, best_resolve, ave_cost)
	    if ave_cost < 1000:
	        break
开发者ID:wdggat,项目名称:agau,代码行数:18,代码来源:ag_history_price_predict.py

示例3: random_reducer

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import norm [as 别名]
def random_reducer(lines):
    # 开盘价, 昨结算, 最高价, 最低价, 加权平均价, 成交量(千克)持仓量 
#    domain = [(-100, 100), (-100, 100), (-100, 100), (-100, 100), (-100, 100), (-100, 100), (-100, 100), (-2000, 2000)]
    domain = [(-100, 100), (-100, 100), (-100, 100), (-100, 100), (-2000, 2000)]
    records = set()
    for line in lines:
        history_record = History.get_from_historyline(line)
	history_record = History.norm(history_record)
	records.add(history_record)

    best_cost,best_resolve = sys.maxint, None
    for i in range(20):
        cost, resolve = optimizations.randomoptimize(domain, get_best_solution(records))
#        cost, resolve = optimizations.hill_climb(domain, get_best_solution(records))
        print 'i: %s, cost: %s, resolve: %s, ave_cost: %f' % (i, cost, resolve, cost / len(records))
	if cost < best_cost:
	    best_cost = cost 
	    best_resolve = resolve
	# goal: daily_cost <= sqrt(100)
	if best_cost <= len(records) * 100:
	    break
    print 'best_cost: %s, best_resolve: %s, best_ave_cost: %f' % (best_cost, best_resolve, best_cost / len(records))
开发者ID:wdggat,项目名称:agau,代码行数:24,代码来源:ag_history_price_predict.py


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