financegy 1.5__py3-none-any.whl → 2.0__py3-none-any.whl

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.
@@ -0,0 +1,10 @@
1
+ # Function to convert GSE price string to float type
2
+
3
+
4
+ def to_float(value):
5
+ if value is None:
6
+ return None
7
+ value = value.strip()
8
+ if value in ("", "-", "N/A"):
9
+ return None
10
+ return float(value.replace(",", ""))
@@ -1,5 +1,7 @@
1
1
  from financegy.core import request_handler, parser
2
2
  from financegy.cache import cache_manager
3
+ import math
4
+
3
5
 
4
6
  def get_securities(use_cache=True):
5
7
  """Get names of all currently traded securities"""
@@ -16,7 +18,8 @@ def get_securities(use_cache=True):
16
18
 
17
19
  cache_manager.save_cache(func_name, html)
18
20
 
19
- return parser.parse_get_securities(html);
21
+ return parser.parse_get_securities(html)
22
+
20
23
 
21
24
  def get_security_by_symbol(symbol: str, use_cache=True):
22
25
  """Get the security details by its ticker symbol"""
@@ -26,11 +29,16 @@ def get_security_by_symbol(symbol: str, use_cache=True):
26
29
  symbol = symbol.strip().upper()
27
30
 
28
31
  return next(
29
- (security['name'] for security in securities if security["symbol"].upper() == symbol),
32
+ (
33
+ security["name"]
34
+ for security in securities
35
+ if security["symbol"].upper() == symbol
36
+ ),
30
37
  None,
31
38
  )
32
39
 
33
- def get_security_recent_year(symbol:str, use_cache=True):
40
+
41
+ def get_security_recent_year(symbol: str, use_cache=True):
34
42
  """Get the most recent year's trade data for any of the traded securities"""
35
43
 
36
44
  func_name = "get_security_recent_year"
@@ -50,11 +58,12 @@ def get_security_recent_year(symbol:str, use_cache=True):
50
58
 
51
59
  return parser.parse_get_security_recent_year(html)
52
60
 
61
+
53
62
  def get_recent_trade(symbol: str, use_cache=True):
54
63
  """Get the most recent trade data for any of the traded securities"""
55
64
 
56
65
  func_name = "get_recent_trade"
57
-
66
+
58
67
  security_name = get_security_by_symbol(symbol)
59
68
  security_name = security_name.lower().replace(" ", "-")
60
69
 
@@ -70,6 +79,197 @@ def get_recent_trade(symbol: str, use_cache=True):
70
79
 
71
80
  return parser.parse_get_recent_trade(html)
72
81
 
