Last active
October 5, 2016 05:04
-
-
Save claytantor/ce46891693705ac463f9ac2e89a7a203 to your computer and use it in GitHub Desktop.
chart a stock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib inline | |
import matplotlib | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from pymongo import MongoClient | |
from bson.objectid import ObjectId | |
import dateutil.parser | |
start_date_str = "2015-04-25T07:00:00Z" | |
start_date = dateutil.parser.parse(start_date_str) | |
end_date_str = "2015-08-25T07:00:00Z" | |
end_date = dateutil.parser.parse(end_date_str) | |
client = MongoClient("mongodb://192.168.0.10:27017") | |
db = client.dronzets | |
cursor = db.daily_measures.find({"code" : "AAPL_CLOSE_ARD", | |
"date": { "$gte": start_date, "$lt": end_date } | |
}) | |
days = [] | |
prices = [] | |
for document in cursor: | |
days.append(document['date']) | |
prices.append(document['value']) | |
plt.plot(days, prices) | |
plt.xlabel('Time') | |
plt.ylabel('Price ($)') | |
plt.title('AAPL_CLOSE_ARD') | |
plt.grid(True) | |
N = 2 | |
params = plt.gcf() | |
plSize = params.get_size_inches() | |
params.set_size_inches( (plSize[0]*N, plSize[1]) ) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment