financegy 1.3__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.
financegy/__init__.py CHANGED
@@ -1,30 +1,48 @@
1
1
  """FinanceGY - a Python library for accessing data from the Guyana Stock Exchange."""
2
2
 
3
- from importlib.metadata import version, PackageNotFoundError
3
+ from financegy.cache.cache_manager import clear_cache
4
+ from financegy.utils.utils import save_to_csv, to_dataframe, save_to_excel
4
5
 
5
- from financegy.modules.securities import(
6
+ from financegy.modules.securities import (
6
7
  get_securities,
7
8
  get_security_by_symbol,
8
9
  get_recent_trade,
10
+ get_previous_close,
11
+ get_price_change,
12
+ get_price_change_percent,
9
13
  get_security_recent_year,
10
14
  get_session_trades,
15
+ get_sessions_average_price,
16
+ get_average_price,
17
+ get_sessions_volatility,
18
+ get_ytd_high_low,
19
+ get_latest_session_for_symbol,
11
20
  get_security_session_trade,
12
21
  search_securities,
13
22
  get_trades_for_year,
14
- get_historical_trades
23
+ get_historical_trades,
15
24
  )
16
25
 
17
- from financegy.cache.cache_manager import clear_cache
18
-
19
26
  __all__ = [
20
27
  "get_securities",
21
28
  "get_security_by_symbol",
22
29
  "get_recent_trade",
30
+ "get_previous_close",
31
+ "get_price_change",
32
+ "get_price_change_percent",
23
33
  "get_security_recent_year",
24
34
  "get_session_trades",
35
+ "get_sessions_average_price",
36
+ "get_average_price",
25
37
  "get_security_session_trade",
38
+ "get_latest_session_for_symbol",
39
+ "get_sessions_volatility",
40
+ "get_ytd_high_low",
26
41
  "search_securities",
27
42
  "get_trades_for_year",
28
43
  "get_historical_trades",
29
- "clear_cache"
44
+ "clear_cache",
45
+ "save_to_csv",
46
+ "to_dataframe",
47
+ "save_to_excel",
30
48
  ]
@@ -5,20 +5,18 @@ import shutil
5
5
  SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
6
6
  CACHE_DIR = os.path.join(SCRIPT_DIR, "cache")
7
7
 
8
+
8
9
  def make_cache_key(func_name, *args, **kwargs):
9
10
  """Create a unique hash for the given function call."""
10
11
 
11
- key_data = {
12
- "func": func_name,
13
- "args": args,
14
- "kwargs": kwargs
15
- }
12
+ key_data = {"func": func_name, "args": args, "kwargs": kwargs}
16
13
 
17
14
  key_string = json.dumps(key_data, sort_keys=True, default=str)
18
15
  hashed = hashlib.md5(key_string.encode()).hexdigest()
19
16
 
20
17
  return f"{func_name}_{hashed}.json"
21
18
 
19
+
22
20
  def load_cache(func_name, *args, max_age_days=7, **kwargs):
23
21
  os.makedirs(CACHE_DIR, exist_ok=True)
24
22
  cache_file = make_cache_key(func_name, *args, **kwargs)
@@ -36,18 +34,17 @@ def load_cache(func_name, *args, max_age_days=7, **kwargs):
36
34
 
37
35
  return data["value"]
38
36
 
37
+
39
38
  def save_cache(func_name, value, *args, **kwargs):
40
39
  os.makedirs(CACHE_DIR, exist_ok=True)
41
40
  cache_file = make_cache_key(func_name, *args, **kwargs)
42
41
  cache_path = os.path.join(CACHE_DIR, cache_file)
43
42
 
44
43
  with open(cache_path, "w") as f:
45
- json.dump({
46
- "timestamp": datetime.now().isoformat(),
47
- "value": value
48
- }, f)
44
+ json.dump({"timestamp": datetime.now().isoformat(), "value": value}, f)
49
45
 
50
- def clear_cache():
46
+
47
+ def clear_cache(silent: bool = False):
51
48
  """Completely clears the FinanceGY cache directory."""
52
49
  if not os.path.exists(CACHE_DIR):
53
50
  print("No cache directory found.")
@@ -55,8 +52,9 @@ def clear_cache():
55
52
 
56
53
  try:
57
54
  shutil.rmtree(CACHE_DIR)
58
- print("Cache cleared successfully.")
55
+ if not silent:
56
+ print("\nCache cleared successfully.")
59
57
  return True
60
-
58
+
61
59
  except Exception as e:
62
- print(f"Failed to clear cache: {e}")
60
+ print(f"Failed to clear cache: {e}")
financegy/config.py CHANGED
@@ -1,7 +1,7 @@
1
- __version__ = "0.1.0"
1
+ __version__ = "2.0"
2
2
 
3
3
  BASE_URL = "https://guyanastockexchangeinc.com"
4
4
  HEADERS = {
5
5
  "User-Agent": f"FinanceGY/{__version__} (https://github.com/xbze3/financegy)"
6
6
  }
7
- REQUEST_TIMEOUT = 10
7
+ REQUEST_TIMEOUT = 10