本文整理汇总了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')
示例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
示例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))