82
+
83
+ def get_previous_close(symbol: str, use_cache=True):
84
+ """Get the most recent closing price for any of the traded securities"""
85
+
86
+ func_name = "get_previous_close"
87
+
88
+ security_name = get_security_by_symbol(symbol)
89
+ security_name = security_name.lower().replace(" ", "-")
90
+
91
+ if use_cache:
92
+ cached = cache_manager.load_cache(func_name, symbol)
93
+ if cached:
94
+ return parser.parse_get_previous_close(cached)
95
+
96
+ path = "/security/" + security_name
97
+ html = request_handler.fetch_page(path)
98
+
99
+ cache_manager.save_cache(func_name, html, symbol)
100
+
101
+ return parser.parse_get_previous_close(html)
102
+
103
+
104
+ def get_price_change(symbol: str, use_cache=True):
105
+ """Get absolute price difference between the most recent trade and the previous session close."""
106
+
107
+ func_name = "get_price_change"
108
+
109
+ security_name = get_security_by_symbol(symbol)
110
+ security_name = security_name.lower().replace(" ", "-")
111
+
112
+ if use_cache:
113
+ cached = cache_manager.load_cache(func_name, symbol)
114
+ if cached:
115
+ return parser.parse_get_price_change(cached)
116
+
117
+ path = "/security/" + security_name
118
+ html = request_handler.fetch_page(path)
119
+
120
+ cache_manager.save_cache(func_name, html, symbol)
121
+
122
+ return parser.parse_get_price_change(html)
123
+
124
+
125
+ def get_price_change_percent(symbol: str, use_cache=True):
126
+ """Get the percentage price change between the most recent trade and the previous session close."""
127
+
128
+ func_name = "get_price_change_percent"
129
+
130
+ security_name = get_security_by_symbol(symbol)
131
+ security_name = security_name.lower().replace(" ", "-")
132
+
133
+ if use_cache:
134
+ cached = cache_manager.load_cache(func_name, symbol)
135
+ if cached:
136
+ return parser.parse_get_price_change_percent(cached)
137
+
138
+ path = "/security/" + security_name
139
+ html = request_handler.fetch_page(path)
140
+
141
+ cache_manager.save_cache(func_name, html, symbol)
142
+
143
+ return parser.parse_get_price_change_percent(html)
144
+
145
+
146
+ def get_latest_session_for_symbol(symbol: str, use_cache: bool = True):
147
+ """
148
+ Fetch the security page, parse the most recent trade, return its session as int.
149
+ """
150
+
151
+ func_name = "get_latest_session_for_symbol"
152
+ symbol = symbol.strip().upper()
153
+
154
+ security_name = get_security_by_symbol(symbol)
155
+ security_name = security_name.lower().replace(" ", "-")
156
+
157
+ if use_cache:
158
+ cached = cache_manager.load_cache(func_name, symbol)
159
+ if cached:
160
+ return parser.parse_get_recent_trade(cached)
161
+
162
+ path = "/security/" + security_name
163
+ html = request_handler.fetch_page(path)
164
+
165
+ cache_manager.save_cache(func_name, html, symbol)
166
+
167
+ recent = parser.parse_get_recent_trade(html)
168
+
169
+ if not recent or not recent.get("session"):
170
+ raise ValueError(f"Could not determine latest session for {symbol}")
171
+
172
+ return recent
173
+
174
+
175
+ def get_sessions_average_price(
176
+ symbol: str, session_start: str, session_end: str, use_cache=True
177
+ ):
178
+ """Get the average last traded price of the security over a specified session range."""
179
+
180
+ func_name = "get_sessions_average_price"
181
+
182
+ start = int(session_start)
183
+ end = int(session_end)
184
+ symbol = symbol.strip().upper()
185
+
186
+ if end < start:
187
+ raise ValueError("session_end must be >= session_start")
188
+
189
+ prices_by_session: dict[int, float] = {}
190
+
191
+ for session in range(start, end + 1):
192
+
193
+ html = None
194
+ if use_cache:
195
+ html = cache_manager.load_cache(func_name, symbol, session)
196
+
197
+ if not html:
198
+ path = f"/financial_session/{session}/"
199
+ html = request_handler.fetch_page(path)
200
+ cache_manager.save_cache(func_name, html, symbol, session)
201
+
202
+ price = parser.parse_get_sessions_average_price(symbol, html)
203
+
204
+ if price is None:
205
+ continue
206
+
207
+ prices_by_session[session] = price
208
+
209
+ if not prices_by_session:
210
+ raise ValueError(f"No prices found for {symbol} in sessions {start}..{end}")
211
+
212
+ avg = round(sum(prices_by_session.values()) / len(prices_by_session), 2)
213
+
214
+ return {
215
+ "symbol": symbol,
216
+ "session_start": start,
217
+ "session_end": end,
218
+ "observations": len(prices_by_session),
219
+ "average_price": avg,
220
+ "prices_by_session": prices_by_session,
221
+ }
222
+
223
+
224
+ def get_average_price(symbol: str, session_number: int, use_cache=True):
225
+ """Average LTP over the most recent `session_number` sessions (ending at latest session)."""
226
+
227
+ func_name = "get_average_price"
228
+ symbol = symbol.strip().upper()
229
+
230
+ if session_number <= 0:
231
+ raise ValueError("session_number must be a positive integer")
232
+
233
+ latest = get_latest_session_for_symbol(symbol, use_cache=use_cache)
234
+ end = int(latest["session"])
235
+ start = max(1, end - session_number + 1)
236
+
237
+ prices_by_session: dict[int, float] = {}
238
+
239
+ for session in range(start, end + 1):
240
+ html = None
241
+
242
+ if use_cache:
243
+ html = cache_manager.load_cache(func_name, symbol, session)
244
+
245
+ if not html:
246
+ path = f"/financial_session/{session}/"
247
+ html = request_handler.fetch_page(path)
248
+ cache_manager.save_cache(func_name, html, symbol, session)
249
+
250
+ price = parser.parse_get_average_price(symbol, html)
251
+ if price is None:
252
+ continue
253
+
254
+ prices_by_session[session] = price
255
+
256
+ if not prices_by_session:
257
+ raise ValueError(f"No prices found for {symbol} in sessions {start}..{end}")
258
+
259
+ avg = round(sum(prices_by_session.values()) / len(prices_by_session), 2)
260
+
261
+ return {
262
+ "symbol": symbol,
263
+ "latest_session": latest,
264
+ "session_number_requested": session_number,
265
+ "session_start": start,
266
+ "session_end": end,
267
+ "observations": len(prices_by_session),
268
+ "average_price": avg,
269
+ "prices_by_session": prices_by_session,
270
+ }
271
+
272
+
73
273
  def get_session_trades(session: str, use_cache=True):
