Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports: Added logic to download bhav copy and market activity reports. #50

Merged
merged 18 commits into from
May 4, 2024
Merged
Prev Previous commit
Next Next commit
migrated constant name and added last price in get price api
  • Loading branch information
Witchking authored and Witchking committed Apr 30, 2024
commit 7204c64937fe7ac29a0c82fb012a6b01052812b1
8 changes: 4 additions & 4 deletions docs/html/nsedt/derivatives/futures.html
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ <h1 class="modulename">
</span><span id="L-32"><a href="#L-32"><span class="linenos">32</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="L-33"><a href="#L-33"><span class="linenos">33</span></a> <span class="n">cookies</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_cookies</span><span class="p">()</span>
</span><span id="L-34"><a href="#L-34"><span class="linenos">34</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">BASE_URL</span>
</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FUTURES_PRICE</span>
</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FNO_HISTORY</span>
</span><span id="L-36"><a href="#L-36"><span class="linenos">36</span></a> <span class="n">symbol</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_symbol</span><span class="p">(</span><span class="n">symbol</span><span class="o">=</span><span class="n">symbol</span><span class="p">,</span> <span class="n">get_key</span><span class="o">=</span><span class="s2">&quot;derivatives&quot;</span><span class="p">)</span>
</span><span id="L-37"><a href="#L-37"><span class="linenos">37</span></a> <span class="n">params</span> <span class="o">=</span> <span class="p">{</span>
</span><span id="L-38"><a href="#L-38"><span class="linenos">38</span></a> <span class="s2">&quot;symbol&quot;</span><span class="p">:</span> <span class="n">symbol</span><span class="p">,</span>
Expand Down Expand Up @@ -1538,7 +1538,7 @@ <h1 class="modulename">
</span><span id="L-75"><a href="#L-75"><span class="linenos">75</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="L-76"><a href="#L-76"><span class="linenos">76</span></a> <span class="n">cookies</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_cookies</span><span class="p">()</span>
</span><span id="L-77"><a href="#L-77"><span class="linenos">77</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">BASE_URL</span>
</span><span id="L-78"><a href="#L-78"><span class="linenos">78</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FUTURES_PRICE</span>
</span><span id="L-78"><a href="#L-78"><span class="linenos">78</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FNO_HISTORY</span>
</span><span id="L-79"><a href="#L-79"><span class="linenos">79</span></a> <span class="n">params</span> <span class="o">=</span> <span class="p">{</span>
</span><span id="L-80"><a href="#L-80"><span class="linenos">80</span></a> <span class="s2">&quot;symbol&quot;</span><span class="p">:</span> <span class="n">symbol</span><span class="p">,</span>
</span><span id="L-81"><a href="#L-81"><span class="linenos">81</span></a> <span class="s2">&quot;from&quot;</span><span class="p">:</span> <span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2">-%m-%Y&quot;</span><span class="p">),</span>
Expand Down Expand Up @@ -1610,7 +1610,7 @@ <h1 class="modulename">
</span><span id="get_future_price-33"><a href="#get_future_price-33"><span class="linenos">33</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="get_future_price-34"><a href="#get_future_price-34"><span class="linenos">34</span></a> <span class="n">cookies</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_cookies</span><span class="p">()</span>
</span><span id="get_future_price-35"><a href="#get_future_price-35"><span class="linenos">35</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">BASE_URL</span>
</span><span id="get_future_price-36"><a href="#get_future_price-36"><span class="linenos">36</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FUTURES_PRICE</span>
</span><span id="get_future_price-36"><a href="#get_future_price-36"><span class="linenos">36</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FNO_HISTORY</span>
</span><span id="get_future_price-37"><a href="#get_future_price-37"><span class="linenos">37</span></a> <span class="n">symbol</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_symbol</span><span class="p">(</span><span class="n">symbol</span><span class="o">=</span><span class="n">symbol</span><span class="p">,</span> <span class="n">get_key</span><span class="o">=</span><span class="s2">&quot;derivatives&quot;</span><span class="p">)</span>
</span><span id="get_future_price-38"><a href="#get_future_price-38"><span class="linenos">38</span></a> <span class="n">params</span> <span class="o">=</span> <span class="p">{</span>
</span><span id="get_future_price-39"><a href="#get_future_price-39"><span class="linenos">39</span></a> <span class="s2">&quot;symbol&quot;</span><span class="p">:</span> <span class="n">symbol</span><span class="p">,</span>
Expand Down Expand Up @@ -1687,7 +1687,7 @@ <h1 class="modulename">
</span><span id="get_future_expdate-76"><a href="#get_future_expdate-76"><span class="linenos">76</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="get_future_expdate-77"><a href="#get_future_expdate-77"><span class="linenos">77</span></a> <span class="n">cookies</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_cookies</span><span class="p">()</span>
</span><span id="get_future_expdate-78"><a href="#get_future_expdate-78"><span class="linenos">78</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">BASE_URL</span>
</span><span id="get_future_expdate-79"><a href="#get_future_expdate-79"><span class="linenos">79</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FUTURES_PRICE</span>
</span><span id="get_future_expdate-79"><a href="#get_future_expdate-79"><span class="linenos">79</span></a> <span class="n">event_api</span> <span class="o">=</span> <span class="n">cns</span><span class="o">.</span><span class="n">FNO_HISTORY</span>
</span><span id="get_future_expdate-80"><a href="#get_future_expdate-80"><span class="linenos">80</span></a> <span class="n">params</span> <span class="o">=</span> <span class="p">{</span>
</span><span id="get_future_expdate-81"><a href="#get_future_expdate-81"><span class="linenos">81</span></a> <span class="s2">&quot;symbol&quot;</span><span class="p">:</span> <span class="n">symbol</span><span class="p">,</span>
</span><span id="get_future_expdate-82"><a href="#get_future_expdate-82"><span class="linenos">82</span></a> <span class="s2">&quot;from&quot;</span><span class="p">:</span> <span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> <span class="o">-</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">3</span><span class="p">))</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2">-%m-%Y&quot;</span><span class="p">),</span>
Expand Down
10 changes: 5 additions & 5 deletions docs/html/nsedt/resources/constants.html
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ <h2>API Documentation</h2>
<a class="variable" href="#VIX_HISTORY">VIX_HISTORY</a>
</li>
<li>
<a class="variable" href="#FUTURES_PRICE">FUTURES_PRICE</a>
<a class="variable" href="#FNO_HISTORY">FNO_HISTORY</a>
</li>
</ul>

Expand Down Expand Up @@ -1551,7 +1551,7 @@ <h1 class="modulename">
</span><span id="L-37"><a href="#L-37"><span class="linenos">37</span></a><span class="n">OPTIONS_PRICE_INDICES</span> <span class="o">=</span> <span class="s2">&quot;api/option-chain-indices?&quot;</span>
</span><span id="L-38"><a href="#L-38"><span class="linenos">38</span></a><span class="n">INDICES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;NIFTY&quot;</span><span class="p">,</span> <span class="s2">&quot;FINNIFTY&quot;</span><span class="p">,</span> <span class="s2">&quot;BANKNIFTY&quot;</span><span class="p">]</span>
</span><span id="L-39"><a href="#L-39"><span class="linenos">39</span></a><span class="n">VIX_HISTORY</span> <span class="o">=</span> <span class="s2">&quot;api/historical/vixhistory?&quot;</span>
</span><span id="L-40"><a href="#L-40"><span class="linenos">40</span></a><span class="n">FUTURES_PRICE</span> <span class="o">=</span> <span class="s2">&quot;api/historical/foCPV?&quot;</span>
</span><span id="L-40"><a href="#L-40"><span class="linenos">40</span></a><span class="n">FNO_HISTORY</span> <span class="o">=</span> <span class="s2">&quot;api/historical/foCPV?&quot;</span>
</span></pre>
</div>

Expand Down Expand Up @@ -1864,14 +1864,14 @@ <h1 class="modulename">


</section>
<section id="FUTURES_PRICE">
<section id="FNO_HISTORY">
<div class="attr variable">
<span class="name">FUTURES_PRICE</span> =
<span class="name">FNO_HISTORY</span> =
<span class="default_value">&#39;api/historical/foCPV?&#39;</span>


</div>
<a class="headerlink" href="#FUTURES_PRICE"></a>
<a class="headerlink" href="#FNO_HISTORY"></a>



Expand Down
1,289 changes: 1,273 additions & 16 deletions docs/html/search.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions nsedt/derivatives/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_future_price(
"""
cookies = utils.get_cookies()
base_url = cns.BASE_URL
event_api = cns.FUTURES_PRICE
event_api = cns.FNO_HISTORY
symbol = utils.get_symbol(symbol=symbol, get_key="derivatives")
params = {
"symbol": symbol,
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_future_expdate(symbol: str) -> list:
"""
cookies = utils.get_cookies()
base_url = cns.BASE_URL
event_api = cns.FUTURES_PRICE
event_api = cns.FNO_HISTORY
params = {
"symbol": symbol,
"from": (datetime.now() - timedelta(days=3)).strftime("%d-%m-%Y"),
Expand Down
2 changes: 1 addition & 1 deletion nsedt/derivatives/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_historical_option_data(
"""
cookies = utils.get_cookies()
base_url = cns.BASE_URL
event_api = cns.FUTURES_PRICE
event_api = cns.FNO_HISTORY
symbol = utils.get_symbol(symbol=symbol, get_key="derivatives")
params = {
"symbol": symbol,
Expand Down
2 changes: 1 addition & 1 deletion nsedt/resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
OPTIONS_PRICE_INDICES = "api/option-chain-indices?"
INDICES = ["NIFTY", "FINNIFTY", "BANKNIFTY"]
VIX_HISTORY = "api/historical/vixhistory?"
FUTURES_PRICE = "api/historical/foCPV?"
FNO_HISTORY = "api/historical/foCPV?"
3 changes: 3 additions & 0 deletions nsedt/utils/data_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def price(result):
"CH_TRADE_LOW_PRICE",
"CH_CLOSING_PRICE",
"CH_PREVIOUS_CLS_PRICE",
"CH_LAST_TRADED_PRICE",
"CH_TOT_TRADED_QTY",
"CH_TOT_TRADED_VAL",
"CH_52WEEK_HIGH_PRICE",
Expand All @@ -30,6 +31,7 @@ def price(result):
"COP_DELIV_PERC",
"CH_SERIES",
]

try:
result = result[columns_required]
except: # pylint: disable=W0702
Expand All @@ -42,6 +44,7 @@ def price(result):
"Low Price",
"Close Price",
"Prev Close Price",
"Last Traded Price",
"Total Traded Quantity",
"Total Traded Value",
"52 Week High Price",
Expand Down