zipline_polygon_bundle 0.1.6__tar.gz → 0.1.7__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.3
2
2
  Name: zipline_polygon_bundle
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: A zipline-reloaded data provider bundle for Polygon.io
5
5
  License: GNU AFFERO GENERAL PUBLIC LICENSE
6
6
  Version 3, 19 November 2007
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = 'zipline_polygon_bundle'
3
- version = '0.1.6'
3
+ version = '0.1.7'
4
4
  description = 'A zipline-reloaded data provider bundle for Polygon.io'
5
5
  authors = [
6
6
  { name = 'Jim White', email = 'jim@fovi.com' },
@@ -19,7 +19,7 @@ Repository = 'https://github.com/fovi-llc/zipline-polygon-bundle'
19
19
 
20
20
  [tool.poetry]
21
21
  name = 'zipline-polygon-bundle'
22
- version = '0.1.6'
22
+ version = '0.1.7'
23
23
  description = 'A zipline-reloaded data provider bundle for Polygon.io'
24
24
  authors = ['Jim White <jim@fovi.com>']
25
25
  license = 'AGPL-3.0'
@@ -64,8 +64,9 @@ def load_splits(
64
64
  splits["split_from"] = splits["split_from"].astype(float)
65
65
  splits["split_to"] = splits["split_to"].astype(float)
66
66
  splits["ratio"] = splits["split_from"] / splits["split_to"]
67
- splits.drop(columns=["ticker", "split_from", "split_to"], inplace=True)
68
- return splits
67
+ # Only return columns Zipline wants.
68
+ # Polygon may add more columns in the future (as they did with `id`).
69
+ return splits[["sid", "effective_date", "ratio"]]
69
70
 
70
71
 
71
72
  def load_polygon_dividends(
@@ -87,7 +88,9 @@ def load_polygon_dividends(
87
88
  dividends = pd.DataFrame(dividends)
88
89
  os.makedirs(os.path.dirname(dividends_path), exist_ok=True)
89
90
  dividends.to_parquet(dividends_path)
90
- print(f"Wrote {len(dividends)=} from Polygon list_dividends to {dividends_path=}")
91
+ print(
92
+ f"Wrote {len(dividends)=} from Polygon list_dividends to {dividends_path=}"
93
+ )
91
94
  # if len(dividends) < 10000:
92
95
  # logging.error(f"Only got {len(dividends)=} from Polygon list_dividends.")
93
96
  # We will always load from the file to avoid any chance of weird errors.
@@ -116,9 +119,9 @@ def load_chunked_polygon_dividends(
116
119
  next_end_date = first_of_next_month - datetime.timedelta(days=1)
117
120
  if next_end_date > last_end_date:
118
121
  next_end_date = last_end_date
119
- dividends_list.append(load_polygon_dividends(
120
- config, next_start_end, next_end_date
121
- ))
122
+ dividends_list.append(
123
+ load_polygon_dividends(config, next_start_end, next_end_date)
124
+ )
122
125
  next_start_end = next_end_date + datetime.timedelta(days=1)
123
126
  return pd.concat(dividends_list)
124
127
 
@@ -145,7 +148,8 @@ def load_dividends(
145
148
  },
146
149
  inplace=True,
147
150
  )
148
- dividends.drop(
149
- columns=["ticker", "frequency", "currency", "dividend_type"], inplace=True
150
- )
151
- return dividends
151
+ # Only return columns Zipline wants.
152
+ # Polygon may add more columns in the future (as they did with `id`).
153
+ return dividends[
154
+ ["sid", "ex_date", "declared_date", "record_date", "pay_date", "amount"]
155
+ ]