nse_data 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +7 -0
  3. data/CHANGELOG.md +22 -0
  4. data/CODE_OF_CONDUCT.md +84 -0
  5. data/Gemfile +24 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +179 -0
  8. data/Rakefile +72 -0
  9. data/doc/NseData/API/Base.html +350 -0
  10. data/doc/NseData/API/SpecialPreopen.html +220 -0
  11. data/doc/NseData/API.html +117 -0
  12. data/doc/NseData/APIManager.html +644 -0
  13. data/doc/NseData/Cache/CachePolicy.html +907 -0
  14. data/doc/NseData/Cache/CacheStore.html +674 -0
  15. data/doc/NseData/Cache.html +117 -0
  16. data/doc/NseData/Client.html +385 -0
  17. data/doc/NseData/Config/Base.html +552 -0
  18. data/doc/NseData/Config/Logger.html +430 -0
  19. data/doc/NseData/Config.html +117 -0
  20. data/doc/NseData/Error.html +124 -0
  21. data/doc/NseData/HttpClient/BaseClient.html +349 -0
  22. data/doc/NseData/HttpClient/FaradayClient.html +301 -0
  23. data/doc/NseData/HttpClient.html +117 -0
  24. data/doc/NseData.html +524 -0
  25. data/doc/_index.html +243 -0
  26. data/doc/class_list.html +54 -0
  27. data/doc/css/common.css +1 -0
  28. data/doc/css/full_list.css +58 -0
  29. data/doc/css/style.css +503 -0
  30. data/doc/file.README.html +304 -0
  31. data/doc/file_list.html +59 -0
  32. data/doc/frames.html +22 -0
  33. data/doc/index.html +304 -0
  34. data/doc/js/app.js +344 -0
  35. data/doc/js/full_list.js +242 -0
  36. data/doc/js/jquery.js +4 -0
  37. data/doc/method_list.html +294 -0
  38. data/doc/top-level-namespace.html +110 -0
  39. data/lib/nse_data/api_manager.rb +83 -0
  40. data/lib/nse_data/cache/README.md +77 -0
  41. data/lib/nse_data/cache/cache_policy.rb +118 -0
  42. data/lib/nse_data/cache/cache_store.rb +84 -0
  43. data/lib/nse_data/cache/redis_cache_store.rb +3 -0
  44. data/lib/nse_data/config/api_endpoints.yml +56 -0
  45. data/lib/nse_data/config/base.rb +38 -0
  46. data/lib/nse_data/config/logger.rb +39 -0
  47. data/lib/nse_data/http_client/base_client.rb +26 -0
  48. data/lib/nse_data/http_client/faraday_client.rb +68 -0
  49. data/lib/nse_data/version.rb +5 -0
  50. data/lib/nse_data.rb +65 -0
  51. data/nse_data.gemspec +34 -0
  52. metadata +131 -0
