ohlcutils 0.2.1__tar.gz → 0.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohlcutils
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A lightweight Python library for python utilities for holidays, dates, options and other tools
5
5
  Author-email: Pankaj Sharma <sharma.pankaj.kumar@gmail.com>
6
6
  License-Expression: MIT
@@ -98,17 +98,29 @@ def get_linked_symbols(short_symbol: str, complete=False) -> pd.DataFrame:
98
98
  """
99
99
  out = pd.DataFrame()
100
100
  end_time = dt.date.today().strftime("%Y-%m-%d")
101
+ # Several rows can share a symbol (NSE lists e.g. NOVARTIS and NOVARTIND -> EVONILE); take the latest
102
+ # row (by date, then file order) and stop on repeats so the chain can never loop forever.
101
103
  if complete:
104
+ seen = {short_symbol}
102
105
  while True:
103
106
  temp = symbolchange.loc[(symbolchange["oldsymbol"] == short_symbol) & (symbolchange["newsymbol"] != "")]
104
- if len(temp) == 1:
105
- short_symbol = temp["newsymbol"].item()
106
107
  if len(temp) == 0:
107
108
  break
109
+ temp = temp.sort_values("effectivedate", kind="stable").tail(1)
110
+ if temp["newsymbol"].item() in seen:
111
+ break
112
+ short_symbol = temp["newsymbol"].item()
113
+ seen.add(short_symbol)
108
114
 
115
+ seen = {short_symbol}
109
116
  while True:
110
117
  temp = symbolchange.loc[(symbolchange["newsymbol"] == short_symbol) & (symbolchange["oldsymbol"] != "")]
118
+ if len(temp) > 1:
119
+ temp = temp.sort_values("effectivedate", kind="stable").tail(1)
120
+ if len(temp) == 1 and temp.iloc[0]["oldsymbol"] in seen:
121
+ temp = temp.iloc[0:0]
111
122
  if len(temp) == 1:
123
+ seen.add(temp.iloc[0]["oldsymbol"])
112
124
  new_row = {
113
125
  "starttime": temp.iloc[0]["effectivedate"],
114
126
  "endtime": end_time,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohlcutils
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A lightweight Python library for python utilities for holidays, dates, options and other tools
5
5
  Author-email: Pankaj Sharma <sharma.pankaj.kumar@gmail.com>
6
6
  License-Expression: MIT
@@ -27,7 +27,7 @@ include-package-data = true
27
27
 
28
28
  [project]
29
29
  name = "ohlcutils"
30
- version = "0.2.1"
30
+ version = "0.2.2"
31
31
  description = "A lightweight Python library for python utilities for holidays, dates, options and other tools"
32
32
  readme = "README.md"
33
33
  license = "MIT"
File without changes
File without changes
File without changes
File without changes