A zoomable candlestick chart.
Copyright © 2015-16, Anil Nair - MIT License
| $ python xor.py | |
| Training: | |
| Epoch 0 MSE: 1.765 | |
| Epoch 100 MSE: 0.015 | |
| Epoch 200 MSE: 0.005 | |
| * Target MSE reached * | |
| Evaluating: | |
| 1 XOR 0 = 1 ( 0.904) Error: 0.096 | |
| 0 XOR 1 = 1 ( 0.908) Error: 0.092 | |
| 1 XOR 1 = 0 (-0.008) Error: 0.008 |
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |
A zoomable candlestick chart.
Copyright © 2015-16, Anil Nair - MIT License
| import pandas as pd | |
| import numpy as np | |
| import instrumentdb as idb | |
| import math | |
| import pickle | |
| def good_entries(ohlcv, min_days = 3, days_out = 15, vola_len = 35, days_pos = 0.6, stop_loss = 1.5): | |
| if days_out <= min_days: | |
| raise RuntimeError('days_out must be greater than min_days.') |
| function NiceScale (lowerBound, upperBound, _maxTicks) { | |
| var maxTicks = _maxTicks || 10; | |
| var tickSpacing; | |
| var range; | |
| var niceLowerBound; | |
| var niceUpperBound; | |
| calculate(); |
| #!/bin/sh | |
| if [ "$PYENV_VERSION" -ne "" ] | |
| then | |
| name=`pyenv version-name` | |
| python=`pyenv which python` | |
| else | |
| name=`basename "$VIRTUAL_ENV"` | |
| python="$VIRTUALENV/bin/python" | |
| fi |
| """ | |
| A bare bones examples of optimizing a black-box function (f) using | |
| Natural Evolution Strategies (NES), where the parameter distribution is a | |
| gaussian of fixed standard deviation. | |
| """ | |
| import numpy as np | |
| np.random.seed(0) | |
| # the function we want to optimize |
| /* colors: | |
| * #ABB2BF default syntax (foreground) | |
| * #828997 medium syntax | |
| * #5C6370 darkest syntax | |
| * #56B6C2 cyan | |
| * #61AFEF blue | |
| * #C678DD purple | |
| * #98C379 green | |
| * #E06C75 light red | |
| * #BE5046 red |
| function slugify(string) { | |
| const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;' | |
| const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------' | |
| const p = new RegExp(a.split('').join('|'), 'g') | |
| return string.toString().toLowerCase() | |
| .replace(/\s+/g, '-') // Replace spaces with - | |
| .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters | |
| .replace(/&/g, '-and-') // Replace & with 'and' | |
| .replace(/[^\w\-]+/g, '') // Remove all non-word characters |
| Title | Description