Skip to content

Instantly share code, notes, and snippets.

@claytantor
Last active October 5, 2016 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claytantor/ce46891693705ac463f9ac2e89a7a203 to your computer and use it in GitHub Desktop.
Save claytantor/ce46891693705ac463f9ac2e89a7a203 to your computer and use it in GitHub Desktop.
chart a stock
%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