@@ -0,0 +1,304 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-NseData">NseData</h1>
62
+
63
+ <h2 id="label-Table+of+Contents">Table of Contents</h2>
64
+ <ul><li>
65
+ <p><a href="#nsedata">NseData</a></p>
66
+ </li><li>
67
+ <p><a href="#table-of-contents">Table of Contents</a></p>
68
+ </li><li>
69
+ <p><a href="#features">Features</a></p>
70
+ </li><li>
71
+ <p><a href="#installation">Installation</a></p>
72
+ </li><li>
73
+ <p><a href="#usage">Usage</a></p>
74
+ <ul><li>
75
+ <p><a href="#high-level-interface">High-Level Interface</a></p>
76
+ </li><li>
77
+ <p><a href="#low-level-api">Low-Level API</a></p>
78
+ </li></ul>
79
+ </li><li>
80
+ <p><a href="#configuration">Configuration</a></p>
81
+ <ul><li>
82
+ <p><a href="#example">Example</a></p>
83
+ </li><li>
84
+ <p><a href="#apis-available">APIs Available</a></p>
85
+ </li></ul>
86
+ </li><li>
87
+ <p><a href="#development">Development</a></p>
88
+ <ul><li>
89
+ <p><a href="#running-tests">Running Tests</a></p>
90
+ </li><li>
91
+ <p><a href="#code-style-and-linting">Code Style and Linting</a></p>
92
+ </li></ul>
93
+ </li><li>
94
+ <p><a href="#contributing">Contributing</a></p>
95
+ </li><li>
96
+ <p><a href="#license">License</a></p>
97
+ </li><li>
98
+ <p><a href="#code-of-conduct">Code of Conduct</a></p>
99
+ </li></ul>
100
+
101
+ <p><strong>NseData</strong> is a Ruby gem designed to interact with the National Stock Exchange (NSE) of India’s API, providing an easy-to-use interface for developers to retrieve stock market data. The gem offers a high-level API for most users and a lower-level API for advanced users who need more control over the interactions.</p>
102
+
103
+ <h2 id="label-Features">Features</h2>
104
+ <ul><li>
105
+ <p>Fetch stock market data from multiple NSE APIs</p>
106
+ </li><li>
107
+ <p>High-level and low-level API interfaces</p>
108
+ </li><li>
109
+ <p>Simple and clear error handling for HTTP requests</p>
110
+ </li><li>
111
+ <p>Ruby 3.1 and 3.2 support with a test matrix across different OS</p>
112
+ </li><li>
113
+ <p>Easy integration with CI/CD and coverage tools</p>
114
+ </li></ul>
115
+
116
+ <h2 id="label-Installation">Installation</h2>
117
+
118
+ <p>Add this line to your application’s Gemfile:</p>
119
+
120
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nse_data</span><span class='tstring_end'>&#39;</span></span>
121
+ </code></pre>
122
+
123
+ <p>And then execute:</p>
124
+
125
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_install'>install</span>
126
+ </code></pre>
127
+
128
+ <p>Or install it yourself as:</p>
129
+
130
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_nse_data'>nse_data</span>
131
+ </code></pre>
132
+
133
+ <h2 id="label-Available+Methods">Available Methods</h2>
134
+ <ul><li>
135
+ <p>fetch_all_indices</p>
136
+ </li><li>
137
+ <p>fetch_circulars</p>
138
+ </li><li>
139
+ <p>fetch_equity_master</p>
140
+ </li><li>
141
+ <p>fetch_glossary</p>
142
+ </li><li>
143
+ <p>fetch_holiday_clearing</p>
144
+ </li><li>
145
+ <p>fetch_holiday_trading</p>
146
+ </li><li>
147
+ <p>fetch_index_names</p>
148
+ </li><li>
149
+ <p>fetch_latest_circulars</p>
150
+ </li><li>
151
+ <p>fetch_market_data_pre_open</p>
152
+ </li><li>
153
+ <p>fetch_market_status</p>
154
+ </li><li>
155
+ <p>fetch_market_turnover</p>
156
+ </li><li>
157
+ <p>fetch_merged_daily_reports_capital</p>
158
+ </li><li>
159
+ <p>fetch_merged_daily_reports_debt</p>
160
+ </li><li>
161
+ <p>fetch_merged_daily_reports_derivatives</p>
162
+ </li></ul>
163
+
164
+ <h2 id="label-Usage">Usage</h2>
165
+
166
+ <h3 id="label-High-Level+Interface">High-Level Interface</h3>
167
+
168
+ <p>The high-level interface is designed to be simple and user-friendly. You can instantiate an object and call the available methods:</p>
169
+
170
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nse_data</span><span class='tstring_end'>&#39;</span></span>
171
+
172
+ <span class='id identifier rubyid_puts'>puts</span> <span class='const'><span class='object_link'><a href="NseData.html" title="NseData (module)">NseData</a></span></span><span class='period'>.</span><span class='id identifier rubyid_list_all_endpoints'><span class='object_link'><a href="NseData.html#list_all_endpoints-class_method" title="NseData.list_all_endpoints (method)">list_all_endpoints</a></span></span> <span class='comment'># Returns all the available APIs in the library
173
+ </span><span class='id identifier rubyid_puts'>puts</span> <span class='const'><span class='object_link'><a href="NseData.html" title="NseData (module)">NseData</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch_all_indices'>fetch_all_indices</span> <span class='comment'># Returns the response.body of allIndices endpoint of NSE
174
+ </span></code></pre>
175
+
176
+ <h3 id="label-Low-Level+API">Low-Level API</h3>
177
+
178
+ <p>For advanced users, the lower-level APIManager class offers more control over requests:</p>
179
+
180
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nse_data</span><span class='tstring_end'>&#39;</span></span>
181
+
182
+ <span class='id identifier rubyid_api_manager'>api_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="NseData.html" title="NseData (module)">NseData</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="NseData/APIManager.html" title="NseData::APIManager (class)">APIManager</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="NseData/APIManager.html#initialize-instance_method" title="NseData::APIManager#initialize (method)">new</a></span></span>
183
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='id identifier rubyid_api_manager'>api_manager</span><span class='period'>.</span><span class='id identifier rubyid_fetch_data'>fetch_data</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>index_names</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
184
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span> <span class='comment'># Returns index names in JSON format
185
+ </span></code></pre>
186
+
187
+ <p>where <code>index_names</code> is the name of the API routing to the path of <a href="https://www.nseindia.com/api/index-names">www.nseindia.com/api/index-names</a></p>
188
+
189
+ <h2 id="label-Configuration">Configuration</h2>
190
+
191
+ <p>The gem uses an <code>api_endpoints.yml</code> file located in the config directory. This file maps API names to their respective endpoint URLs.</p>
192
+
193
+ <h3 id="label-Example">Example</h3>
194
+
195
+ <pre class="code ruby"><code class="ruby">all_indices:
196
+ path: &quot;allIndices&quot;
197
+ description: &quot;Fetches data of all available indices.&quot;
198
+ </code></pre>
199
+
200
+ <h3 id="label-APIs+Available">APIs Available</h3>
201
+ <ul><li>
202
+ <p><strong>all_indices</strong>: Fetches data of all available indices.</p>
203
+ </li><li>
204
+ <p><strong>circulars</strong>: Provides a list of circulars.</p>
205
+ </li><li>
206
+ <p><strong>equity_master</strong>: Fetches equity master data.</p>
207
+ </li><li>
208
+ <p><strong>glossary</strong>: Fetches glossary content.</p>
209
+ </li><li>
210
+ <p><strong>holiday_clearing</strong>: Fetches clearing holiday data.</p>
211
+ </li><li>
212
+ <p><strong>holiday_trading</strong>: Fetches trading holiday data.</p>
213
+ </li><li>
214
+ <p><strong>index_names</strong>: Fetches names of all indices.</p>
215
+ </li><li>
216
+ <p><strong>latest_circulars</strong>: Provides the latest circulars.</p>
217
+ </li><li>
218
+ <p><strong>market_data_pre_open</strong>: Fetches market pre-open data for all securities.</p>
219
+ </li><li>
220
+ <p><strong>market_status</strong>: Fetches the current status of the market.</p>
221
+ </li><li>
222
+ <p><strong>market_turnover</strong>: Fetches turnover data for the market.</p>
223
+ </li><li>
224
+ <p><strong>merged_daily_reports_capital</strong>: Fetches merged daily reports for capital.</p>
225
+ </li><li>
226
+ <p><strong>merged_daily_reports_debt</strong>: Fetches merged daily reports for debt.</p>
227
+ </li><li>
228
+ <p><strong>merged_daily_reports_derivatives</strong>: Fetches merged daily reports for derivatives.</p>
229
+ </li></ul>
230
+
231
+ <p>Please refer to the <a href="lib/nse_data/config/api_endpoints.yml">api_endpoints.yml</a> file for the actual endpoint routing information.</p>
232
+
233
+ <h2 id="label-Development">Development</h2>
234
+
235
+ <p>To get started with contributing to <strong>NseData</strong>, follow these steps:</p>
236
+ <ol><li>
237
+ <p><strong>Clone the repository</strong>:</p>
238
+ </li></ol>
239
+
240
+ <p>First, clone the repository to your local machine and navigate to the project directory:</p>
241
+
242
+ <p>“‘bash git clone <a href="https://github.com/ahasunos/nse_data.git">github.com/ahasunos/nse_data.git</a> cd nse_data</p>
243
+ <ol><li>
244
+ <p><strong>Install dependencies</strong>:</p>
245
+ </li></ol>
246
+
247
+ <p>After navigating to the project directory, install the required gems using Bundler:</p>
248
+
249
+ <p><code>bash bundle install </code></p>
250
+
251
+ <h3 id="label-Running+Tests">Running Tests</h3>
252
+
253
+ <p>The project uses RSpec for testing. Before submitting any changes, make sure to run the test suite to ensure that everything works as expected:</p>
254
+
255
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_exec'>exec</span> <span class='id identifier rubyid_rspec'>rspec</span>
256
+ </code></pre>
257
+
258
+ <h3 id="label-Code+Style+and+Linting">Code Style and Linting</h3>
259
+
260
+ <p>To maintain consistent code quality and style, the project uses RuboCop for linting. Before submitting a pull request, ensure that your code adheres to the project’s style guidelines by running RuboCop:</p>
261
+
262
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_exec'>exec</span> <span class='id identifier rubyid_rubocop'>rubocop</span>
263
+ </code></pre>
264
+
265
+ <p>If RuboCop identifies any issues, it will provide suggestions for how to fix them.</p>
266
+
267
+ <h2 id="label-Debugging">Debugging</h2>
268
+
269
+ <h3 id="label-NseData-3A-3AConfig-3A-3ALogger">NseData::Config::Logger</h3>
270
+
271
+ <p>The <code>NseData::Config::Logger</code> class is part of the NseData gem, providing configurable logging capabilities for your application. By default, it logs to a temporary file in the system’s temporary directory, but it can be customized to suit your needs.</p>
272
+
273
+ <h4 id="label-Usage">Usage</h4>
274
+
275
+ <p>By default, the Logger class logs to a temporary file. You can configure it as follows:</p>
276
+
277
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="NseData.html" title="NseData (module)">NseData</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="NseData.html#configure-class_method" title="NseData.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config'>config</span><span class='op'>|</span>
278
+ <span class='id identifier rubyid_custom_logger'>custom_logger</span> <span class='op'>=</span> <span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='gvar'>$stdout</span><span class='rparen'>)</span>
279
+ <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span> <span class='op'>=</span> <span class='id identifier rubyid_custom_logger'>custom_logger</span>
280
+ <span class='kw'>end</span>
281
+ </code></pre>
282
+
283
+ <h2 id="label-Contributing">Contributing</h2>
284
+
285
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/ahasunos/nse_data">github.com/ahasunos/nse_data</a>. For major changes, please open an issue first to discuss what you would like to change.</p>
286
+
287
+ <h2 id="label-License">License</h2>
288
+
289
+ <p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
290
+
291
+ <h2 id="label-Code+of+Conduct">Code of Conduct</h2>
292
+
293
+ <p>Everyone interacting in the NseData project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow the of conduct[https://github.com/[USERNAME]/nse_data/blob/master/CODE_OF_CONDUCT.md].</p>
294
+ </div></div>
295
+
296
+ <div id="footer">
297
+ Generated on Tue Sep 10 12:25:13 2024 by
298
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
299
+ 0.9.37 (ruby-3.2.2).
300
+ </div>
301
+
302
+ </div>
303
+ </body>
304
+ </html>
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE html>
2
+ <html >
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">
42
+ <label for="search-class">Search:</label>
43
+ <input id="search-class" type="text" />
44
+ </div>
45
+ </div>
46
+
47
+ <ul id="full_list" class="file">
48
+
49
+
50
+ <li id="object_README" class="odd">
51
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
52
+ </li>
53
+
54
+
55
+
56
+ </ul>
57
+ </div>
58
+ </body>
59
+ </html>
data/doc/frames.html ADDED
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.37</title>
6
+ </head>
7
+ <script type="text/javascript">
8
+ var mainUrl = 'index.html';
9
+ try {
10
+ var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
11
+ var name = match ? match[1] : mainUrl;
12
+ var url = new URL(name, location.href);
13
+ window.top.location.replace(url.origin === location.origin ? name : mainUrl);
14
+ } catch (e) {
15
+ window.top.location.replace(mainUrl);
16
+ }
17
+ </script>
18
+ <noscript>
19
+ <h1>Oops!</h1>
20
+ <h2>YARD requires JavaScript!</h2>
21
+ </noscript>
22
+ </html>