74
274
  """Get the session trade data for all the available securities"""
75
275
 
@@ -87,6 +287,7 @@ def get_session_trades(session: str, use_cache=True):
87
287
 
88
288
  return parser.parse_get_session_trades(html)
89
289
 
290
+
90
291
  def get_security_session_trade(symbol: str, session: str, use_cache=True):
91
292
  """Get the session trade data for a given security"""
92
293
 
@@ -106,6 +307,114 @@ def get_security_session_trade(symbol: str, session: str, use_cache=True):
106
307
 
107
308
  return parser.parse_get_security_session_trade(symbol, html)
108
309
 
310
+
311
+ def get_sessions_volatility(symbol: str, session_number: int, use_cache=True):
312
+ """
313
+ Volatility over the last `sessions` observed prices, ending at the latest session.
314
+ Uses log returns and returns weekly volatility (std dev of weekly returns).
315
+ """
316
+
317
+ symbol = symbol.strip().upper()
318
+
319
+ if session_number <= 1:
320
+ raise ValueError(
321
+ "session_number must be >= 2 (need at least 2 prices to compute returns)."
322
+ )
323
+
324
+ latest = get_latest_session_for_symbol(symbol, use_cache=use_cache)
325
+ latest_session = int(latest["session"])
326
+
327
+ target_prices = session_number
328
+ prices: list[float] = []
329
+ prices_by_session: dict[int, float] = {}
330
+
331
+ func_name = "get_sessions_volatility"
332
+
333
+ session = latest_session
334
+ safety_limit = latest_session - (session_number * 5)
335
+
336
+ while session >= 1 and session >= safety_limit and len(prices) < target_prices:
337
+
338
+ html = None
339
+ if use_cache:
340
+ html = cache_manager.load_cache(func_name, symbol, session)
341
+
342
+ if not html:
343
+ path = f"/financial_session/{session}/"
344
+ html = request_handler.fetch_page(path)
345
+ cache_manager.save_cache(func_name, html, symbol, session)
346
+
347
+ price = parser.parse_get_session_ltp(symbol, html)
348
+
349
+ if price is not None:
350
+ prices.append(price)
351
+ prices_by_session[session] = price
352
+
353
+ session -= 1
354
+
355
+ if len(prices) < 2:
356
+ raise ValueError(
357
+ f"Not enough price data found for {symbol} to compute volatility."
358
+ )
359
+
360
+ prices.reverse()
361
+
362
+ returns = []
363
+ for i in range(1, len(prices)):
364
+ prev_p = prices[i - 1]
365
+ cur_p = prices[i]
366
+ if prev_p and prev_p > 0 and cur_p and cur_p > 0:
367
+ returns.append(math.log(cur_p / prev_p))
368
+
369
+ if len(returns) < 2:
370
+ raise ValueError("Not enough valid returns to compute volatility.")
371
+
372
+ mean = sum(returns) / len(returns)
373
+ variance = sum((r - mean) ** 2 for r in returns) / (len(returns) - 1)
374
+ weekly_vol = round(math.sqrt(variance), 2)
375
+
376
+ annualized_vol = round(weekly_vol * math.sqrt(52), 2)
377
+
378
+ return {
379
+ "symbol": symbol,
380
+ "latest_session": latest_session,
381
+ "requested_sessions": session_number,
382
+ "prices_found": len(prices),
383
+ "returns_count": len(returns),
384
+ "weekly_volatility": weekly_vol,
385
+ "annualized_volatility": annualized_vol,
386
+ "prices_by_session": dict(sorted(prices_by_session.items())),
387
+ }
388
+
389
+
390
+ def get_ytd_high_low(symbol: str, use_cache: bool = True):
391
+ """Return year-to-date highest and lowest traded prices for the security."""
392
+
393
+ func_name = "get_ytd_high_low"
394
+ symbol = symbol.strip().upper()
395
+
396
+ security_name = get_security_by_symbol(symbol)
397
+ security_name = security_name.lower().replace(" ", "-")
398
+
399
+ html = None
400
+ if use_cache:
401
+ html = cache_manager.load_cache(func_name, symbol)
402
+
403
+ if not html:
404
+ path = f"/security/{security_name}/"
405
+ html = request_handler.fetch_page(path)
406
+ cache_manager.save_cache(func_name, html, symbol)
407
+
408
+ result = parser.parse_get_ytd_high_low(html)
409
+ if not result:
410
+ raise ValueError(f"Could not compute YTD high/low for {symbol}")
411
+
412
+ return {
413
+ "symbol": symbol,
414
+ **result,
415
+ }
416
+
417
+
109
418
  def get_trades_for_year(symbol: str, year: str, use_cache=True):
