Skip to content

Commit 995585d

Browse files
handle stricter date parsing in pandas 2
1 parent da4daba commit 995585d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: trading_ig/rest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1694,9 +1694,11 @@ def mid_prices(self, prices, version):
16941694
if version == "3":
16951695
df = df.set_index("snapshotTimeUTC")
16961696
df = df.drop(columns=["snapshotTime"])
1697+
date_format = "%Y-%m-%dT%H:%M:%S"
16971698
else:
16981699
df = df.set_index("snapshotTime")
1699-
df.index = pd.to_datetime(df.index, format=DATE_FORMATS[int(version)])
1700+
date_format = DATE_FORMATS[int(version)]
1701+
df.index = pd.to_datetime(df.index, format=date_format)
17001702
df.index.name = "DateTime"
17011703

17021704
df["Open"] = df[["openPrice.bid", "openPrice.ask"]].mean(axis=1)

0 commit comments

Comments
 (0)