From e06ec7645094823b7fb1fe46ff28ddc2b803e8d1 Mon Sep 17 00:00:00 2001 From: Vitalik Buterin Date: Sun, 9 Nov 2014 13:18:48 -0500 Subject: [PATCH] Added estimators --- stability/diff_and_price.csv | 1563 ++++++++++++++++++++++++++++++++++ stability/fit.py | 122 +++ stability/spread.py | 460 ++++++++++ 3 files changed, 2145 insertions(+) create mode 100644 stability/diff_and_price.csv create mode 100644 stability/fit.py create mode 100644 stability/spread.py diff --git a/stability/diff_and_price.csv b/stability/diff_and_price.csv new file mode 100644 index 0000000..f3c00bc --- /dev/null +++ b/stability/diff_and_price.csv @@ -0,0 +1,1563 @@ +2014-11-01,337.99,35985641472.0 +2014-10-31,346.14,35985641472.0 +2014-10-30,336.37,35985641472.0 +2014-10-29,355.71,35985641472.0 +2014-10-28,351.03,35985641472.0 +2014-10-27,355.19,35985641472.0 +2014-10-26,348.69,35985641472.0 +2014-10-25,358.78,35985641472.0 +2014-10-24,356.81,35985641472.0 +2014-10-23,382.05,35640559249.8 +2014-10-22,385.79,35002482688.0 +2014-10-21,381.0,35002482688.0 +2014-10-20,389.06,35002482688.0 +2014-10-19,390.59,35002482688.0 +2014-10-18,383.2,35002482688.0 +2014-10-17,384.19,35002482688.0 +2014-10-16,394.52,35002482688.0 +2014-10-15,402.01,35002482688.0 +2014-10-14,392.99,35002482688.0 +2014-10-13,378.48,35002482688.0 +2014-10-12,362.77,35002482688.0 +2014-10-11,360.85,35002482688.0 +2014-10-10,364.01,35002482688.0 +2014-10-09,355.73,34758211750.1 +2014-10-08,334.8,34661425152.0 +2014-10-07,328.56,34661425152.0 +2014-10-06,322.82,34661425152.0 +2014-10-05,326.24,34661425152.0 +2014-10-04,358.71,34661425152.0 +2014-10-03,376.29,34661425152.0 +2014-10-02,384.85,34661425152.0 +2014-10-01,389.56,34661425152.0 +2014-09-30,374.17,34661425152.0 +2014-09-29,375.35,34661425152.0 +2014-09-28,399.16,34661425152.0 +2014-09-27,405.08,34661425152.0 +2014-09-26,410.0,34661425152.0 +2014-09-25,423.57,30419648333.4 +2014-09-24,440.85,29829732352.0 +2014-09-23,399.77,29829732352.0 +2014-09-22,400.77,29829732352.0 +2014-09-21,410.92,29829732352.0 +2014-09-20,395.86,29829732352.0 +2014-09-19,426.62,29829732352.0 +2014-09-18,452.99,29829732352.0 +2014-09-17,463.48,29829732352.0 +2014-09-16,469.47,29829732352.0 +2014-09-15,475.47,29829732352.0 +2014-09-14,477.99,29829732352.0 +2014-09-13,473.08,27800071694.1 +2014-09-12,477.43,27428630528.0 +2014-09-11,477.78,27428630528.0 +2014-09-10,473.34,27428630528.0 +2014-09-09,468.32,27428630528.0 +2014-09-08,477.4,27428630528.0 +2014-09-07,479.99,27428630528.0 +2014-09-06,477.65,27428630528.0 +2014-09-05,489.61,27428630528.0 +2014-09-04,474.86,27428630528.0 +2014-09-03,474.5,27428630528.0 +2014-09-02,475.89,27428630528.0 +2014-09-01,479.01,27428630528.0 +2014-08-31,501.49,23901860308.4 +2014-08-30,509.3,23844669440.0 +2014-08-29,506.94,23844669440.0 +2014-08-28,511.87,23844669440.0 +2014-08-27,514.4,23844669440.0 +2014-08-26,503.74,23844669440.0 +2014-08-25,507.84,23844669440.0 +2014-08-24,496.96,23844669440.0 +2014-08-23,514.65,23844669440.0 +2014-08-22,519.29,23844669440.0 +2014-08-21,516.39,23844669440.0 +2014-08-20,491.98,23844669440.0 +2014-08-19,474.74,20349111527.2 +2014-08-18,498.0,19729645568.0 +2014-08-17,523.47,19729645568.0 +2014-08-16,502.48,19729645568.0 +2014-08-15,507.99,19729645568.0 +2014-08-14,549.85,19729645568.0 +2014-08-13,569.39,19729645568.0 +2014-08-12,574.55,19729645568.0 +2014-08-11,590.98,19729645568.0 +2014-08-10,589.82,19729645568.0 +2014-08-09,588.99,19729645568.0 +2014-08-08,585.84,19534776384.8 +2014-08-07,581.16,18736441344.0 +2014-08-06,581.75,18736441344.0 +2014-08-05,588.5,18736441344.0 +2014-08-04,588.96,18736441344.0 +2014-08-03,589.6,18736441344.0 +2014-08-02,597.84,18736441344.0 +2014-08-01,583.54,18736441344.0 +2014-07-31,563.83,18736441344.0 +2014-07-30,585.93,18736441344.0 +2014-07-29,589.88,18736441344.0 +2014-07-28,592.61,18736441344.0 +2014-07-27,596.23,18736441344.0 +2014-07-26,602.93,18736441344.0 +2014-07-25,603.96,17439394520.7 +2014-07-24,620.95,17336317952.0 +2014-07-23,619.99,17336317952.0 +2014-07-22,622.63,17336317952.0 +2014-07-21,626.98,17336317952.0 +2014-07-20,630.0,17336317952.0 +2014-07-19,632.59,17336317952.0 +2014-07-18,626.3,17336317952.0 +2014-07-17,617.39,17336317952.0 +2014-07-16,622.9,17336317952.0 +2014-07-15,621.15,17336317952.0 +2014-07-14,630.88,17336317952.0 +2014-07-13,637.9,17336317952.0 +2014-07-12,634.99,16834953933.5 +2014-07-11,616.87,16818461696.0 +2014-07-10,621.96,16818461696.0 +2014-07-09,623.98,16818461696.0 +2014-07-08,622.09,16818461696.0 +2014-07-07,633.87,16818461696.0 +2014-07-06,630.9,16818461696.0 +2014-07-05,628.81,16818461696.0 +2014-07-04,648.48,16818461696.0 +2014-07-03,650.49,16818461696.0 +2014-07-02,638.25,16818461696.0 +2014-07-01,640.0,16818461696.0 +2014-06-30,599.86,16818461696.0 +2014-06-29,591.46,15429084016.5 +2014-06-28,599.99,13462580224.0 +2014-06-27,580.09,13462580224.0 +2014-06-26,560.4,13462580224.0 +2014-06-25,574.0,13462580224.0 +2014-06-24,588.22,13462580224.0 +2014-06-23,600.34,13462580224.0 +2014-06-22,591.33,13462580224.0 +2014-06-21,590.0,13462580224.0 +2014-06-20,593.41,13462580224.0 +2014-06-19,607.99,13462580224.0 +2014-06-18,606.48,13171043788.1 +2014-06-17,587.0,11756552192.0 +2014-06-16,592.0,11756552192.0 +2014-06-15,566.58,11756552192.0 +2014-06-14,592.0,11756552192.0 +2014-06-13,569.98,11756552192.0 +2014-06-12,623.81,11756552192.0 +2014-06-11,648.55,11756552192.0 +2014-06-10,648.83,11756552192.0 +2014-06-09,658.0,11756552192.0 +2014-06-08,657.13,11756552192.0 +2014-06-07,647.16,11756552192.0 +2014-06-06,661.46,11756552192.0 +2014-06-05,640.55,10584091540.2 +2014-06-04,668.9,10455719936.0 +2014-06-03,662.0,10455719936.0 +2014-06-02,630.99,10455719936.0 +2014-06-01,627.8,10455719936.0 +2014-05-31,621.0,10455719936.0 +2014-05-30,572.37,10455719936.0 +2014-05-29,580.66,10455719936.0 +2014-05-28,572.7,10455719936.0 +2014-05-27,581.87,10455719936.0 +2014-05-26,573.5,10455719936.0 +2014-05-25,528.44,10455719936.0 +2014-05-24,523.75,9612949650.29 +2014-05-23,529.99,8853415936.0 +2014-05-22,493.98,8853415936.0 +2014-05-21,489.0,8853415936.0 +2014-05-20,448.34,8853415936.0 +2014-05-19,446.91,8853415936.0 +2014-05-18,449.07,8853415936.0 +2014-05-17,447.55,8853415936.0 +2014-05-16,446.27,8853415936.0 +2014-05-15,444.07,8853415936.0 +2014-05-14,439.12,8853415936.0 +2014-05-13,442.48,8853415936.0 +2014-05-12,437.67,8359564228.68 +2014-05-11,457.7,8000871936.0 +2014-05-10,452.78,8000871936.0 +2014-05-09,439.6,8000871936.0 +2014-05-08,441.47,8000871936.0 +2014-05-07,429.0,8000871936.0 +2014-05-06,431.64,8000871936.0 +2014-05-05,435.88,8000871936.0 +2014-05-04,439.0,8000871936.0 +2014-05-03,452.0,8000871936.0 +2014-05-02,460.97,8000871936.0 +2014-05-01,449.0,8000871936.0 +2014-04-30,448.0,8000871936.0 +2014-04-29,440.41,7026656860.82 +2014-04-28,430.0,6978842624.0 +2014-04-27,459.22,6978842624.0 +2014-04-26,466.71,6978842624.0 +2014-04-25,502.15,6978842624.0 +2014-04-24,491.94,6978842624.0 +2014-04-23,490.0,6978842624.0 +2014-04-22,497.98,6978842624.0 +2014-04-21,501.07,6978842624.0 +2014-04-20,505.18,6978842624.0 +2014-04-19,482.1,6978842624.0 +2014-04-18,500.09,6978842624.0 +2014-04-17,529.26,6328150803.69 +2014-04-16,523.1,6119726080.0 +2014-04-15,459.99,6119726080.0 +2014-04-14,416.29,6119726080.0 +2014-04-13,424.91,6119726080.0 +2014-04-12,423.0,6119726080.0 +2014-04-11,363.1,6119726080.0 +2014-04-10,441.69,6119726080.0 +2014-04-09,453.57,6119726080.0 +2014-04-08,447.11,6119726080.0 +2014-04-07,459.97,6119726080.0 +2014-04-06,464.8,6119726080.0 +2014-04-05,450.0,5560039447.95 +2014-04-04,451.03,5006860800.0 +2014-04-03,438.9,5006860800.0 +2014-04-02,478.98,5006860800.0 +2014-04-01,454.81,5006860800.0 +2014-03-31,460.0,5006860800.0 +2014-03-30,491.99,5006860800.0 +2014-03-29,502.01,5006860800.0 +2014-03-28,475.0,5006860800.0 +2014-03-27,581.48,5006860800.0 +2014-03-26,583.77,5006860800.0 +2014-03-25,585.9,5006860800.0 +2014-03-24,558.22,4270341463.15 +2014-03-23,564.31,4250217984.0 +2014-03-22,569.99,4250217984.0 +2014-03-21,585.6,4250217984.0 +2014-03-20,610.01,4250217984.0 +2014-03-19,613.84,4250217984.0 +2014-03-18,622.97,4250217984.0 +2014-03-17,634.99,4250217984.0 +2014-03-16,637.58,4250217984.0 +2014-03-15,630.99,4250217984.0 +2014-03-14,641.02,4250217984.0 +2014-03-13,634.95,4218033227.85 +2014-03-12,631.72,3815723776.0 +2014-03-11,628.02,3815723776.0 +2014-03-10,638.4,3815723776.0 +2014-03-09,620.02,3815723776.0 +2014-03-08,632.79,3815723776.0 +2014-03-07,669.57,3815723776.0 +2014-03-06,669.0,3815723776.0 +2014-03-05,673.27,3815723776.0 +2014-03-04,677.69,3815723776.0 +2014-03-03,565.38,3815723776.0 +2014-03-02,567.46,3815723776.0 +2014-03-01,551.8,3815723776.0 +2014-02-28,584.7,3440425903.38 +2014-02-27,585.24,3129573120.0 +2014-02-26,534.34,3129573120.0 +2014-02-25,535.49,3129573120.0 +2014-02-24,609.9,3129573120.0 +2014-02-23,610.77,3129573120.0 +2014-02-22,581.35,3129573120.0 +2014-02-21,561.86,3129573120.0 +2014-02-20,623.01,3129573120.0 +2014-02-19,627.7,3129573120.0 +2014-02-18,633.66,3129573120.0 +2014-02-17,621.0,3123016104.46 +2014-02-16,655.83,2621404416.0 +2014-02-15,670.34,2621404416.0 +2014-02-14,609.4,2621404416.0 +2014-02-13,650.04,2621404416.0 +2014-02-12,677.0,2621404416.0 +2014-02-11,688.34,2621404416.0 +2014-02-10,688.0,2621404416.0 +2014-02-09,680.49,2621404416.0 +2014-02-08,705.01,2621404416.0 +2014-02-07,764.0,2621404416.0 +2014-02-06,780.01,2621404416.0 +2014-02-05,802.0,2468705627.43 +2014-02-04,806.99,2193847808.0 +2014-02-03,814.94,2193847808.0 +2014-02-02,813.23,2193847808.0 +2014-02-01,803.0,2193847808.0 +2014-01-31,799.99,2193847808.0 +2014-01-30,794.21,2193847808.0 +2014-01-29,785.51,2193847808.0 +2014-01-28,750.95,2193847808.0 +2014-01-27,814.67,2193847808.0 +2014-01-26,806.81,2193847808.0 +2014-01-25,780.0,2193847808.0 +2014-01-24,810.95,1941427202.71 +2014-01-23,819.2,1789547008.0 +2014-01-22,824.88,1789547008.0 +2014-01-21,826.02,1789547008.0 +2014-01-20,841.5,1789547008.0 +2014-01-19,810.0,1789547008.0 +2014-01-18,796.97,1789547008.0 +2014-01-17,814.4,1789547008.0 +2014-01-16,841.14,1789547008.0 +2014-01-15,815.99,1789547008.0 +2014-01-14,823.99,1789547008.0 +2014-01-13,844.04,1730264338.18 +2014-01-12,895.0,1418481408.0 +2014-01-11,851.63,1418481408.0 +2014-01-10,825.5,1418481408.0 +2014-01-09,823.94,1418481408.0 +2014-01-08,785.0,1418481408.0 +2014-01-07,915.8,1418481408.0 +2014-01-06,905.0,1418481408.0 +2014-01-05,828.79,1418481408.0 +2014-01-04,808.24,1418481408.0 +2014-01-03,784.19,1418481408.0 +2014-01-02,751.88,1406071647.52 +2014-01-01,732.0,1180923136.0 +2013-12-31,736.51,1180923136.0 +2013-12-30,728.01,1180923136.0 +2013-12-29,715.0,1180923136.0 +2013-12-28,723.98,1180923136.0 +2013-12-27,747.83,1180923136.0 +2013-12-26,679.01,1180923136.0 +2013-12-25,653.57,1180923136.0 +2013-12-24,654.76,1180923136.0 +2013-12-23,612.66,1180923136.0 +2013-12-22,595.07,1180923136.0 +2013-12-21,610.0,1067492432.3 +2013-12-20,685.1,908350848.0 +2013-12-19,520.0,908350848.0 +2013-12-18,675.0,908350848.0 +2013-12-17,690.5,908350848.0 +2013-12-16,861.98,908350848.0 +2013-12-15,850.78,908350848.0 +2013-12-14,888.47,908350848.0 +2013-12-13,871.22,908350848.0 +2013-12-12,879.04,908350848.0 +2013-12-11,979.07,908350848.0 +2013-12-10,899.91,775435696.0 +2013-12-09,787.0,707408256.0 +2013-12-08,693.3,707408256.0 +2013-12-07,809.72,707408256.0 +2013-12-06,1020.51,707408256.0 +2013-12-05,1135.0,707408256.0 +2013-12-04,1055.0,707408256.0 +2013-12-03,1037.11,707408256.0 +2013-12-02,955.0,707408256.0 +2013-12-01,1119.52,707408256.0 +2013-11-30,1131.99,707408256.0 +2013-11-29,1012.0,634388612.81 +2013-11-28,963.98,609482688.0 +2013-11-27,915.01,609482688.0 +2013-11-26,811.95,609482688.0 +2013-11-25,800.01,609482688.0 +2013-11-24,829.15,609482688.0 +2013-11-23,794.0,609482688.0 +2013-11-22,720.0,609482688.0 +2013-11-21,600.0,609482688.0 +2013-11-20,536.01,609482688.0 +2013-11-19,669.0,609482688.0 +2013-11-18,478.1,609482688.0 +2013-11-17,434.53,542721005.42 +2013-11-16,412.07,510929728.0 +2013-11-15,416.88,510929728.0 +2013-11-14,393.5,510929728.0 +2013-11-13,354.94,510929728.0 +2013-11-12,343.63,510929728.0 +2013-11-11,323.0,510929728.0 +2013-11-10,341.24,510929728.0 +2013-11-09,333.9,510929728.0 +2013-11-08,291.0,510929728.0 +2013-11-07,263.24,510929728.0 +2013-11-06,242.9,510929728.0 +2013-11-05,227.29,412308275.68 +2013-11-04,210.0,390928800.0 +2013-11-03,204.86,390928800.0 +2013-11-02,202.14,390928800.0 +2013-11-01,203.54,390928800.0 +2013-10-31,197.58,390928800.0 +2013-10-30,204.0,390928800.0 +2013-10-29,196.62,390928800.0 +2013-10-28,194.99,390928800.0 +2013-10-27,180.39,390928800.0 +2013-10-26,187.5,373329149.71 +2013-10-25,194.0,267731248.0 +2013-10-24,203.94,267731248.0 +2013-10-23,189.74,267731248.0 +2013-10-22,180.15,267731248.0 +2013-10-21,166.6,267731248.0 +2013-10-20,166.0,267731248.0 +2013-10-19,152.89,267731248.0 +2013-10-18,143.94,267731248.0 +2013-10-17,137.54,267731248.0 +2013-10-16,142.75,219914105.14 +2013-10-15,135.43,189281248.0 +2013-10-14,132.83,189281248.0 +2013-10-13,127.58,189281248.0 +2013-10-12,127.38,189281248.0 +2013-10-11,126.8,189281248.0 +2013-10-10,125.79,189281248.0 +2013-10-09,124.5,189281248.0 +2013-10-08,123.5,189281248.0 +2013-10-07,122.49,189281248.0 +2013-10-06,121.25,164129164.11 +2013-10-05,121.94,148819200.0 +2013-10-04,117.62,148819200.0 +2013-10-03,103.85,148819200.0 +2013-10-02,127.31,148819200.0 +2013-10-01,126.25,148819200.0 +2013-09-30,127.0,148819200.0 +2013-09-29,126.5,148819200.0 +2013-09-28,126.95,148819200.0 +2013-09-27,124.85,148819200.0 +2013-09-26,123.32,148819200.0 +2013-09-25,123.75,125804758.8 +2013-09-24,122.81,112628552.0 +2013-09-23,123.27,112628552.0 +2013-09-22,123.38,112628552.0 +2013-09-21,122.92,112628552.0 +2013-09-20,124.17,112628552.0 +2013-09-19,127.0,112628552.0 +2013-09-18,126.92,112628552.0 +2013-09-17,126.28,112628552.0 +2013-09-16,125.36,112628552.0 +2013-09-15,124.49,112628552.0 +2013-09-14,127.71,87168754.86 +2013-09-13,126.38,86933016.0 +2013-09-12,127.54,86933016.0 +2013-09-11,122.08,86933016.0 +2013-09-10,121.68,86933016.0 +2013-09-09,118.37,86933016.0 +2013-09-08,119.91,86933016.0 +2013-09-07,116.56,86933016.0 +2013-09-06,122.0,86933016.0 +2013-09-05,121.65,86933016.0 +2013-09-04,129.2,81734744.59 +2013-09-03,129.4,65750060.0 +2013-09-02,130.65,65750060.0 +2013-09-01,127.9,65750060.0 +2013-08-31,124.86,65750060.0 +2013-08-30,118.91,65750060.0 +2013-08-29,117.91,65750060.0 +2013-08-28,117.74,65750060.0 +2013-08-27,111.85,65750060.0 +2013-08-26,113.12,65750060.0 +2013-08-25,109.15,65750060.0 +2013-08-24,107.91,56116797.92 +2013-08-23,109.12,50810340.0 +2013-08-22,111.52,50810340.0 +2013-08-21,104.87,50810340.0 +2013-08-20,102.85,50810340.0 +2013-08-19,99.32,50810340.0 +2013-08-18,99.71,50810340.0 +2013-08-17,98.26,50810340.0 +2013-08-16,98.09,50810340.0 +2013-08-15,99.19,50810340.0 +2013-08-14,97.75,50810340.0 +2013-08-13,95.37,39812330.16 +2013-08-12,94.0,37392768.0 +2013-08-11,93.51,37392768.0 +2013-08-10,92.72,37392768.0 +2013-08-09,94.26,37392768.0 +2013-08-08,97.09,37392768.0 +2013-08-07,97.7,37392768.0 +2013-08-06,97.88,37392768.0 +2013-08-05,96.38,37392768.0 +2013-08-04,95.54,37392768.0 +2013-08-03,95.82,34144399.06 +2013-08-02,96.63,31256960.0 +2013-08-01,97.77,31256960.0 +2013-07-31,96.98,31256960.0 +2013-07-30,93.45,31256960.0 +2013-07-29,92.72,31256960.0 +2013-07-28,88.16,31256960.0 +2013-07-27,89.97,31256960.0 +2013-07-26,90.1,31256960.0 +2013-07-25,88.42,31256960.0 +2013-07-24,86.88,31256960.0 +2013-07-23,85.59,31256960.0 +2013-07-22,85.73,27181692.8 +2013-07-21,85.02,26162876.0 +2013-07-20,86.51,26162876.0 +2013-07-19,85.0,26162876.0 +2013-07-18,90.96,26162876.0 +2013-07-17,91.61,26162876.0 +2013-07-16,93.76,26162876.0 +2013-07-15,90.02,26162876.0 +2013-07-14,91.67,26162876.0 +2013-07-13,90.19,26162876.0 +2013-07-12,87.81,26162876.0 +2013-07-11,86.13,26107386.97 +2013-07-10,75.0,21335330.0 +2013-07-09,74.0,21335330.0 +2013-07-08,73.97,21335330.0 +2013-07-07,66.34,21335330.0 +2013-07-06,67.13,21335330.0 +2013-07-05,79.4,21335330.0 +2013-07-04,77.33,21335330.0 +2013-07-03,88.04,21335330.0 +2013-07-02,83.41,21335330.0 +2013-07-01,89.41,21335330.0 +2013-06-30,88.83,21335330.0 +2013-06-29,89.2,20177844.46 +2013-06-28,96.98,19339258.0 +2013-06-27,98.75,19339258.0 +2013-06-26,97.57,19339258.0 +2013-06-25,98.83,19339258.0 +2013-06-24,100.4,19339258.0 +2013-06-23,100.0,19339258.0 +2013-06-22,101.29,19339258.0 +2013-06-21,103.0,19339258.0 +2013-06-20,105.24,19339258.0 +2013-06-19,104.49,19339258.0 +2013-06-18,100.39,19339258.0 +2013-06-17,98.74,19339258.0 +2013-06-16,99.43,15948722.86 +2013-06-15,99.01,15605633.0 +2013-06-14,101.86,15605633.0 +2013-06-13,106.1,15605633.0 +2013-06-12,107.35,15605633.0 +2013-06-11,104.21,15605633.0 +2013-06-10,100.17,15605633.0 +2013-06-09,109.11,15605633.0 +2013-06-08,110.17,15605633.0 +2013-06-07,118.78,15605633.0 +2013-06-06,120.98,15605633.0 +2013-06-05,120.58,13466756.95 +2013-06-04,123.22,12153412.0 +2013-06-03,123.35,12153412.0 +2013-06-02,128.77,12153412.0 +2013-06-01,127.76,12153412.0 +2013-05-31,126.78,12153412.0 +2013-05-30,130.01,12153412.0 +2013-05-29,125.99,12153412.0 +2013-05-28,126.2,12153412.0 +2013-05-27,130.27,12153412.0 +2013-05-26,128.98,12153412.0 +2013-05-25,128.65,11450753.82 +2013-05-24,123.84,11187257.0 +2013-05-23,118.45,11187257.0 +2013-05-22,117.25,11187257.0 +2013-05-21,117.81,11187257.0 +2013-05-20,117.27,11187257.0 +2013-05-19,118.49,11187257.0 +2013-05-18,117.51,11187257.0 +2013-05-17,113.36,11187257.0 +2013-05-16,108.96,11187257.0 +2013-05-15,107.0,11187257.0 +2013-05-14,115.98,11187257.0 +2013-05-13,115.05,11187257.0 +2013-05-12,115.58,10301130.95 +2013-05-11,117.9,10076293.0 +2013-05-10,111.96,10076293.0 +2013-05-09,113.16,10076293.0 +2013-05-08,110.92,10076293.0 +2013-05-07,112.67,10076293.0 +2013-05-06,116.9,10076293.0 +2013-05-05,112.89,10076293.0 +2013-05-04,98.08,10076293.0 +2013-05-03,107.02,10076293.0 +2013-05-02,116.75,10076293.0 +2013-05-01,139.87,10076293.0 +2013-04-30,143.32,9854414.41 +2013-04-29,135.31,8974296.0 +2013-04-28,128.8,8974296.0 +2013-04-27,137.3,8974296.0 +2013-04-26,141.9,8974296.0 +2013-04-25,150.0,8974296.0 +2013-04-24,137.3,8974296.0 +2013-04-23,123.73,8974296.0 +2013-04-22,118.91,8974296.0 +2013-04-21,126.55,8974296.0 +2013-04-20,118.11,8974296.0 +2013-04-19,109.3,8974296.0 +2013-04-18,89.98,8974296.0 +2013-04-17,67.85,8038276.07 +2013-04-16,73.99,7673000.0 +2013-04-15,91.79,7673000.0 +2013-04-14,90.44,7673000.0 +2013-04-13,109.9,7673000.0 +2013-04-12,81.02,7673000.0 +2013-04-11,162.0,7673000.0 +2013-04-10,228.94,7673000.0 +2013-04-09,185.6,7673000.0 +2013-04-08,164.97,7673000.0 +2013-04-07,141.0,7673000.0 +2013-04-06,141.8,7673000.0 +2013-04-05,134.67,7005058.62 +2013-04-04,133.87,6695826.5 +2013-04-03,116.0,6695826.5 +2013-04-02,103.73,6695826.5 +2013-04-01,95.5,6695826.5 +2013-03-31,92.12,6695826.5 +2013-03-30,90.49,6695826.5 +2013-03-29,88.96,6695826.5 +2013-03-28,89.4,6695826.5 +2013-03-27,79.81,6695826.5 +2013-03-26,74.3,6695826.5 +2013-03-25,70.22,6695826.5 +2013-03-24,64.37,5581051.56 +2013-03-23,68.81,4847647.0 +2013-03-22,70.87,4847647.0 +2013-03-21,65.13,4847647.0 +2013-03-20,59.46,4847647.0 +2013-03-19,49.87,4847647.0 +2013-03-18,47.24,4847647.0 +2013-03-17,46.7,4847647.0 +2013-03-16,46.93,4847647.0 +2013-03-15,46.95,4847647.0 +2013-03-14,46.99,4665387.63 +2013-03-13,44.29,4367876.0 +2013-03-12,48.15,4367876.0 +2013-03-11,45.97,4367876.0 +2013-03-10,45.76,4367876.0 +2013-03-09,43.77,4367876.0 +2013-03-08,41.68,4367876.0 +2013-03-07,42.31,4367876.0 +2013-03-06,40.66,4367876.0 +2013-03-05,36.56,4367876.0 +2013-03-04,34.33,4367876.0 +2013-03-03,34.29,4367876.0 +2013-03-02,34.55,4367876.0 +2013-03-01,33.53,3844376.45 +2013-02-28,31.31,3651011.75 +2013-02-27,31.01,3651011.75 +2013-02-26,30.43,3651011.75 +2013-02-25,29.79,3651011.75 +2013-02-24,29.55,3651011.75 +2013-02-23,30.37,3651011.75 +2013-02-22,29.96,3651011.75 +2013-02-21,30.0,3651011.75 +2013-02-20,29.39,3651011.75 +2013-02-19,26.92,3651011.75 +2013-02-18,26.81,3639348.79 +2013-02-17,27.36,3275464.5 +2013-02-16,27.43,3275464.5 +2013-02-15,27.4,3275464.5 +2013-02-14,25.0,3275464.5 +2013-02-13,25.33,3275464.5 +2013-02-12,23.94,3275464.5 +2013-02-11,23.74,3275464.5 +2013-02-10,23.46,3275464.5 +2013-02-09,22.4,3275464.5 +2013-02-08,21.95,3275464.5 +2013-02-07,20.91,3275464.5 +2013-02-06,20.56,3275464.5 +2013-02-05,20.3,3115692.26 +2013-02-04,20.55,2968775.25 +2013-02-03,19.76,2968775.25 +2013-02-02,20.35,2968775.25 +2013-02-01,20.3,2968775.25 +2013-01-31,19.45,2968775.25 +2013-01-30,19.46,2968775.25 +2013-01-29,18.6,2968775.25 +2013-01-28,17.6,2968775.25 +2013-01-27,17.49,2968775.25 +2013-01-26,17.3,2968775.25 +2013-01-25,17.15,2968775.25 +2013-01-24,17.5,2968775.25 +2013-01-23,17.5,3187155.22 +2013-01-22,16.53,3249549.5 +2013-01-21,15.62,3249549.5 +2013-01-20,15.48,3249549.5 +2013-01-19,15.52,3249549.5 +2013-01-18,15.34,3249549.5 +2013-01-17,14.53,3249549.5 +2013-01-16,14.15,3249549.5 +2013-01-15,14.1,3249549.5 +2013-01-14,13.65,3249549.5 +2013-01-13,13.94,3249549.5 +2013-01-12,14.02,3249549.5 +2013-01-11,14.0,3249549.5 +2013-01-10,13.67,3249549.5 +2013-01-09,13.51,3249549.5 +2013-01-08,13.2,3117637.13 +2013-01-07,13.1,2979636.5 +2013-01-06,13.11,2979636.5 +2013-01-05,13.19,2979636.5 +2013-01-04,13.12,2979636.5 +2013-01-03,13.09,2979636.5 +2013-01-02,13.12,2979636.5 +2013-01-01,13.24,2979636.5 +2012-12-31,13.2,2979636.5 +2012-12-30,13.13,2979636.5 +2012-12-29,13.18,2979636.5 +2012-12-28,13.19,2979636.5 +2012-12-27,13.18,2979636.5 +2012-12-26,13.09,3182517.15 +2012-12-25,13.23,3370181.75 +2012-12-24,13.11,3370181.75 +2012-12-23,13.2,3370181.75 +2012-12-22,13.28,3370181.75 +2012-12-21,13.38,3370181.75 +2012-12-20,13.27,3370181.75 +2012-12-19,13.13,3370181.75 +2012-12-18,13.3,3370181.75 +2012-12-17,13.28,3370181.75 +2012-12-16,13.38,3370181.75 +2012-12-15,13.51,3370181.75 +2012-12-14,13.51,3370181.75 +2012-12-13,13.49,3370181.75 +2012-12-12,13.39,3370181.75 +2012-12-11,13.13,3370181.75 +2012-12-10,13.3,3422568.26 +2012-12-09,13.35,3438909.0 +2012-12-08,13.3,3438909.0 +2012-12-07,13.34,3438909.0 +2012-12-06,13.2,3438909.0 +2012-12-05,12.86,3438909.0 +2012-12-04,12.5,3438909.0 +2012-12-03,12.46,3438909.0 +2012-12-02,12.44,3438909.0 +2012-12-01,12.39,3438909.0 +2012-11-30,12.35,3438909.0 +2012-11-29,12.22,3438909.0 +2012-11-28,12.01,3438909.0 +2012-11-27,12.2,3438909.0 +2012-11-26,12.32,3402274.46 +2012-11-25,12.29,3368767.25 +2012-11-24,12.16,3368767.25 +2012-11-23,11.86,3368767.25 +2012-11-22,11.67,3368767.25 +2012-11-21,11.64,3368767.25 +2012-11-20,11.6,3368767.25 +2012-11-19,11.51,3368767.25 +2012-11-18,11.56,3368767.25 +2012-11-17,11.48,3368767.25 +2012-11-16,11.05,3368767.25 +2012-11-15,10.98,3368767.25 +2012-11-14,10.87,3368767.25 +2012-11-13,10.92,3368767.25 +2012-11-12,10.78,3321435.11 +2012-11-11,10.82,3304356.5 +2012-11-10,10.8,3304356.5 +2012-11-09,10.69,3304356.5 +2012-11-08,10.65,3304356.5 +2012-11-07,10.68,3304356.5 +2012-11-06,10.78,3304356.5 +2012-11-05,10.63,3304356.5 +2012-11-04,10.67,3304356.5 +2012-11-03,10.54,3304356.5 +2012-11-02,10.85,3304356.5 +2012-11-01,11.0,3304356.5 +2012-10-31,10.79,3304356.5 +2012-10-30,10.8,3304356.5 +2012-10-29,10.67,3072321.75 +2012-10-28,10.35,3072321.75 +2012-10-27,10.0,3072321.75 +2012-10-26,10.46,3072321.75 +2012-10-25,11.39,3072321.75 +2012-10-24,11.38,3072321.75 +2012-10-23,11.5,3072321.75 +2012-10-22,11.54,3072321.75 +2012-10-21,11.6,3072321.75 +2012-10-20,11.65,3072321.75 +2012-10-19,11.75,3072321.75 +2012-10-18,11.9,3072321.75 +2012-10-17,11.79,3072321.75 +2012-10-16,11.8,3055426.6 +2012-10-15,11.78,3054627.5 +2012-10-14,11.85,3054627.5 +2012-10-13,11.9,3054627.5 +2012-10-12,11.95,3054627.5 +2012-10-11,12.1,3054627.5 +2012-10-10,11.85,3054627.5 +2012-10-09,11.62,3054627.5 +2012-10-08,11.7,3054627.5 +2012-10-07,12.39,3054627.5 +2012-10-06,12.51,3054627.5 +2012-10-05,12.61,3054627.5 +2012-10-04,12.9,3054627.5 +2012-10-03,12.63,3037440.7 +2012-10-02,12.2,2864140.5 +2012-10-01,12.21,2864140.5 +2012-09-30,12.2,2864140.5 +2012-09-29,12.28,2864140.5 +2012-09-28,12.21,2864140.5 +2012-09-27,12.2,2864140.5 +2012-09-26,11.8,2864140.5 +2012-09-25,11.9,2864140.5 +2012-09-24,11.99,2864140.5 +2012-09-23,12.11,2864140.5 +2012-09-22,12.14,2864140.5 +2012-09-21,12.29,2864140.5 +2012-09-20,12.44,2864140.5 +2012-09-19,11.9,2709730.29 +2012-09-18,11.85,2694048.0 +2012-09-17,11.75,2694048.0 +2012-09-16,11.63,2694048.0 +2012-09-15,11.6,2694048.0 +2012-09-14,11.26,2694048.0 +2012-09-13,11.17,2694048.0 +2012-09-12,11.04,2694048.0 +2012-09-11,10.95,2694048.0 +2012-09-10,10.85,2694048.0 +2012-09-09,10.97,2694048.0 +2012-09-08,10.98,2694048.0 +2012-09-07,11.03,2694048.0 +2012-09-06,10.9,2491027.22 +2012-09-05,10.38,2440642.5 +2012-09-04,10.36,2440642.5 +2012-09-03,10.17,2440642.5 +2012-09-02,10.07,2440642.5 +2012-09-01,10.2,2440642.5 +2012-08-31,10.65,2440642.5 +2012-08-30,10.81,2440642.5 +2012-08-29,11.0,2440642.5 +2012-08-28,10.9,2440642.5 +2012-08-27,10.31,2440642.5 +2012-08-26,10.57,2440642.5 +2012-08-25,10.45,2420732.78 +2012-08-24,10.03,2190866.0 +2012-08-23,9.96,2190866.0 +2012-08-22,9.99,2190866.0 +2012-08-21,9.79,2190866.0 +2012-08-20,8.09,2190866.0 +2012-08-19,11.86,2190866.0 +2012-08-18,12.64,2190866.0 +2012-08-17,13.49,2190866.0 +2012-08-16,13.14,2190866.0 +2012-08-15,12.13,2190866.0 +2012-08-14,11.9,2190866.0 +2012-08-13,11.42,2190866.0 +2012-08-12,11.4,2114253.45 +2012-08-11,11.32,2036671.13 +2012-08-10,11.0,2036671.13 +2012-08-09,11.0,2036671.13 +2012-08-08,10.75,2036671.13 +2012-08-07,10.86,2036671.13 +2012-08-06,10.71,2036671.13 +2012-08-05,10.93,2036671.13 +2012-08-04,10.96,2036671.13 +2012-08-03,10.4,2036671.13 +2012-08-02,9.45,2036671.13 +2012-08-01,9.28,2036671.13 +2012-07-31,9.0,2036671.13 +2012-07-30,8.7,1950563.69 +2012-07-29,8.79,1866391.25 +2012-07-28,8.83,1866391.25 +2012-07-27,8.76,1866391.25 +2012-07-26,8.64,1866391.25 +2012-07-25,8.59,1866391.25 +2012-07-24,8.59,1866391.25 +2012-07-23,8.42,1866391.25 +2012-07-22,8.74,1866391.25 +2012-07-21,8.52,1866391.25 +2012-07-20,8.76,1866391.25 +2012-07-19,9.06,1866391.25 +2012-07-18,8.5,1866391.25 +2012-07-17,8.3,1794889.9 +2012-07-16,7.57,1751454.5 +2012-07-15,7.55,1751454.5 +2012-07-14,7.58,1751454.5 +2012-07-13,7.6,1751454.5 +2012-07-12,7.15,1751454.5 +2012-07-11,7.08,1751454.5 +2012-07-10,6.95,1751454.5 +2012-07-09,6.77,1751454.5 +2012-07-08,6.8,1751454.5 +2012-07-07,6.6,1751454.5 +2012-07-06,6.59,1751454.5 +2012-07-05,6.52,1751454.5 +2012-07-04,6.44,1739840.1 +2012-07-03,6.61,1726566.5 +2012-07-02,6.55,1726566.5 +2012-07-01,6.6,1726566.5 +2012-06-30,6.58,1726566.5 +2012-06-29,6.5,1726566.5 +2012-06-28,6.49,1726566.5 +2012-06-27,6.41,1726566.5 +2012-06-26,6.26,1726566.5 +2012-06-25,6.35,1726566.5 +2012-06-24,6.35,1726566.5 +2012-06-23,6.6,1726566.5 +2012-06-22,6.64,1726566.5 +2012-06-21,6.66,1726566.5 +2012-06-20,6.4,1624711.13 +2012-06-19,6.13,1583177.88 +2012-06-18,6.13,1583177.88 +2012-06-17,6.41,1583177.88 +2012-06-16,6.41,1583177.88 +2012-06-15,5.88,1583177.88 +2012-06-14,5.86,1583177.88 +2012-06-13,5.77,1583177.88 +2012-06-12,5.57,1583177.88 +2012-06-11,5.48,1583177.88 +2012-06-10,5.54,1583177.88 +2012-06-09,5.6,1583177.88 +2012-06-08,5.48,1583177.88 +2012-06-07,5.41,1589256.96 +2012-06-06,5.39,1591075.0 +2012-06-05,5.22,1591075.0 +2012-06-04,5.18,1591075.0 +2012-06-03,5.19,1591075.0 +2012-06-02,5.2,1591075.0 +2012-06-01,5.17,1591075.0 +2012-05-31,5.14,1591075.0 +2012-05-30,5.07,1591075.0 +2012-05-29,5.07,1591075.0 +2012-05-28,5.08,1591075.0 +2012-05-27,5.08,1591075.0 +2012-05-26,5.08,1591075.0 +2012-05-25,5.09,1591075.0 +2012-05-24,5.08,1699095.7 +2012-05-23,5.02,1733207.5 +2012-05-22,5.05,1733207.5 +2012-05-21,5.04,1733207.5 +2012-05-20,5.03,1733207.5 +2012-05-19,5.08,1733207.5 +2012-05-18,5.03,1733207.5 +2012-05-17,5.02,1733207.5 +2012-05-16,5.0,1733207.5 +2012-05-15,4.95,1733207.5 +2012-05-14,4.93,1733207.5 +2012-05-13,4.95,1733207.5 +2012-05-12,4.95,1733207.5 +2012-05-11,4.97,1733207.5 +2012-05-10,5.02,1733207.5 +2012-05-09,5.02,1606014.25 +2012-05-08,5.06,1508589.63 +2012-05-07,5.05,1508589.63 +2012-05-06,5.06,1508589.63 +2012-05-05,5.09,1508589.63 +2012-05-04,5.1,1508589.63 +2012-05-03,5.06,1508589.63 +2012-05-02,5.01,1508589.63 +2012-05-01,4.94,1508589.63 +2012-04-30,4.92,1508589.63 +2012-04-29,4.92,1508589.63 +2012-04-28,5.07,1508589.63 +2012-04-27,5.03,1528103.01 +2012-04-26,5.1,1577913.5 +2012-04-25,5.12,1577913.5 +2012-04-24,4.99,1577913.5 +2012-04-23,5.2,1577913.5 +2012-04-22,5.24,1577913.5 +2012-04-21,5.4,1577913.5 +2012-04-20,5.15,1577913.5 +2012-04-19,5.17,1577913.5 +2012-04-18,4.98,1577913.5 +2012-04-17,4.99,1577913.5 +2012-04-16,4.93,1577913.5 +2012-04-15,4.96,1577913.5 +2012-04-14,4.94,1577913.5 +2012-04-13,4.88,1577913.5 +2012-04-12,4.87,1613531.77 +2012-04-11,4.86,1626553.5 +2012-04-10,4.75,1626553.5 +2012-04-09,4.7,1626553.5 +2012-04-08,4.8,1626553.5 +2012-04-07,4.94,1626553.5 +2012-04-06,4.9,1626553.5 +2012-04-05,4.99,1626553.5 +2012-04-04,4.92,1626553.5 +2012-04-03,5.04,1626553.5 +2012-04-02,4.8,1626553.5 +2012-04-01,4.89,1626553.5 +2012-03-31,4.9,1626553.5 +2012-03-30,4.81,1626553.5 +2012-03-29,4.93,1593806.49 +2012-03-28,4.75,1498294.38 +2012-03-27,4.54,1498294.38 +2012-03-26,4.6,1498294.38 +2012-03-25,4.61,1498294.38 +2012-03-24,4.72,1498294.38 +2012-03-23,4.73,1498294.38 +2012-03-22,4.86,1498294.38 +2012-03-21,4.9,1498294.38 +2012-03-20,4.82,1498294.38 +2012-03-19,5.24,1498294.38 +2012-03-18,5.41,1498294.38 +2012-03-17,5.38,1498294.38 +2012-03-16,5.3,1497898.79 +2012-03-15,5.27,1496978.63 +2012-03-14,5.32,1496978.63 +2012-03-13,4.99,1496978.63 +2012-03-12,4.85,1496978.63 +2012-03-11,4.94,1496978.63 +2012-03-10,4.91,1496978.63 +2012-03-09,5.01,1496978.63 +2012-03-08,4.94,1496978.63 +2012-03-07,5.05,1496978.63 +2012-03-06,5.0,1496978.63 +2012-03-05,4.8,1496978.63 +2012-03-04,4.78,1496978.63 +2012-03-03,4.81,1496978.63 +2012-03-02,4.99,1445646.14 +2012-03-01,4.99,1376302.25 +2012-02-29,4.97,1376302.25 +2012-02-28,5.09,1376302.25 +2012-02-27,4.97,1376302.25 +2012-02-26,4.79,1376302.25 +2012-02-25,5.11,1376302.25 +2012-02-24,5.12,1376302.25 +2012-02-23,4.59,1376302.25 +2012-02-22,4.47,1376302.25 +2012-02-21,4.52,1376302.25 +2012-02-20,4.72,1376302.25 +2012-02-19,4.38,1376302.25 +2012-02-18,4.67,1377710.78 +2012-02-17,4.67,1379647.5 +2012-02-16,4.5,1379647.5 +2012-02-15,4.9,1379647.5 +2012-02-14,5.2,1379647.5 +2012-02-13,5.53,1379647.5 +2012-02-12,5.78,1379647.5 +2012-02-11,5.71,1379647.5 +2012-02-10,5.88,1379647.5 +2012-02-09,5.52,1379647.5 +2012-02-08,5.79,1379647.5 +2012-02-07,5.5,1379647.5 +2012-02-06,5.6,1379647.5 +2012-02-05,5.93,1379647.5 +2012-02-04,6.35,1346207.4 +2012-02-03,6.29,1307728.38 +2012-02-02,5.99,1307728.38 +2012-02-01,5.53,1307728.38 +2012-01-31,5.7,1307728.38 +2012-01-30,5.3,1307728.38 +2012-01-29,5.89,1307728.38 +2012-01-28,4.91,1307728.38 +2012-01-27,3.8,1307728.38 +2012-01-26,6.27,1307728.38 +2012-01-25,6.26,1307728.38 +2012-01-24,6.52,1307728.38 +2012-01-23,6.5,1307728.38 +2012-01-22,6.79,1298931.44 +2012-01-21,6.3,1250757.75 +2012-01-20,6.9,1250757.75 +2012-01-19,5.52,1250757.75 +2012-01-18,5.99,1250757.75 +2012-01-17,6.5,1250757.75 +2012-01-16,6.2,1250757.75 +2012-01-15,7.15,1250757.75 +2012-01-14,6.5,1250757.75 +2012-01-13,6.8,1250757.75 +2012-01-12,6.95,1250757.75 +2012-01-11,7.14,1250757.75 +2012-01-10,6.24,1250757.75 +2012-01-09,6.99,1250757.75 +2012-01-08,6.9,1178875.27 +2012-01-07,6.8,1159929.5 +2012-01-06,6.65,1159929.5 +2012-01-05,5.72,1159929.5 +2012-01-04,4.93,1159929.5 +2012-01-03,5.32,1159929.5 +2012-01-02,5.0,1159929.5 +2012-01-01,4.58,1159929.5 +2011-12-31,4.39,1159929.5 +2011-12-30,4.26,1159929.5 +2011-12-29,4.3,1159929.5 +2011-12-28,4.29,1159929.5 +2011-12-27,4.33,1159929.5 +2011-12-26,4.27,1156198.98 +2011-12-25,4.32,1155038.38 +2011-12-24,4.33,1155038.38 +2011-12-23,3.86,1155038.38 +2011-12-22,4.19,1155038.38 +2011-12-21,4.38,1155038.38 +2011-12-20,4.75,1155038.38 +2011-12-19,3.5,1155038.38 +2011-12-18,3.25,1155038.38 +2011-12-17,3.25,1155038.38 +2011-12-16,3.25,1155038.38 +2011-12-15,3.39,1155038.38 +2011-12-14,3.42,1155038.38 +2011-12-13,3.25,1155038.38 +2011-12-12,3.37,1101351.67 +2011-12-11,3.17,1090715.63 +2011-12-10,3.2,1090715.63 +2011-12-09,3.2,1090715.63 +2011-12-08,3.27,1090715.63 +2011-12-07,3.05,1090715.63 +2011-12-06,2.9,1090715.63 +2011-12-05,2.82,1090715.63 +2011-12-04,2.82,1090715.63 +2011-12-03,2.93,1090715.63 +2011-12-02,3.45,1090715.63 +2011-12-01,3.46,1090715.63 +2011-11-30,3.19,1090715.63 +2011-11-29,2.69,1149719.76 +2011-11-28,2.67,1192497.75 +2011-11-27,2.67,1192497.75 +2011-11-26,2.77,1192497.75 +2011-11-25,2.5,1192497.75 +2011-11-24,2.54,1192497.75 +2011-11-23,2.54,1192497.75 +2011-11-22,2.53,1192497.75 +2011-11-21,2.45,1192497.75 +2011-11-20,2.37,1192497.75 +2011-11-19,2.5,1192497.75 +2011-11-18,2.5,1192497.75 +2011-11-17,3.0,1192497.75 +2011-11-16,2.51,1192497.75 +2011-11-15,2.99,1192497.75 +2011-11-14,2.95,1196024.67 +2011-11-13,3.35,1203461.88 +2011-11-12,3.35,1203461.88 +2011-11-11,3.3,1203461.88 +2011-11-10,3.25,1203461.88 +2011-11-09,3.09,1203461.88 +2011-11-08,3.08,1203461.88 +2011-11-07,3.08,1203461.88 +2011-11-06,2.95,1203461.88 +2011-11-05,3.21,1203461.88 +2011-11-04,3.27,1203461.88 +2011-11-03,3.27,1203461.88 +2011-11-02,3.27,1203461.88 +2011-11-01,3.32,1203461.88 +2011-10-31,3.25,1235795.74 +2011-10-30,3.85,1468195.38 +2011-10-29,3.69,1468195.38 +2011-10-28,3.07,1468195.38 +2011-10-27,3.07,1468195.38 +2011-10-26,2.72,1468195.38 +2011-10-25,2.66,1468195.38 +2011-10-24,2.99,1468195.38 +2011-10-23,2.99,1468195.38 +2011-10-22,2.99,1468195.38 +2011-10-21,2.22,1468195.38 +2011-10-20,2.22,1468195.38 +2011-10-19,2.22,1468195.38 +2011-10-18,2.22,1468195.38 +2011-10-17,3.92,1468195.38 +2011-10-16,3.92,1468195.38 +2011-10-15,3.92,1468195.38 +2011-10-14,4.05,1479331.87 +2011-10-13,3.93,1689334.38 +2011-10-12,3.95,1689334.38 +2011-10-11,3.98,1689334.38 +2011-10-10,3.99,1689334.38 +2011-10-09,3.89,1689334.38 +2011-10-08,4.57,1689334.38 +2011-10-07,4.8,1689334.38 +2011-10-06,4.88,1689334.38 +2011-10-05,4.92,1689334.38 +2011-10-04,4.86,1689334.38 +2011-10-03,4.85,1689334.38 +2011-10-02,4.85,1689334.38 +2011-10-01,4.85,1689334.38 +2011-09-30,4.85,1689334.38 +2011-09-29,4.81,1689334.38 +2011-09-28,4.9,1689334.38 +2011-09-27,4.85,1753437.68 +2011-09-26,6.06,1755425.38 +2011-09-25,6.05,1755425.38 +2011-09-24,5.7,1755425.38 +2011-09-23,5.7,1755425.38 +2011-09-22,5.68,1755425.38 +2011-09-21,5.7,1755425.38 +2011-09-20,4.92,1755425.38 +2011-09-19,4.9,1755425.38 +2011-09-18,4.87,1755425.38 +2011-09-17,4.87,1755425.38 +2011-09-16,4.82,1755425.38 +2011-09-15,5.12,1755425.38 +2011-09-14,5.58,1755425.38 +2011-09-13,5.8,1765183.44 +2011-09-12,5.94,1777774.5 +2011-09-11,4.7739,1777774.5 +2011-09-10,5.019,1777774.5 +2011-09-09,6.5299,1777774.5 +2011-09-08,7.19786,1777774.5 +2011-09-07,6.8628,1777774.5 +2011-09-06,7.61101,1777774.5 +2011-09-05,8.12796,1777774.5 +2011-09-04,8.4632,1777774.5 +2011-09-03,8.6,1777774.5 +2011-09-02,8.25,1777774.5 +2011-09-01,8.19951,1777774.5 +2011-08-31,8.79,1777774.5 +2011-08-30,8.969,1783130.24 +2011-08-29,9.07021,1805700.88 +2011-08-28,8.5911,1805700.88 +2011-08-27,8.17939,1805700.88 +2011-08-26,9.65702,1805700.88 +2011-08-25,10.8506,1805700.88 +2011-08-24,10.94001,1805700.88 +2011-08-23,10.909,1805700.88 +2011-08-22,11.31125,1805700.88 +2011-08-21,11.453,1805700.88 +2011-08-20,11.65638,1805700.88 +2011-08-19,10.83001,1805700.88 +2011-08-18,10.97792,1805700.88 +2011-08-17,10.92339,1805700.88 +2011-08-16,11.1548,1805700.88 +2011-08-15,10.7921,1887498.6 +2011-08-14,10.1302,1888786.75 +2011-08-13,9.47024,1888786.75 +2011-08-12,9.46268,1888786.75 +2011-08-11,10.08821,1888786.75 +2011-08-10,9.95017,1888786.75 +2011-08-09,7.79996,1888786.75 +2011-08-08,7.9,1888786.75 +2011-08-07,6.5317,1888786.75 +2011-08-06,9.7403,1888786.75 +2011-08-05,10.7106,1888786.75 +2011-08-04,9.287,1888786.75 +2011-08-03,12.05,1888786.75 +2011-08-02,13.09628,1888786.75 +2011-08-01,13.3503,1807231.67 +2011-07-31,13.5365,1690895.75 +2011-07-30,13.5015,1690895.75 +2011-07-29,13.4901,1690895.75 +2011-07-28,13.891,1690895.75 +2011-07-27,13.88214,1690895.75 +2011-07-26,14.02979,1690895.75 +2011-07-25,13.98001,1690895.75 +2011-07-24,13.6904,1690895.75 +2011-07-23,13.69999,1690895.75 +2011-07-22,13.61,1690895.75 +2011-07-21,13.71982,1690895.75 +2011-07-20,13.86024,1690895.75 +2011-07-19,13.47051,1583738.97 +2011-07-18,13.16,1563028.0 +2011-07-17,13.719,1563028.0 +2011-07-16,13.81,1563028.0 +2011-07-15,13.99999,1563028.0 +2011-07-14,13.97,1563028.0 +2011-07-13,14.0276,1563028.0 +2011-07-12,14.20912,1563028.0 +2011-07-11,14.9,1563028.0 +2011-07-10,14.375,1563028.0 +2011-07-09,14.31399,1563028.0 +2011-07-08,14.77609,1563028.0 +2011-07-07,14.78367,1563028.0 +2011-07-06,12.90701,1406123.6 +2011-07-05,13.878,1379192.25 +2011-07-04,15.4407,1379192.25 +2011-07-03,15.39981,1379192.25 +2011-07-02,15.3705,1379192.25 +2011-07-01,16.10098,1379192.25 +2011-06-30,16.846,1379192.25 +2011-06-29,16.94991,1379192.25 +2011-06-28,16.75,1379192.25 +2011-06-27,16.45001,1379192.25 +2011-06-26,17.51001,1379192.25 +2011-06-26,17.51001,1379192.25 +2011-06-26,17.51001,1067618.83 +2011-06-26,17.51001,876954.5 +2011-06-26,17.51001,876954.5 +2011-06-26,17.51001,876954.5 +2011-06-26,17.51001,876954.5 +2011-06-19,16.85,876954.5 +2011-06-18,15.9635,876954.5 +2011-06-17,17.0,876954.5 +2011-06-16,19.5,876954.5 +2011-06-15,19.2804,688257.55 +2011-06-14,19.8,567269.5 +2011-06-13,18.5479,567269.5 +2011-06-12,14.75,567269.5 +2011-06-11,23.93,567269.5 +2011-06-10,28.9191,567269.5 +2011-06-09,29.91,567269.5 +2011-06-08,23.9999,567269.5 +2011-06-07,18.2605,567269.5 +2011-06-06,16.7,484311.13 +2011-06-05,18.966,434877.03 +2011-06-04,14.27,434877.03 +2011-06-03,10.6002,434877.03 +2011-06-02,9.6,434877.03 +2011-06-01,8.741,434877.03 +2011-05-31,8.8,434877.03 +2011-05-30,8.4483,434877.03 +2011-05-29,8.3001,434877.03 +2011-05-28,8.55,434877.03 +2011-05-27,8.7002,434877.03 +2011-05-26,8.2502,277625.18 +2011-05-25,7.4899,244112.48 +2011-05-24,7.1499,244112.48 +2011-05-23,6.6901,244112.48 +2011-05-22,6.14,244112.48 +2011-05-21,5.7999,244112.48 +2011-05-20,6.8051,244112.48 +2011-05-19,6.7002,244112.48 +2011-05-18,7.1911,162533.88 +2011-05-17,7.8974,157416.41 +2011-05-16,6.9899,157416.41 +2011-05-15,7.0022,157416.41 +2011-05-14,8.12011,157416.41 +2011-05-13,6.3201,157416.41 +2011-05-12,5.4898,157416.41 +2011-05-11,5.7499,157416.41 +2011-05-10,3.81,157416.41 +2011-05-09,3.8696,115463.61 +2011-05-08,3.641,109670.13 +2011-05-07,3.45,109670.13 +2011-05-06,3.333,109670.13 +2011-05-05,3.4013,109670.13 +2011-05-04,3.418,109670.13 +2011-05-03,3.2,109670.13 +2011-05-02,3.0988,109670.13 +2011-05-01,3.5,109670.13 +2011-04-30,2.879,107653.75 +2011-04-29,2.211,92347.59 +2011-04-28,1.892,92347.59 +2011-04-27,1.781,92347.59 +2011-04-26,1.581,92347.59 +2011-04-25,1.631,92347.59 +2011-04-24,1.7999,92347.59 +2011-04-23,1.3911,92347.59 +2011-04-22,1.21,92347.59 +2011-04-21,1.14209,92347.59 +2011-04-20,1.181,92347.59 +2011-04-19,1.1618,92347.59 +2011-04-18,1.13888,89441.62 +2011-04-17,1.048,82345.64 +2011-04-16,0.9841,82345.64 +2011-04-15,1.0,82345.64 +2011-04-14,0.939,82345.64 +2011-04-13,0.86,82345.64 +2011-04-12,0.7787,82345.64 +2011-04-11,0.7369,82345.64 +2011-04-10,0.75,82345.64 +2011-04-09,0.74999,82345.64 +2011-04-08,0.7538,82345.64 +2011-04-07,0.748,82345.64 +2011-04-06,0.7477,82345.64 +2011-04-05,0.68,69942.47 +2011-04-04,0.78,68977.78 +2011-04-03,0.78199,68977.78 +2011-04-02,0.775,68977.78 +2011-04-01,0.78461,68977.78 +2011-03-31,0.7897,68977.78 +2011-03-30,0.7925,68977.78 +2011-03-29,0.7989,68977.78 +2011-03-28,0.82,68977.78 +2011-03-27,0.829,68977.78 +2011-03-26,0.8837,68977.78 +2011-03-25,0.86688,69603.35 +2011-03-24,0.832,76192.62 +2011-03-23,0.81,76192.62 +2011-03-22,0.75897,76192.62 +2011-03-21,0.76145,76192.62 +2011-03-20,0.763,76192.62 +2011-03-19,0.78,76192.62 +2011-03-18,0.8499,76192.62 +2011-03-17,0.845,76192.62 +2011-03-16,0.871,76192.62 +2011-03-15,0.8949,76192.62 +2011-03-14,0.89249,76192.62 +2011-03-13,0.90501,76192.62 +2011-03-12,0.88,76192.62 +2011-03-11,0.89,76192.62 +2011-03-10,0.86449,76192.62 +2011-03-09,0.85132,62671.83 +2011-03-08,0.88502,55589.52 +2011-03-07,0.87,55589.52 +2011-03-06,0.9098,55589.52 +2011-03-05,0.91,55589.52 +2011-03-04,0.92021,55589.52 +2011-03-03,0.9128,55589.52 +2011-03-02,0.92021,55589.52 +2011-03-01,0.8601,55589.52 +2011-02-28,0.89009,55589.52 +2011-02-27,0.958,44848.7 +2011-02-26,0.9112,36459.89 +2011-02-25,0.97,36459.89 +2011-02-24,0.93,36459.89 +2011-02-23,0.90999,36459.89 +2011-02-22,0.85,36459.89 +2011-02-21,0.8313,36459.89 +2011-02-20,0.94898,36459.89 +2011-02-19,0.8376,36459.89 +2011-02-18,1.031,34091.13 +2011-02-17,1.045,25997.88 +2011-02-16,1.05,25997.88 +2011-02-15,1.06,25997.88 +2011-02-14,1.04,25997.88 +2011-02-13,1.0511,25997.88 +2011-02-12,1.01,25997.88 +2011-02-11,0.98,25997.88 +2011-02-10,1.08,25997.88 +2011-02-09,0.905,25997.88 +2011-02-08,0.89,25001.51 +2011-02-07,0.89968,22012.38 +2011-02-06,0.92,22012.38 +2011-02-05,0.839,22012.38 +2011-02-04,0.72,22012.38 +2011-02-03,0.7218,22012.38 +2011-02-02,0.71,22012.38 +2011-02-01,0.5451,22012.38 +2011-01-31,0.47981,22012.38 +2011-01-30,0.445,22012.38 +2011-01-29,0.445,22012.38 +2011-01-28,0.4223,22012.38 +2011-01-27,0.4095,20537.8 +2011-01-26,0.41123,18437.64 +2011-01-25,0.4199,18437.64 +2011-01-24,0.4424,18437.64 +2011-01-23,0.4443,18437.64 +2011-01-22,0.41,18437.64 +2011-01-21,0.3899,18437.64 +2011-01-20,0.31299,18437.64 +2011-01-19,0.31299,18437.64 +2011-01-18,0.3495,18437.64 +2011-01-17,0.38679,18437.64 +2011-01-16,0.3994,18437.64 +2011-01-15,0.4,17202.93 +2011-01-14,0.3176,16307.42 +2011-01-13,0.31868,16307.42 +2011-01-12,0.3265,16307.42 +2011-01-11,0.32659,16307.42 +2011-01-10,0.32291,16307.42 +2011-01-09,0.32291,16307.42 +2011-01-08,0.3092,16307.42 +2011-01-07,0.2975,16307.42 +2011-01-06,0.2989,16307.42 +2011-01-05,0.29004,16307.42 +2011-01-04,0.29601,16307.42 +2011-01-03,0.29,15910.04 +2011-01-02,0.29459,14484.16 +2011-01-01,0.292,14484.16 +2010-12-31,0.3,14484.16 +2010-12-30,0.291,14484.16 +2010-12-29,0.271,14484.16 +2010-12-28,0.264,14484.16 +2010-12-27,0.251,14484.16 +2010-12-26,0.2499,14484.16 +2010-12-25,0.2475,14484.16 +2010-12-24,0.25,14484.16 +2010-12-23,0.248,14484.16 +2010-12-22,0.244,14484.16 +2010-12-21,0.26,12606.86 +2010-12-20,0.2401,12252.0 +2010-12-19,0.248,12252.0 +2010-12-18,0.2487,12252.0 +2010-12-17,0.249,12252.0 +2010-12-16,0.23801,12252.0 +2010-12-15,0.245,12252.0 +2010-12-14,0.2289,12252.0 +2010-12-13,0.2101,12252.0 +2010-12-12,0.208,12252.0 +2010-12-11,0.204,12252.0 +2010-12-10,0.19999,12252.0 +2010-12-09,0.226,8227.93 +2010-12-08,0.24,8078.2 +2010-12-07,0.1938,8078.2 +2010-12-06,0.225,8078.2 +2010-12-05,0.22,8078.2 +2010-12-04,0.255,8078.2 +2010-12-03,0.25,8078.2 +2010-12-02,0.228,8078.2 +2010-12-01,0.2095,8078.2 +2010-11-30,0.2299,7166.72 +2010-11-29,0.279,6866.9 +2010-11-28,0.283,6866.9 +2010-11-27,0.2844,6866.9 +2010-11-26,0.27899,6866.9 +2010-11-25,0.2825,6866.9 +2010-11-24,0.28295,6866.9 +2010-11-23,0.2825,6866.9 +2010-11-22,0.27679,6866.9 +2010-11-21,0.27631,6866.9 +2010-11-20,0.27999,6866.9 +2010-11-19,0.2683,6866.9 +2010-11-18,0.2221,4917.22 +2010-11-17,0.223,4536.35 +2010-11-16,0.2683,4536.35 +2010-11-15,0.27904,4536.35 +2010-11-14,0.276,4536.35 +2010-11-13,0.2799,4536.35 +2010-11-12,0.2289,4536.35 +2010-11-11,0.2299,4536.35 +2010-11-10,0.2101,4536.35 +2010-11-09,0.251,3670.91 +2010-11-08,0.3459,3091.74 +2010-11-07,0.46999,3091.74 +2010-11-06,0.262,3091.74 +2010-11-05,0.2101,3091.74 +2010-11-04,0.1988,3091.74 +2010-11-03,0.1938,3091.74 +2010-11-02,0.192,3091.74 +2010-11-01,0.1925,3091.74 +2010-10-31,0.194,3091.74 +2010-10-30,0.1876,2186.43 +2010-10-29,0.1799,2149.02 +2010-10-28,0.1845,2149.02 +2010-10-27,0.151,2149.02 +2010-10-26,0.133,2149.02 +2010-10-25,0.09009,2149.02 +2010-10-24,0.108,2149.02 +2010-10-23,0.108,2149.02 +2010-10-22,0.1015,2149.02 +2010-10-21,0.0972,1962.49 +2010-10-20,0.1,1378.03 +2010-10-19,0.1,1378.03 +2010-10-18,0.103,1378.03 +2010-10-17,0.102,1378.03 +2010-10-16,0.1,1378.03 +2010-10-15,0.1,1378.03 +2010-10-14,0.1045,1378.03 +2010-10-13,0.092,1378.03 +2010-10-12,0.094,1363.09 +2010-10-11,0.091,1318.67 +2010-10-10,0.093,1318.67 +2010-10-09,0.08411,1318.67 +2010-10-08,0.067,1318.67 +2010-10-07,0.06312,1318.67 +2010-10-06,0.06145,1318.67 +2010-10-05,0.06132,1318.67 +2010-10-04,0.06113,1318.67 +2010-10-03,0.06139,1318.67 +2010-10-02,0.06188,1318.67 +2010-10-01,0.06189,1318.67 +2010-09-30,0.06174,1318.67 +2010-09-29,0.062,1318.67 +2010-09-28,0.06196,978.33 +2010-09-27,0.06205,917.83 +2010-09-26,0.06204,917.83 +2010-09-25,0.06222,917.83 +2010-09-24,0.06209,917.83 +2010-09-23,0.0621,917.83 +2010-09-22,0.0624,917.83 +2010-09-21,0.06309,917.83 +2010-09-20,0.0621,917.83 +2010-09-19,0.06091,893.32 +2010-09-18,0.059,712.88 +2010-09-17,0.06089,712.88 +2010-09-16,0.0618,712.88 +2010-09-15,0.0625,712.88 +2010-09-14,0.062,712.88 +2010-09-13,0.06199,712.88 +2010-09-12,0.0621,712.88 +2010-09-11,0.0619,712.88 +2010-09-10,0.061,712.88 +2010-09-09,0.0611,712.88 +2010-09-08,0.061,696.61 +2010-09-07,0.0616,623.39 +2010-09-06,0.0627,623.39 +2010-09-05,0.06245,623.39 +2010-09-04,0.06125,623.39 +2010-09-03,0.061,623.39 +2010-09-02,0.061,623.39 +2010-09-01,0.062,623.39 +2010-08-31,0.06411,623.39 +2010-08-30,0.0646,623.39 +2010-08-29,0.0647,623.39 +2010-08-28,0.065,623.39 +2010-08-27,0.064,623.39 +2010-08-26,0.06482,516.56 +2010-08-25,0.06499,511.77 +2010-08-24,0.06491,511.77 +2010-08-23,0.066,511.77 +2010-08-22,0.065,511.77 +2010-08-21,0.0655,511.77 +2010-08-20,0.0667,511.77 +2010-08-19,0.0679,511.77 +2010-08-18,0.06999,511.77 +2010-08-17,0.0655,511.77 +2010-08-16,0.06319,511.77 +2010-08-15,0.067,389.94 +2010-08-14,0.0655,352.16 +2010-08-13,0.0665,352.16 +2010-08-12,0.068,352.16 +2010-08-11,0.06,352.16 +2010-08-10,0.068,352.16 +2010-08-09,0.06091,352.16 +2010-08-08,0.059,352.16 +2010-08-07,0.0608,352.16 +2010-08-06,0.062,352.16 +2010-08-05,0.0581,259.07 +2010-08-04,0.06229,244.21 +2010-08-03,0.06,244.21 +2010-08-02,0.0627,244.21 +2010-08-01,0.061,244.21 +2010-07-31,0.065,244.21 +2010-07-30,0.0698,244.21 +2010-07-29,0.0597,244.21 +2010-07-28,0.06,244.21 +2010-07-27,0.053,239.31 +2010-07-26,0.05,181.54 +2010-07-25,0.05545,181.54 +2010-07-24,0.06161,181.54 +2010-07-23,0.0505,181.54 diff --git a/stability/fit.py b/stability/fit.py new file mode 100644 index 0000000..7c17ede --- /dev/null +++ b/stability/fit.py @@ -0,0 +1,122 @@ +import spread +import math +import random + +o = spread.declutter(spread.load('diff_and_price.csv')) + +diffs = [float(q[2]) for q in o][::-1] +prices = [float(q[1]) for q in o][::-1] + + +def simple_estimator(fac): + o = [1] + for i in range(1, len(diffs)): + o.append(o[-1] * diffs[i] * 1.0 / diffs[i-1] / fac) + return o + + +def minimax_estimator(fac): + o = [1] + for i in range(1, len(diffs)): + if diffs[i] * 1.0 / diffs[i-1] > fac: + o.append(o[-1] * diffs[i] * 1.0 / diffs[i-1] / fac) + elif diffs[i] > diffs[i-1]: + o.append(o[-1]) + else: + o.append(o[-1] * diffs[i] * 1.0 / diffs[i-1]) + return o + + +def diff_estimator(fac, dw, mf): + o = [1] + derivs = [0] * 14 + for i in range(14, len(diffs)): + derivs.append(diffs[i] - diffs[i - 14]) + for i in range(0, 14): + derivs[i] = derivs[14] + vals = [max(diffs[i] + derivs[i] * dw, diffs[i] * mf) for i in range(len(diffs))] + for i in range(1, len(diffs)): + if vals[i] * 1.0 / vals[i-1] > fac: + o.append(o[-1] * vals[i] * 1.0 / vals[i-1] / fac) + elif vals[i] > vals[i-1]: + o.append(o[-1]) + else: + o.append(o[-1] * vals[i] * 1.0 / vals[i-1]) + return o + + +def ndiff_estimator(*args): + fac, dws, mf = args[0], args[1:-1], args[-1] + o = [1] + ds = [diffs] + for dw in dws: + derivs = [0] * 14 + for i in range(14, len(diffs)): + derivs.append(ds[-1][i] - ds[-1][i - 14]) + for i in range(0, 14): + derivs[i] = derivs[14] + ds.append(derivs) + vals = [] + for i in range(len(diffs)): + q = ds[0][i] + sum([ds[j+1][i] * dws[j] for j in range(len(dws))]) + vals.append(max(q, ds[0][i] * mf)) + for i in range(1, len(diffs)): + if vals[i] * 1.0 / vals[i-1] > fac: + o.append(o[-1] * vals[i] * 1.0 / vals[i-1] / fac) + elif vals[i] > vals[i-1]: + o.append(o[-1]) + else: + o.append(o[-1] * vals[i] * 1.0 / vals[i-1]) + return o + + +def dual_threshold_estimator(fac1, fac2, dmul): + o = [1] + derivs = [0] * 14 + for i in range(14, len(diffs)): + derivs.append(diffs[i] - diffs[i - 14]) + for i in range(0, 14): + derivs[i] = derivs[14] + for i in range(1, len(diffs)): + if diffs[i] * 1.0 / diffs[i-1] > fac1 and derivs[i] * 1.0 / derivs[i-1] > fac2: + o.append(o[-1] * diffs[i] * 1.0 / diffs[i-1] / fac1 * (1 + (derivs[i] / derivs[i-1] - fac2) * dmul)) + elif diffs[i] > diffs[i-1]: + o.append(o[-1]) + else: + o.append(o[-1] * diffs[i] * 1.0 / diffs[i-1]) + return o + + +def evaluate_estimates(estimates, crossvalidate=False): + sz = len(prices) if crossvalidate else 780 + sqdiffsum = 0 + # compute average + tot = 0 + for i in range(sz): + tot += math.log(prices[i] / estimates[i]) + avg = 2.718281828459 ** (tot * 1.0 / sz) + for i in range(1, sz): + sqdiffsum += math.log(prices[i] / estimates[i] / avg) ** 2 + return sqdiffsum + + +# Simulated annealing optimizer +def optimize(producer, floors, ceilings, rate=0.7): + vals = [f*0.5+c*0.5 for f, c in zip(floors, ceilings)] + y = evaluate_estimates(producer(*vals)) + for i in range(1, 5000): + stepsizes = [(f*0.5-c*0.5) / i**rate for f, c in zip(floors, ceilings)] + steps = [(random.random() * 2 - 1) * s for s in stepsizes] + newvals = [max(mi, min(ma, v+s)) for v, s, mi, ma in zip(vals, steps, floors, ceilings)] + newy = evaluate_estimates(producer(*newvals)) + if newy < y: + vals = newvals + y = newy + if not i % 1000: + print i, vals, y + + return vals + + +def score(producer, *vals): + return evaluate_estimates(producer(*vals), True) diff --git a/stability/spread.py b/stability/spread.py new file mode 100644 index 0000000..bfa235c --- /dev/null +++ b/stability/spread.py @@ -0,0 +1,460 @@ +import copy, re +from sets import Set +# NOTE THAT ALL FUNCTIONS HERE WORK BY RETURNING A NEW ARRAY, THERE ARE NO IN-PLACE MODIFICATION METHODS +# ALSO KEEP IN MIND THAT COLUMNS AND ROW INDICES START FROM ZERO (ie. column A -> 0, E -> 4, Z -> 25, etc) +# Scans a CSV line, keeping track of separators and quotes +def scanline(ln,sp=','): + arr = [] + inq = False + ind = 0 + buff = "" + while ind < len(ln): + if ln[ind] == '"': + inq = not inq + ind += 1 + elif ln[ind] == '\\': + buff += ln[ind+1] + ind += 2 + elif ln[ind] == sp and not inq: + arr.append(buff) + buff = "" + ind += 1 + else: + buff += ln[ind] + ind += 1 + arr.append(buff) + return arr +# Load a CSV into a 2D array, automatically filling in unevenly wide rows to make the array square +def load(f,sp=','): + array = [scanline(x,sp) for x in open(f,'r').readlines()] + maxlen = 0 + for i in range(len(array)): + if len(array[i]) > maxlen: maxlen = len(array[i]) + for i in range(len(array)): + if len(array[i]) < maxlen: array[i] += [''] * (maxlen - len(array[i])) + return array +# Apply a Porter stemmer to every cell in a given range of cols in an array (calling stem with just a list and no cols argument stems _every_ cell) +# Example outputs: manage, management, manager, managing -> manag; pony, ponies -> poni; reincarnate, reincarnated, reincarnation -> reincarn +def stem(li,cols=0): + if cols == 0: cols = range(len(li[0])) + import porter + pstemmer = porter.PorterStemmer() + newlist = copy.deepcopy(li) + for i in range(len(li)): + for j in cols: + string = str(li[i][j]) + for ch in "'"+'"+[]?!\n': string = string.replace(ch,'') + words = string.split(' ') + newlist[i][j] = ' '.join([pstemmer.stem(x.strip().lower(),0,len(x.strip())-1) for x in words]) + return newlist +# Is a string a number? +def isnumber(s): + t = re.findall('^-?[0-9,]*\.[0-9,]*$',s) + return len(t) > 0 + +# Declutters (removes special characters, numerifies numbers) every cell, rules same as those for stem(li,cols=0) +def declutter(li,cols=0): + if cols == 0: cols = range(len(li[0])) + newlist = copy.deepcopy(li) + for i in range(len(li)): + for j in cols: + string = str(li[i][j]) + for ch in "'"+'"+[]?!\n': string = string.replace(ch,'') + words = string.split(' ') + newlist[i][j] = ' '.join([x.strip().lower() for x in words]) + if isnumber(newlist[i][j]): + newlist[i][j] = float(newlist[i][j]) + return newlist +# Generate a list of individual words occurring in a given column in a given array; useful for generating source lists to do n-grams from +def wordlist(li,col): + wlist = [] + for i in range(len(li)): + words = li[i][col].split(' ') + for w in words: + if w not in wlist: wlist.append(w) + return wlist +# Generates a list of phrases (complete cell entries) +def phraselist(li,col): + wlist = [] + for i in range(len(li)): + phrase= li[i][col] + if phrase not in wlist: wlist.append(phrase) + return wlist +# Retrieve just a few columns from a given array to make a smaller (narrower) array +def cols(li,cols): + result = [] + for i in range(len(li)): + newline = [] + for c in cols: + if c >= 0: newline.append(li[i][c]) + else: newline.append(1) + result.append(newline) + return result +# Combine two possibly unsorted arrays matching rows by heading in headingcol1 in li1 and headingcol2 in li2 +# setting linclusive = True makes sure every row in li1 makes it into the output, same with rinclusive and li2 +# Recommended to do some kind of sort after splice is done +def splice(li1,li2,headingcol1,headingcol2,linclusive=False,rinclusive=False): + s1 = sorted(li1,key=lambda x:x[headingcol1],reverse=True) + s2 = sorted(li2,key=lambda x:x[headingcol2],reverse=True) + l1 = len(s1[0]) + l2 = len(s2[0]) + ind1 = 0 + ind2 = 0 + output = [] + while ind1 < len(s1) and ind2 < len(s2): + if cmp(s2[ind2][headingcol2],s1[ind1][headingcol1]) == 1: + if rinclusive: output.append([s2[ind2][headingcol2]] + [''] * (l1-1) + s2[ind2][:headingcol2] + s2[ind2][headingcol2 + 1:]) + ind2 += 1 + elif cmp(s2[ind2][headingcol2],s1[ind1][headingcol1]) == -1: + if linclusive: output.append([s1[ind1][headingcol1]] + s1[ind1][:headingcol1] + s1[ind1][headingcol1 + 1:] + [''] * (l2-1)) + ind1 += 1 + else: + output.append([s1[ind1][headingcol1]] + s1[ind1][:headingcol1] + s1[ind1][headingcol1 + 1:] + s2[ind2][:headingcol2] + s2[ind2][headingcol2 + 1:]) + ind1, ind2 = ind1 + 1, ind2 + 1 + while ind1 < len(s1) and linclusive: + output.append([s1[ind1][headingcol1]] + s1[ind1][:headingcol1] + s1[ind1][headingcol1 + 1:] + [''] * l2) + ind1 += 1 + while ind2 < len(s2) and rinclusive: + output.append([s2[ind2][headingcol2]] + [''] * l1 + s2[ind2][:headingcol2] + s2[ind2][headingcol2 + 1:]) + ind2 += 1 + return output +# Creates a wordlist sorted according to function f taken of an array with the results in the addcols in order +# eg. sorted_wordlist with addcols = [2,4,6], row is 1 2 4 8 16 32 64, f=lambda x:x[2]+x[1]+1.01*x[0] returns sorting key 84.04 +def sorted_wordlist(li,wcol,addcols,f=lambda x:x[1],rev=True): + return [x[0] for x in sorted(onegrams(li,wcol,addcols),key=f,reverse=rev)] +# Utility function, used by twograms, threegrams and fourgrams +def compose(arg): + return ' '.join(sorted(list(Set(arg)))) +# Calculate a total sum for every desired column for different exact matches in wcol, column -1 is implied to be 1 for every row +# for example, consider the array +# dog 20 3 +# dog house 15 28 +# cat 25 31 +# cat 10 7 +# dog 40 0 +# house 10 14 +# Doing pivot(li,0,[1,-1]) gives you the list: +# dog 60 2 +# dog house 15 1 +# cat 35 2 +# house 10 1 +# wlist allows you to restrict the table to a given wordlist +def pivot(li, wcol, addcols,wlist=0,sortkey=lambda x:1): + if wlist == 0: wlist = phraselist(li,wcol) + result = {} + for i in range(len(wlist)): + result[wlist[i]] = [0] * len(addcols) + for i in range(len(li)): + nums = [] + for ac in addcols: + if ac >= 0: + num = str(li[i][ac]).replace(',','').replace(' ','') + if num == '': num = 0 + elif num[-1] == '%': num = float(num[:-1] * 0.01) + else: num = float(num) + else: num = 1 + nums.append(num) + if li[i][wcol] in result: result[li[i][wcol]] = [pair[0] + pair[1] for pair in zip(result[li[i][wcol]],nums)] + array = [] + for word in result.keys(): + array.append([word] + result[word]) + return sorted(array,key=sortkey,reverse=True) +# Similar to a pivot table but looks at individual keywords. The example list above will return with onegrams(li,0,[1,2]): +# dog 75 3 +# cat 35 2 +# house 25 2 +def onegrams(li, wcol, addcols,wlist=0,sortkey=lambda x: 1): + if wlist == 0: wlist = wordlist(li,wcol) + result = {} + for i in range(len(wlist)): + result[wlist[i]] = [0] * len(addcols) + for i in range(len(li)): + words = [x.strip() for x in li[i][wcol].split(' ')] + nums = [] + for ac in addcols: + if ac >= 0: + num = str(li[i][ac]).replace(',','').replace(' ','') + if num == '': num = 0 + elif num[-1] == '%': num = float(num[:-1] * 0.01) + else: num = float(num) + else: num = 1 + nums.append(num) + for i in range(len(words)): + if words[i] in result: result[words[i]] = [pair[0] + pair[1] for pair in zip(result[words[i]],nums)] + array = [] + for word in result.keys(): + array.append([word] + result[word]) + return sorted(array,key=sortkey,reverse=True) +# Calculate a total sum for every column in addcols and for every word pair in wcol +# words do not need to be beside each other or in any particular order, so "buy a dog house", "good house for dog owners", "dog in my house" all go under "dog house" +def twograms(li,wcol,addcols,wlist=0,sortkey=lambda x:1,allindices=False): + if wlist == 0: wlist = wordlist(li,wcol) + result = {} + if allindices: + for i in range(len(wlist)): + for j in range(len(wlist)): + if i != j: result[compose([wlist[i],wlist[j]])] = [0] * len(addcols) + for i in range(len(li)): + if i % int(len(li)/10) == (int(len(li)/10) - 1): print "Two grams: " + str(i) + " / " + str(len(li)) + words = [x.strip() for x in li[i][wcol].split(' ')] + nums = [] + for ac in addcols: + if ac >= 0: + num = str(li[i][ac]).replace(',','').replace(' ','') + if num == '': num = 0 + elif num[-1] == '%': num = float(num[:-1]) * 0.01 + else: num = float(num) + else: num = 1 + nums.append(num) + for i in range(len(words)): + if words[i] in wlist: + for j in range(i+1,len(words)): + if words[j] in wlist: + comb = compose([words[i],words[j]]) + if comb in result: result[comb] = [pair[0] + pair[1] for pair in zip(result[comb],nums)] + elif allindices == False: result[comb] = nums + array = [] + for words in result.keys(): + array.append([words] + result[words]) + return sorted(array,key=sortkey,reverse=True) +# Calculate a total sum for every column in addcols and for every word triplet in wcol (do not need to be beside each other or in any particular order) +# setting allindices to True slows down the calculation a lot but gives you a CSV with all possible combinations of words, making it convenient for +# working with the same word list on different data +def threegrams(li,wcol,addcols,wlist=0,sortkey=lambda x:1,allindices=False): + if wlist == 0: wlist = wordlist(li,wcol) + result = {} + if allindices: + for i in range(len(wlist)): + for j in range(len(wlist)): + for k in range(len(wlist)): + if i != j and i != k and j != k: result[compose([wlist[i],wlist[j],wlist[k]])] = [0] * len(addcols) + for i in range(len(li)): + if i % int(len(li)/10) == (int(len(li)/10) - 1): print "Three grams: " + str(i) + " / " + str(len(li)) + words = [x.strip() for x in li[i][wcol].split(' ')] + nums = [] + for ac in addcols: + if ac >= 0: + num = str(li[i][ac]).replace(',','').replace(' ','') + if num == '': num = 0 + elif num[-1] == '%': num = float(num[:-1]) * 0.01 + else: num = float(num) + else: num = 1 + nums.append(num) + for i in range(len(words)): + if words[i] in wlist: + for j in range(i+1,len(words)): + if words[j] in wlist: + for k in range(j+1,len(words)): + if words[k] in wlist: + comb = compose([words[i],words[j],words[k]]) + if comb in result: + result[comb] = [pair[0] + pair[1] for pair in zip(result[comb],nums)] + elif allindices == False: result[comb] = nums + array = [] + for words in result.keys(): + array.append([words] + result[words]) + return sorted(array,key=sortkey,reverse=True) +# Calculate a total sum for every column in addcols and for every word quadruplet in wcol +def fourgrams(li,wcol,addcols,wlist=0,sortkey=lambda x:1): + if wlist == 0: wlist = wordlist(li,wcol) + result = {} + for i in range(len(li)): + if i % int(len(li)/10) == (int(len(li)/10) - 1): print "Four grams: " + str(i) + " / " + str(len(li)) + words = [x.strip() for x in li[i][wcol].split(' ')] + nums = [] + for ac in addcols: + if ac >= 0: + num = str(li[i][ac]).replace(',','').replace(' ','') + if num == '': num = 0 + elif num[-1] == '%': num = float(num[:-1]) * 0.01 + else: num = float(num) + else: num = 1 + nums.append(num) + for i in range(len(words)): + if words[i] in wlist: + for j in range(i+1,len(words)): + if words[j] in wlist: + for k in range(j+1,len(words)): + if words[j] in wlist: + for l in range(k+1,len(words)): + if words[l] in wlist: + comb = compose([words[i],words[j],words[k],words[l]]) + if comb in result: + result[comb] = [pair[0] + pair[1] for pair in zip(result[comb],nums)] + else: result[comb] = nums + + array = [] + for words in result.keys(): + array.append([words] + result[words]) + return sorted(array,key=sortkey,reverse=True) +# Filters array, returning only the rows where column wcol of that row contains the query keywords (keywords can appear in any order) +# This and the other filters are useful for taking a list of entries and creating a list of only valid entries according to some validity characteristic +# eg: +# dog house, 15 +# cat, 18 +# dog, 33 +# filter(li,0,'dog'): +# dog house, 15 +# dog, 33 +def filter(li,wcol,query): + result = [] + for i in range(len(li)): + words = [x.strip() for x in li[i][wcol].split(' ')] + inlist = True + queryarray = query.split(' ') + if queryarray == ['']: queryarray = [] + for w in queryarray: + if w not in words: inlist = False + if queryarray == ['*']: inlist = len(li[i][wcol]) > 0 + if inlist: result.append(li[i]) + return result +# Filters array, requiring column wcol to exactly match query +def phrasefilter(li,wcol,query): + result = [] + for i in range(len(li)): + if li[i][wcol] == query: result.append(li[i]) + return result +# Filters array, requiring function func taken of the row to return True (or 1) +def funcfilter(li,func): + result = [] + for i in range(len(li)): + if func(li[i]): result.append(li[i]) + return result +# Adds up columns in addcols for a query matching keyfilter(li,wcol,query); can also be thought of as doing a single n-keyword match +# eg: +# dog, 25 +# cat, 15 +# dog, 75 +# dog, 10 +# horse, 55 +# cat, 7 +# search(li,0,[1],'dog') gives ['dog',110] +def search(li,wcol,addcols,query): + result = [0] * len(addcols) + for i in range(len(li)): + words = [x.strip() for x in li[i][wcol].split(' ')] + nums = [] + for ac in addcols: + if ac >= 0: + num = str(li[i][ac]).replace(',','').replace(' ','') + if num == '': num = 0 + elif num[-1] == '%': num = float(num[:-1] * 0.01) + else: num = float(num) + else: num = 1 + nums.append(num) + inlist = True + queryarray = query.split(' ') + if queryarray == ['']: queryarray = [] + for w in queryarray: + if w not in words: inlist = False + if queryarray == ['*']: inlist = len(li[i][wcol]) > 0 + if inlist: + result = [pair[0] + pair[1] for pair in zip(result,nums)] + return [query] + result +# Print a CSV from an array to stdout +def tochars(array,sp=','): + string = "" + for line in array: string += sp.join([str(x) for x in line]) + '\n' + return string[:-1] +# Save an array to CSV +def save(f,array,sp=','): + writeto = open(f,'w') + writeto.write(tochars(array,sp)) + writeto.close() +# Compares keywords by two different parameters from two different lists. For example, li1 can be a list of how much money is spent (on addcol1) on a particular combination of keywords (on keycol1) and li2 can be a list of upgraded accounts with the search query they came from on keycol2, and addcol 2 can be left blank to default to -1 (each row is worth one point). Fourth column is statistical significance. +# Remember that you may have to filter the list yourself first +# Arguments: +# grams = 1 for single keywords, 2 for pairs, 3 for triplets and 4 for quadruplets +# li1, li2 = your two lists +# keycol1, keycol2 = where the keywords are located in those two lists +# addcol1, addcol2 = the columns of what you want to add up, eg. cost (set to -1 or leave blank to make it add 1 for each row) +# sortkey = function to sort results by (highest first) +# usestem = stem keywords +# sigtable = add ratio and significance to table +# invertratio = set ratio column to col1/col2 instead of col2/col1 +# preformatted = li1 and li2 are already properly formatted +# justpreformat = convert li1 and li2 into twocolumns for comparison but don't go all the way +# wordlimit = limit search to some more common keywords for speedup purposes +# Example: list of customers, some upgraded, with originating keywords, and a list of how much you're paying for each search phrase +# +# customers.csv: +# Name, Keyword, Status +# Bob Jones, spreadsheet csv software, upgraded +# Matt Bones, csv python utils, free +# Army Drones, free spreadsheet, free +# Glenn Mitt, csv software, upgraded +# Pat Submitt, python utils software, upgraded +# Shawn Wit, python spreadsheet program, upgraded +# +# costs.csv: +# csv software, useless, and, irrelevant, data, 5.00, blah, blah +# python spreadsheet, useless, and, irrelevant, data, 2.50, blah, blah +# spreadsheet utils, useless, and, irrelevant, data, 10.00, blah, blah +# csv utils, useless, and, irrelevant, data, 1.50, blah, blah +# +# Steps: +# 1. import spread (if not imported already) +# 2. upgrades = spread.filter(spread.load('customers.csv'),2,'upgraded') +# 3. costs = spread.load('costs.csv') +# 4. res = compare(1,costs,upgrades,0,1,5,invertratio=True) +# 5. spread.save('saved.csv',res) +# +# Res should look like: +# +# Keyword, Column 1, Column 2, Ratio, Significance +# spreadsheet, 12.50, 2, 6.25, -0.389 +# utils, 11.50, 1, 11.50, -0.913 +# csv, 7.50, 2, 3.75, 0.335 +# python, 2.50, 2, 1.25, 2.031 +# +# Or, if desired, you can: +# i1,i2 = compare(1,costs,upgrades,0,1,5,justpreformat=True) +# res1 = compare(1,i1,i2,0,1,5,invertratio=True,preformatted=True) +# res2 = compare(2,i1,i2,0,1,5,invertratio=True,preformatted=True) +# res3 = compare(3,i1,i2,0,1,5,invertratio=True,preformatted=True) +# res4 = compare(4,i1,i2,0,1,5,invertratio=True,preformatted=True) +# +# Note that significance is calculated based on col2/col1 regardless of invertratio, since getting 0 upgrades when you should have gotten 2 is not that unlikely, but calculating significance based on col1/col2 would give you infinity as infinity is infinitely far away from 0.5. +def compare(grams,li1,li2,keycol1,keycol2,addcol1=-1,addcol2=-1,sortkey=lambda x:x[1],usestem=True,sigtable=True,invertratio=False,preformatted=False,justpreformat=False,wordlimit=0): + gramfuncs = [0,onegrams,twograms,threegrams,fourgrams] + if preformatted == False: + s1 = declutter(cols(li1,[keycol1,addcol1]),[1]) + print "Done decluttering/stemming: 1/4" + s2 = declutter(cols(li2,[keycol2,addcol2]),[1]) + print "Done decluttering/stemming: 2/4" + s1 = stem(s1,[0]) if usestem else declutter(s1,[0]) + print "Done decluttering/stemming: 3/4" + s2 = stem(s2,[0]) if usestem else declutter(s2,[0]) + print "Done decluttering/stemming: 4/4" + else: s1,s2 = li1,li2 + print "Printing sample of list 1" + print s1[:10] + print "Printing sample of list 2" + print s2[:10] + if justpreformat: return s1,s2 + while type(s1[0][1]) is str: s1.pop(0) + while type(s2[0][1]) is str: s2.pop(0) + print "Cleaned invalid rows" + wl = sorted_wordlist(s1,0,[1]) + if wl.count('') > 0: blank = wl.pop(wl.index('')) + print "Base wordlist length: " + str(len(wl)) + " ; Top ten: " + str(wl[:10]) + if wordlimit > 0 and wordlimit < len(wl): + print "Shortening to " + str(wordlimit) + wl = wl[:wordlimit] + res1 = gramfuncs[grams](s1,0,[1],wl) + print "Done search: 1/2" + res2 = gramfuncs[grams](s2,0,[1],wl) + print "Done search: 2/2" + comb = sorted(splice(res1,res2,0,0),key=sortkey,reverse=True) + if sigtable: + tot1 = search(s1,0,[1],'') + tot2 = search(s2,0,[1],'') + ev = tot2[1]*1.0/tot1[1] + print "Totals: " + str(tot1[1]) + ", " + str(tot2[1]) + for i in range(len(comb)): + comb[i].append(comb[i][2 - invertratio]*1.0/(comb[i][1 + invertratio] + 0.000001)) + comb[i].append((comb[i][2] - ev * comb[i][1])*1.0/(ev * comb[i][1] + 0.000001) ** 0.5) + comb = [['Keyword','Column 1','Column 2','Ratio','Significance']] + comb + else: comb = [['Keyword','Column 1','Column 2']] + comb + print "Done" + return comb