@@ -0,0 +1,2150 @@
+from pymongo import MongoClient%0Afrom bitcoin_price_prediction.bayesian_regression import *%0A%0Aclient = MongoClient()%0Adatabase = client%5B'okcoindb'%5D%0Acollection = database%5B'historical_data'%5D%0A%0A# Retrieve price, v_ask, and v_bid data points from the database.%0Aprices = %5B%5D%0Av_ask = %5B%5D%0Av_bid = %5B%5D%0Anum_points = 777600%0Afor doc in collection.find().limit(num_points):%0A    prices.append(doc%5B'price'%5D)%0A    v_ask.append(doc%5B'v_ask'%5D)%0A    v_bid.append(doc%5B'v_bid'%5D)%0A%0A# Divide prices into three, roughly equal sized, periods:%0A# prices1, prices2, and prices3.%0A%5Bprices1, prices2, prices3%5D = np.array_split(prices, 3)%0A%0A# Divide v_bid into three, roughly equal sized, periods:%0A# v_bid1, v_bid2, and v_bid3.%0A%5Bv_bid1, v_bid2, v_bid3%5D = np.array_split(v_bid, 3)%0A%0A# Divide v_ask into three, roughly equal sized, periods:%0A# v_ask1, v_ask2, and v_ask3.%0A%5Bv_ask1, v_ask2, v_ask3%5D = np.array_split(v_ask, 3)%0A%0A# Use the first time period (prices1) to generate all possible time series of%0A# appropriate length (180, 360, and 720).%0Atimeseries180 = generate_timeseries(prices1, 180)%0Atimeseries360 = generate_timeseries(prices1, 360)%0Atimeseries720 = generate_timeseries(prices1, 720)%0A%0A# Cluster timeseries180 in 100 clusters using k-means, return the cluster%0A# centers (centers180), and choose the 20 most effective centers (s1).%0Acenters180 = find_cluster_centers(timeseries180, 100)%0As1 = choose_effective_centers(centers180, 20)%0A%0Acenters360 = find_cluster_centers(timeseries360, 100)%0As2 = choose_effective_centers(centers360, 20)%0A%0Acenters720 = find_cluster_centers(timeseries720, 100)%0As3 = choose_effective_centers(centers720, 20)%0A%0A# Use the second time period to generate the independent and dependent%0A# variables in the linear regression model:%0A# %CE%94p = w0 + w1 * %CE%94p1 + w2 * %CE%94p2 + w3 * %CE%94p3 + w4 * r.%0ADpi_r, Dp = linear_regression_vars(prices2, v_bid2, v_ask2, s1, s2, s3)%0A%0A# Find the parameter values w (w0, w1, w2, w3, w4).%0Aw = find_parameters_w(Dpi_r, Dp)%0A%0A# Predict average price changes over the third time period.%0Adps = predict_dps(prices3, v_bid3, v_ask3, s1, s2, s3, w)%0A%0A# What's your 'Fuck You Money' number?%0Abank_balance = evaluate_performance(prices3, dps, t=0.0001, step=1)%0A

Add an example.