MAINT: Fix failures/warnings in test_api_shim.py

- Fixes a warning on indexing with a float that ultimately came from
  pd.Timedelta.total_seconds().  Adds ``timedelta_to_integral_seconds``
  and ``timedelta_to_integral_minutes()`` functions and replaces various
  usages of ``int(delta.total_seconds())`` with them.

- Fixes a warnings triggered in ``_create_daily_stats`` from
  passing tz-aware datetimes to np.datetime64.
This commit is contained in:
Scott Sanderson
2016-07-15 12:16:19 -04:00
parent ccc31152a5
commit becf897da9
6 changed files with 73 additions and 34 deletions
+3 -2
View File
@@ -819,8 +819,9 @@ class TradingAlgorithm(object):
else:
self.risk_report = perf
daily_dts = [np.datetime64(perf['period_close'], utc=True)
for perf in daily_perfs]
daily_dts = pd.DatetimeIndex(
[p['period_close'] for p in daily_perfs], tz='UTC'
)
daily_stats = pd.DataFrame(daily_perfs, index=daily_dts)
return daily_stats