{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [], "source": [ "from datetime import date\n", "from datetime import timedelta\n", "from gs_quant.datetime.relative_date import RelativeDate\n", "from gs_quant.markets import PricingContext\n", "from gs_quant.session import GsSession, Environment" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "is_executing": false, "name": "#%%\n" } }, "outputs": [], "source": [ "# external users should substitute their client id and secret; please skip this step if using internal jupyterh\n", "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('read_product_data',))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/plain": [ "datetime.date(2021, 1, 3)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "yesterday = date.today() - timedelta(days=1)\n", "with PricingContext(pricing_date=yesterday):\n", " my_date = RelativeDate('-1d').apply_rule() # Returns 2 days ago\n", "my_date" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" }, "pycharm": { "stem_cell": { "cell_type": "raw", "metadata": { "collapsed": false }, "source": [] } } }, "nbformat": 4, "nbformat_minor": 4 }