Lumiwealth / quantstats_lumi

Apache License 2.0
53 stars 20 forks source link

Errors and warnings with noncompounded returns and sum() type functions #19

Closed kartiksubbarao closed 4 months ago

kartiksubbarao commented 4 months ago

I recently ran into similar warnings/errors for noncompounded returns similar to #11 (see below). The fixes are fairly straightforward, I will submit a pull request.

/path/to/python/lib/python3.12/site-packages/numpy/core/fromnumeric.py:86: FutureWarning: The behavior of DataFrame.sum with axis=None is deprecated, in a future version this will reduce over both axes and return a scalar. To retain the old behavior, pass axis=0 (or do not pass axis)
  File "/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/wrappers.py", line 555, in yearly_returns
    returns = returns.resample("YE").apply(_df.sum)
[...]
  File "/path/to/python/lib/python3.12/site-packages/pandas/core/frame.py", line 11657, in sum
    result = super().sum(axis, skipna, numeric_only, min_count, **kwargs)
             ^^^^^^^^^^^
TypeError: super(type, obj): obj must be an instance or subtype of type
/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py:426: FutureWarning: The provided callable <function sum at 0x7fb51bb2f2e0> is currently using DatetimeIndexResampler.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
  .apply(apply_fnc)
/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py:432: FutureWarning: The provided callable <function sum at 0x7fb51bb2f2e0> is currently using DatetimeIndexResampler.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
  returns.fillna(0).resample(resample).apply(apply_fnc).resample(resample).last()
/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py:1008: FutureWarning: The provided callable <function sum at 0x7fb51bb2f2e0> is currently using DatetimeIndexResampler.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
  port["Weekly"] = port["Daily"].resample("W-MON").apply(apply_fnc)
/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py:1011: FutureWarning: The provided callable <function sum at 0x7fb51bb2f2e0> is currently using DatetimeIndexResampler.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
  port["Monthly"] = port["Daily"].resample("ME").apply(apply_fnc)
/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py:1014: FutureWarning: The provided callable <function sum at 0x7fb51bb2f2e0> is currently using DatetimeIndexResampler.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
  port["Quarterly"] = port["Daily"].resample("QE").apply(apply_fnc)
/path/to/python/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py:1017: FutureWarning: The provided callable <function sum at 0x7fb51bb2f2e0> is currently using DatetimeIndexResampler.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "sum" instead.
  port["Yearly"] = port["Daily"].resample("YE").apply(apply_fnc)
kartiksubbarao commented 4 months ago

Pull request: https://github.com/Lumiwealth/quantstats_lumi/pull/20

kartiksubbarao commented 4 months ago

@grzesir I noticed that 0.1.11 was released today. Any chance you could take a look at #20 and see if it can be included in the next release?

kartiksubbarao commented 4 months ago

Fixed by #20