diff --git a/etc/requirements_dev.txt b/etc/requirements_dev.txt index 0d33ec34..819b77d5 100644 --- a/etc/requirements_dev.txt +++ b/etc/requirements_dev.txt @@ -25,3 +25,5 @@ tornado==3.1 pyparsing==2.0.1 statsmodels==0.4.3 patsy==0.1.0 + +Markdown==2.3.1 diff --git a/tests/risk/AnswerKeyAnnotations.ipynb b/tests/risk/AnswerKeyAnnotations.ipynb new file mode 100644 index 00000000..0ecadebf --- /dev/null +++ b/tests/risk/AnswerKeyAnnotations.ipynb @@ -0,0 +1,49 @@ +{ + "metadata": { + "name": "AnswerKeyAnnotations" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": true, + "input": [ + "#\n", + "# Copyright 2013 Quantopian, Inc.\n", + "#\n", + "# Licensed under the Apache License, Version 2.0 (the \"License\");\n", + "# you may not use this file except in compliance with the License.\n", + "# You may obtain a copy of the License at\n", + "#\n", + "# http://www.apache.org/licenses/LICENSE-2.0\n", + "#\n", + "# Unless required by applicable law or agreed to in writing, software\n", + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", + "# See the License for the specific language governing permissions and\n", + "# limitations under the License.\n", + "\n", + "from annotation_utils import Markdown\n", + "import answer_key" + ], + "language": "python", + "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Markdown(\"\"\"\n", + "Download link for latest answer key: [{latest_answer_key_url}]({latest_answer_key_url})\n", + "\"\"\".format(latest_answer_key_url=answer_key.LATEST_ANSWER_KEY_URL))" + ], + "language": "python", + "outputs": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/risk/annotation_utils.py b/tests/risk/annotation_utils.py new file mode 100644 index 00000000..fedf0024 --- /dev/null +++ b/tests/risk/annotation_utils.py @@ -0,0 +1,27 @@ +# +# Copyright 2013 Quantopian, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import markdown + + +# Inspired by: +# http://catherinedevlin.blogspot.com/2013/06/\ +# easy-html-output-in-ipython-notebook.html +class Markdown(str): + """ + Markdown wrapper to allow dynamic Markdown cells. + """ + def _repr_html_(self): + return markdown.markdown(self) diff --git a/tests/risk/answer_key.py b/tests/risk/answer_key.py index 6de07485..8be0a766 100644 --- a/tests/risk/answer_key.py +++ b/tests/risk/answer_key.py @@ -44,6 +44,9 @@ ANSWER_KEY_DL_TEMPLATE = """ https://s3.amazonaws.com/zipline-test-data/risk/{md5}/risk-answer-key.xlsx """.strip() +LATEST_ANSWER_KEY_URL = ANSWER_KEY_DL_TEMPLATE.format( + md5=ANSWER_KEY_CHECKSUMS[-1]) + def answer_key_signature(): with open(ANSWER_KEY_PATH, 'r') as f: