-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d580490
Showing
51 changed files
with
7,928 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 7d36cd01a7d2d5c6721ae0b96691e81f | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<!DOCTYPE html> | ||
<html class="writer-html5" lang="en" data-content_root="../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Overview: module code — Qtrade 0.6.0 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" /> | ||
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094" /> | ||
|
||
|
||
<!--[if lt IE 9]> | ||
<script src="../_static/js/html5shiv.min.js"></script> | ||
<![endif]--> | ||
|
||
<script src="../_static/documentation_options.js?v=8fa8b3e9"></script> | ||
<script src="../_static/doctools.js?v=888ff710"></script> | ||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<script src="../_static/js/theme.js"></script> | ||
<link rel="index" title="Index" href="../genindex.html" /> | ||
<link rel="search" title="Search" href="../search.html" /> | ||
</head> | ||
|
||
<body class="wy-body-for-nav"> | ||
<div class="wy-grid-for-nav"> | ||
<nav data-toggle="wy-nav-shift" class="wy-nav-side"> | ||
<div class="wy-side-scroll"> | ||
<div class="wy-side-nav-search" > | ||
|
||
|
||
|
||
<a href="../index.html" class="icon icon-home"> | ||
Qtrade | ||
</a> | ||
<div class="version"> | ||
0.6.0 | ||
</div> | ||
<div role="search"> | ||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> | ||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> | ||
<input type="hidden" name="check_keywords" value="yes" /> | ||
<input type="hidden" name="area" value="default" /> | ||
</form> | ||
</div> | ||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> | ||
<p class="caption" role="heading"><span class="caption-text">Introduction:</span></p> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Introduction to Qtrade</a></li> | ||
</ul> | ||
<p class="caption" role="heading"><span class="caption-text">API Reference</span></p> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../api/modules.html">qtrade</a></li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
</nav> | ||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > | ||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i> | ||
<a href="../index.html">Qtrade</a> | ||
</nav> | ||
|
||
<div class="wy-nav-content"> | ||
<div class="rst-content"> | ||
<div role="navigation" aria-label="Page navigation"> | ||
<ul class="wy-breadcrumbs"> | ||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li> | ||
<li class="breadcrumb-item active">Overview: module code</li> | ||
<li class="wy-breadcrumbs-aside"> | ||
</li> | ||
</ul> | ||
<hr/> | ||
</div> | ||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> | ||
<div itemprop="articleBody"> | ||
|
||
<h1>All modules for which code is available</h1> | ||
<ul><li><a href="qtrade/questrade.html">qtrade.questrade</a></li> | ||
<li><a href="qtrade/utility.html">qtrade.utility</a></li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
<footer> | ||
|
||
<hr/> | ||
|
||
<div role="contentinfo"> | ||
<p>© Copyright 2019, Jan Borchmann.</p> | ||
</div> | ||
|
||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a | ||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> | ||
provided by <a href="https://readthedocs.org">Read the Docs</a>. | ||
|
||
|
||
</footer> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
<script> | ||
jQuery(function () { | ||
SphinxRtdTheme.Navigation.enable(true); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<!DOCTYPE html> | ||
<html class="writer-html5" lang="en" data-content_root="../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>qtrade.utility — Qtrade 0.6.0 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" /> | ||
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" /> | ||
|
||
|
||
<!--[if lt IE 9]> | ||
<script src="../../_static/js/html5shiv.min.js"></script> | ||
<![endif]--> | ||
|
||
<script src="../../_static/documentation_options.js?v=8fa8b3e9"></script> | ||
<script src="../../_static/doctools.js?v=888ff710"></script> | ||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<script src="../../_static/js/theme.js"></script> | ||
<link rel="index" title="Index" href="../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../search.html" /> | ||
</head> | ||
|
||
<body class="wy-body-for-nav"> | ||
<div class="wy-grid-for-nav"> | ||
<nav data-toggle="wy-nav-shift" class="wy-nav-side"> | ||
<div class="wy-side-scroll"> | ||
<div class="wy-side-nav-search" > | ||
|
||
|
||
|
||
<a href="../../index.html" class="icon icon-home"> | ||
Qtrade | ||
</a> | ||
<div class="version"> | ||
0.6.0 | ||
</div> | ||
<div role="search"> | ||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> | ||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> | ||
<input type="hidden" name="check_keywords" value="yes" /> | ||
<input type="hidden" name="area" value="default" /> | ||
</form> | ||
</div> | ||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> | ||
<p class="caption" role="heading"><span class="caption-text">Introduction:</span></p> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">Introduction to Qtrade</a></li> | ||
</ul> | ||
<p class="caption" role="heading"><span class="caption-text">API Reference</span></p> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../api/modules.html">qtrade</a></li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
</nav> | ||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > | ||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i> | ||
<a href="../../index.html">Qtrade</a> | ||
</nav> | ||
|
||
<div class="wy-nav-content"> | ||
<div class="rst-content"> | ||
<div role="navigation" aria-label="Page navigation"> | ||
<ul class="wy-breadcrumbs"> | ||
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li> | ||
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li> | ||
<li class="breadcrumb-item active">qtrade.utility</li> | ||
<li class="wy-breadcrumbs-aside"> | ||
</li> | ||
</ul> | ||
<hr/> | ||
</div> | ||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> | ||
<div itemprop="articleBody"> | ||
|
||
<h1>Source code for qtrade.utility</h1><div class="highlight"><pre> | ||
<span></span><span class="sd">"""Collection of utility functions."""</span> | ||
<span class="kn">import</span> <span class="nn">logging</span> | ||
<span class="kn">import</span> <span class="nn">sys</span> | ||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span> | ||
|
||
<span class="kn">import</span> <span class="nn">yaml</span> | ||
|
||
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span> <span class="o"><</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> | ||
<span class="kn">from</span> <span class="nn">typing_extensions</span> <span class="kn">import</span> <span class="n">TypedDict</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="p">(</span> <span class="c1"># type: ignore ## needed to do this for mypy error in python < 3.8</span> | ||
<span class="n">TypedDict</span><span class="p">,</span> | ||
<span class="p">)</span> | ||
|
||
|
||
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span> <span class="c1"># pylint: disable=C0103</span> | ||
|
||
<span class="n">TokenDict</span> <span class="o">=</span> <span class="n">TypedDict</span><span class="p">(</span> | ||
<span class="s2">"TokenDict"</span><span class="p">,</span> | ||
<span class="p">{</span> | ||
<span class="s2">"access_token"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> | ||
<span class="s2">"api_server"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> | ||
<span class="s2">"expires_in"</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> | ||
<span class="s2">"refresh_token"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> | ||
<span class="s2">"token_type"</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> | ||
<span class="p">},</span> | ||
<span class="p">)</span> | ||
|
||
|
||
<div class="viewcode-block" id="get_access_token_yaml"> | ||
<a class="viewcode-back" href="../../api/qtrade.html#qtrade.utility.get_access_token_yaml">[docs]</a> | ||
<span class="k">def</span> <span class="nf">get_access_token_yaml</span><span class="p">(</span><span class="n">token_yaml</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">TokenDict</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""Read in access token yaml.</span> | ||
|
||
<span class="sd"> Parameters</span> | ||
<span class="sd"> ----------</span> | ||
<span class="sd"> token_yaml: str</span> | ||
<span class="sd"> Path of the token yaml file</span> | ||
|
||
<span class="sd"> Returns</span> | ||
<span class="sd"> -------</span> | ||
<span class="sd"> dict</span> | ||
<span class="sd"> Dicitonary with the access token parameters</span> | ||
<span class="sd"> """</span> | ||
<span class="k">try</span><span class="p">:</span> | ||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">token_yaml</span><span class="p">)</span> <span class="k">as</span> <span class="n">yaml_file</span><span class="p">:</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Loading access token from yaml..."</span><span class="p">)</span> | ||
<span class="n">token_yaml_payload</span><span class="p">:</span> <span class="n">TokenDict</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">yaml_file</span><span class="p">,</span> <span class="n">Loader</span><span class="o">=</span><span class="n">yaml</span><span class="o">.</span><span class="n">FullLoader</span><span class="p">)</span> | ||
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Error loading access token from yaml..."</span><span class="p">)</span> | ||
<span class="k">raise</span> | ||
|
||
<span class="n">validate_access_token</span><span class="p">(</span><span class="o">**</span><span class="n">token_yaml_payload</span><span class="p">)</span> | ||
<span class="k">return</span> <span class="n">token_yaml_payload</span></div> | ||
|
||
|
||
|
||
<div class="viewcode-block" id="validate_access_token"> | ||
<a class="viewcode-back" href="../../api/qtrade.html#qtrade.utility.validate_access_token">[docs]</a> | ||
<span class="k">def</span> <span class="nf">validate_access_token</span><span class="p">(</span> | ||
<span class="n">access_token</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">api_server</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">expires_in</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">refresh_token</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="n">token_type</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> | ||
<span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""Validate access token.</span> | ||
|
||
<span class="sd"> This function validates the access token and ensures that all requiered</span> | ||
<span class="sd"> attributes are provided.</span> | ||
|
||
<span class="sd"> Parameters</span> | ||
<span class="sd"> ----------</span> | ||
<span class="sd"> access_token: str, optional</span> | ||
<span class="sd"> Access token</span> | ||
<span class="sd"> api_server: str, optional</span> | ||
<span class="sd"> Api server URL</span> | ||
<span class="sd"> expires_in: int, optional</span> | ||
<span class="sd"> Time until token expires</span> | ||
<span class="sd"> refresh_token: str, optional</span> | ||
<span class="sd"> Refresh token</span> | ||
<span class="sd"> token_type: str, optional</span> | ||
<span class="sd"> Token type</span> | ||
|
||
<span class="sd"> Raises</span> | ||
<span class="sd"> ------</span> | ||
<span class="sd"> Exception</span> | ||
<span class="sd"> If any of the inputs is None.</span> | ||
<span class="sd"> """</span> | ||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Validating access token..."</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">access_token</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Access token was not provided."</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">api_server</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"API server URL was not provided."</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">expires_in</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Expiry time was not provided."</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">refresh_token</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Refresh token was not provided."</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">token_type</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Token type was not provided."</span><span class="p">)</span></div> | ||
|
||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
<footer> | ||
|
||
<hr/> | ||
|
||
<div role="contentinfo"> | ||
<p>© Copyright 2019, Jan Borchmann.</p> | ||
</div> | ||
|
||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a | ||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> | ||
provided by <a href="https://readthedocs.org">Read the Docs</a>. | ||
|
||
|
||
</footer> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
<script> | ||
jQuery(function () { | ||
SphinxRtdTheme.Navigation.enable(true); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
qtrade | ||
====== | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
qtrade |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
qtrade package | ||
============== | ||
|
||
Submodules | ||
---------- | ||
|
||
|
||
.. automodule:: qtrade.questrade | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
.. automodule:: qtrade.utility | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: qtrade | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Welcome to Qtrade's documentation! | ||
================================== | ||
|
||
Contents: | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Introduction: | ||
|
||
readme | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
:caption: API Reference | ||
|
||
api/modules | ||
|
||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
Oops, something went wrong.