110
419
  """Get security trade information from a specific year"""
111
420
 
@@ -128,6 +437,7 @@ def get_trades_for_year(symbol: str, year: str, use_cache=True):
128
437
 
129
438
  return parser.parse_get_trades_for_year(year, html)
130
439
 
440
+
131
441
  def get_historical_trades(symbol: str, start_date: str, end_date: str, use_cache=True):
132
442
  """Get historical trade data for a date range"""
133
443
 
@@ -150,6 +460,7 @@ def get_historical_trades(symbol: str, start_date: str, end_date: str, use_cache
150
460
 
151
461
  return parser.parse_get_historical_trades(start_date, end_date, html)
152
462
 
463
+
153
464
  def search_securities(query: str, use_cache=True):
154
465
  """Search securities by symbol or name (partial match)"""
155
466
 
@@ -157,8 +468,9 @@ def search_securities(query: str, use_cache=True):
157
468
  all_securities = get_securities()
158
469
 
159
470
  matches = [
160
- sec for sec in all_securities
471
+ sec
472
+ for sec in all_securities
161
473
  if query in sec["symbol"].lower() or query in sec["name"].lower()
162
474
  ]
163
475
 
164
- return matches
476
+ return matches
financegy/utils/utils.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import pandas as pd
3
3
 
4
+
4
5
  def to_dataframe(data: dict | list[dict]):
5
6
  """Output as Dataframe"""
6
7
 
@@ -8,13 +9,16 @@ def to_dataframe(data: dict | list[dict]):
8
9
  raise TypeError("All items in the list must be dictionaries")
9
10
  elif not isinstance(data, (dict, list)):
10
11
  raise TypeError("data must be a dict or a list of dicts")
11
-
12
+
12
13
  if isinstance(data, dict):
13
- data = [data]
14
+ data = [data]
14
15
 
15
16
  return pd.DataFrame(data)
16
17
 
17
- def save_to_csv(data, filename: str = "output.csv", path: str = None):
18
+
19
+ def save_to_csv(
20
+ data, filename: str = "output.csv", path: str = None, silent: bool = False
21
+ ):
18
22
  """Save a list of dicts to CSV"""
19
23
 
20
24
  if path is None:
@@ -28,13 +32,20 @@ def save_to_csv(data, filename: str = "output.csv", path: str = None):
28
32
 
29
33
  df.to_csv(full_path, index=False)
30
34
 
31
- print(f"Saved CSV to: {full_path}")
35
+ if not silent:
36
+ print(f"\nSaved CSV to: {full_path}")
32
37
 
33
38
  return True
34
39
 
35
- def save_to_excel(data: dict | list[dict], filename: str = "output.xlsx", path: str = None):
40
+
41
+ def save_to_excel(
42
+ data: dict | list[dict],
43
+ filename: str = "output.xlsx",
44
+ path: str = None,
45
+ silent: bool = False,
46
+ ):
36
47
  """Save data to an Excel spreadsheet."""
37
-
48
+
38
49
  if path is None:
39
50
  path = os.getcwd()
40
51
  else:
@@ -43,10 +54,8 @@ def save_to_excel(data: dict | list[dict], filename: str = "output.xlsx", path:
43
54
  full_path = os.path.join(path, filename)
44
55
  df = to_dataframe(data)
45
56
  df.to_excel(full_path, index=False)
46
-
47
- print(f"Saved Excel Document to: {full_path}")
48
-
49
- return True
50
-
51
57
 
58
+ if not silent:
59
+ print(f"\nSaved Excel Document to: {full_path}")
52
60
 
61
+ return True
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.4
2
+ Name: financegy
3
+ Version: 2.0
4
+ Summary: Unofficial Python library for accessing GSE (Guyana Stock Exchange) financial data
5
+ Author-email: Ezra Minty <ezranminty@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/xbze3/financegy
8
+ Project-URL: Issues, https://github.com/xbze3/financegy/issues
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: requests
12
+ Requires-Dist: beautifulsoup4
13
+ Requires-Dist: pandas
14
+ Requires-Dist: openpyxl
15
+ Dynamic: license-file
16
+
17
+ # 🏦 FinanceGY
18
+
19
+ **FinanceGY** is an unofficial Python library for accessing financial data from the **Guyana Stock Exchange (GSE)**. It provides a simple and consistent interface for retrieving information on traded securities, recent trade data, and session details, all programmatically.
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install financegy
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ import financegy
35
+
36
+ # --------------------------
37
+ # Core Data Retrieval
38
+ # --------------------------
39
+
40
+ # Get a list of all traded securities
41
+ securities = financegy.get_securities()
42
+
43
+ # Get the full name of a security by its ticker symbol
44
+ security_name = financegy.get_security_by_symbol("DDL")
45
+
46
+ # Get the most recent trade data for a security
47
+ recent_trade = financegy.get_recent_trade("DDL")
48
+
49
+ # Get the most recent closing/last trade price (same most-recent session)
50
+ previous_close = financegy.get_previous_close("DDL")
51
+
52
+ # Get absolute price change vs previous session close
53
+ price_change = financegy.get_price_change("DDL")
54
+
55
+ # Get percent price change vs previous session close
56
+ price_change_percent = financegy.get_price_change_percent("DDL")
57
+
58
+ # Get all trade data for the most recent year (for the security)
59
+ recent_year_trades = financegy.get_security_recent_year("DDL")
60
+
61
+ # Get trade data for a specific trading session (all securities)
62
+ session_trades = financegy.get_session_trades("1136")
63
+
64
+ # Get trade data for a specific security in a session
65
+ security_session_trade = financegy.get_security_session_trade("DDL", "1136")
66
+
67
+ # Search for securities by name or symbol
68
+ search_results = financegy.search_securities("DDL")
69
+
70
+ # Get all trades for a specific year
71
+ year_trades = financegy.get_trades_for_year("DDL", "2019")
72
+
73
+ # Get historical trades within a date range — supports: yyyy / mm/yyyy / dd/mm/yyyy
74
+ historical_trades = financegy.get_historical_trades(
75
+ symbol="DDL",
76
+ start_date="01/06/2020",
77
+ end_date="01/2022"
78
+ )
79
+
80
+ # --------------------------
81
+ # Analytics / Calculations
82
+ # --------------------------
83
+
84
+ # Get the latest session info (dict returned from most recent trade)
85
+ latest_session = financegy.get_latest_session_for_symbol("DDL")
86
+
87
+ # Average last traded price over a session range (inclusive)
88
+ avg_price_range = financegy.get_sessions_average_price("DDL", "1100", "1136")
89
+
90
+ # Average last traded price over the last N sessions (ending at latest session)
91
+ avg_price_latest = financegy.get_average_price("DDL", 30)
92
+
93
+ # Volatility over the last N sessions (weekly log-return volatility + annualized)
94
+ volatility = financegy.get_sessions_volatility("DDL", 30)
95
+
96
+ # Year-to-date high and low traded prices
97
+ ytd_high_low = financegy.get_ytd_high_low("DDL")
98
+
99
+ # --------------------------
100
+ # Utilities
101
+ # --------------------------
102
+
103
+ # Convert results to a DataFrame
104
+ df = financegy.to_dataframe(securities)
105
+
106
+ # Export to CSV / Excel
107
+ financegy.save_to_csv(securities, filename="securities.csv", silent=True)
108
+ financegy.save_to_excel(securities, filename="securities.xlsx", silent=True)
109
+
110
+ # Clear FinanceGY cache directory
111
+ financegy.clear_cache(silent=True)
112
+ ```
113
+
114
+ ---
115
+
116
+ ## API Reference
117
+
118
+ ### Core Data Retrieval
119
+
120
+ | Function | Description |
121
+ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
122
+ | `get_securities()` | Returns all currently traded securities on the GSE. |
123
+ | `get_security_by_symbol(symbol)` | Returns the full security name for a ticker symbol (e.g., `"DDL"` → `"Demerara Distillers Limited"`). |
124
+ | `get_recent_trade(symbol)` | Returns the most recent trade information for the given security. |
125
+ | `get_security_recent_year(symbol)` | Returns all trade data for the most recent year available for the selected security. |
126
+ | `get_session_trades(session)` | Returns trade data for **all** securities during a specific trading session. |
127
+ | `get_security_session_trade(symbol, session)` | Returns trade data for a **specific** security during a specific session. |
128
+ | `search_securities(query)` | Searches securities whose names or ticker symbols match the given query (partial match). |
129
+ | `get_trades_for_year(symbol, year)` | Returns all trade records for a specific security during a given year. |
130
+ | `get_historical_trades(symbol, start_date, end_date)` | Returns historical trades within the specified date range (`dd/mm/yyyy`, `mm/yyyy`, or `yyyy`). |
131
+
132
+ ### Analytics / Calculation Functions
133
+
134
+ | Function | Description |
135
+ | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
136
+ | `get_previous_close(symbol)` | Returns the most recent closing/last trade price for the security. |
137
+ | `get_price_change(symbol)` | Returns absolute price difference between the most recent trade and the previous session close. |
138
+ | `get_price_change_percent(symbol)` | Returns percent price change between the most recent trade and the previous session close. |
139
+ | `get_latest_session_for_symbol(symbol)` | Returns the latest trade dict for the symbol (includes the latest `session`). |
140
+ | `get_sessions_average_price(symbol, session_start, session_end)` | Returns the average last traded price over a session range (inclusive). |
141
+ | `get_average_price(symbol, session_number)` | Returns the average last traded price over the last **N** sessions ending at the latest session. |
142
+ | `get_sessions_volatility(symbol, session_number)` | Returns volatility over the last **N** sessions using log returns (weekly + annualized). |
143
+ | `get_ytd_high_low(symbol)` | Returns year-to-date highest and lowest traded prices for the security. |
144
+
145
+ ### Utilities
146
+
147
+ | Function | Description |
148
+ | ---------------------------------------------------------------------- | --------------------------------------------------------------- |
149
+ | `to_dataframe(data)` | Converts FinanceGY list/dict results into a `pandas.DataFrame`. |
150
+ | `save_to_csv(data, filename="output.csv", path=None, silent=False)` | Saves data to a CSV file. |
151
+ | `save_to_excel(data, filename="output.xlsx", path=None, silent=False)` | Saves data to an Excel file. |
152
+ | `clear_cache(silent=False)` | Completely clears the FinanceGY cache directory. |
153
+
154
+ ---
155
+
156
+ ## Caching System
157
+
158
+ FinanceGY includes a lightweight local caching system designed to speed up repeated requests and reduce unnecessary calls.
159
+
160
+ Whenever you call a data retrieval function (such as `get_securities()` or `get_recent_trade()`), FinanceGY automatically checks whether a cached response already exists for that specific query:
161
+
162
+ - If a valid cache file (less than 7 days old since sessions are held once per week) is found, the result is returned instantly from the cache.
163
+ - If the cache is missing, disabled, or older than one week, FinanceGY fetches fresh data from the GSE and updates the cache automatically.
164
+
165
+ All cache files are stored in a local `cache/` directory as small JSON files containing the retrieved data and a timestamp.
166
+
167
+ You can manually clear all cached data at any time:
168
+
169
+ ```python
170
+ import financegy
171
+
172
+ financegy.clear_cache()
173
+ ```
174
+
175
+ This will delete all cached files and force the next data request to fetch fresh data directly from the source.
176
+
177
+ If you prefer to bypass the cache for a specific call, simply pass `use_cache=False` to any function. For example:
178
+
179
+ ```python
180
+ # Force a fresh fetch from the GSE, ignoring cached data
181
+ recent_trade = financegy.get_recent_trade("DDL", use_cache=False)
182
+ ```
183
+
184
+ By default, caching is enabled for all supported functions unless explicitly turned off.
185
+
186
+ ---
187
+
188
+ ## License
189
+
190
+ This project is licensed under the **MIT License**
191
+
192
+ ---
193
+
194
+ ## Example Use Case
195
+
196
+ ```python
197
+ import financegy
198
+
199
+ ddl_recent = financegy.get_security_recent("DDL")
200
+ print(ddl_recent)
201
+ ```
@@ -0,0 +1,14 @@
1
+ financegy/__init__.py,sha256=d9oZzZVzAazdSqhHX3IdHV9bOChYMreOhmXaG64z8hE,1334
2
+ financegy/config.py,sha256=0kiLrY4FI07_wvpQcBlgzeMNLmDwaBa2dHV9rKk9rVM,193
3
+ financegy/cache/cache_manager.py,sha256=c-VW3tk2A-Z-hMrTN4d_OOB6Zse9r-hrAcNhpBY6Sjo,1840
4
+ financegy/core/parser.py,sha256=tU6bFDVTW6ztKeDWQBL7RuxJGTIjeGuMk3SUF_lTWKY,18181
5
+ financegy/core/request_handler.py,sha256=g0C0R-nvIvicAhxnCEAtTU8buVtzUn8725EERvBA6ZU,276
6
+ financegy/helpers/safe_text.py,sha256=pskFh-ejjVAR8f_NBL5x3EwuBtd9OocAKN6ozqNDPhs,141
7
+ financegy/helpers/to_float.py,sha256=PV0VCFE6KxWXa_5KBQv8eRDJuJ8UrmMtgzlSWDZSkL8,249
8
+ financegy/modules/securities.py,sha256=_1f0-aZI7xWH5ndk5KSRVkqage3OpMbxaIod4W1xBy8,14687
9
+ financegy/utils/utils.py,sha256=mqbjZ4em_a7rZyDgCjFswspEIL_WUPOXa8siAuxZuoY,1434
10
+ financegy-2.0.dist-info/licenses/LICENSE,sha256=HGLhx0fI215whUzIvTFdFivB447d_IdIIIRncUCQaEs,1088
11
+ financegy-2.0.dist-info/METADATA,sha256=x6PofU0FCiuMlzfUSdL58B7h11n-2_KVGt2uhvzsb4o,9674
12
+ financegy-2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
+ financegy-2.0.dist-info/top_level.txt,sha256=TpdYDxtK61m5xnvvzbqnDVJ82gphEqxnXN_Ur8rjvxQ,10
14
+ financegy-2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5