Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: an integer is required (got type bytes) #693

Open
cdsmumbai opened this issue Aug 23, 2022 · 1 comment
Open

TypeError: an integer is required (got type bytes) #693

cdsmumbai opened this issue Aug 23, 2022 · 1 comment

Comments

@cdsmumbai
Copy link

Problem Description

Please provide a minimal, self-contained, and reproducible example:

[Paste code here]

import pyfolio as pf
Please provide the full traceback:

[Paste traceback here]
```---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-1977abd82007> in <module>
----> 1 import pyfolio as pf

~\anaconda3\lib\site-packages\pyfolio\__init__.py in <module>
----> 1 from . import utils
      2 from . import timeseries
      3 from . import pos
      4 from . import txn
      5 from . import interesting_periods

~\anaconda3\lib\site-packages\pyfolio\utils.py in <module>
     26 import empyrical.utils
     27 
---> 28 from . import pos
     29 from . import txn
     30 

~\anaconda3\lib\site-packages\pyfolio\pos.py in <module>
     20 
     21 try:
---> 22     from zipline.assets import Equity, Future
     23     ZIPLINE = True
     24 except ImportError:

c:\users\home\src\zipline-trader\zipline\__init__.py in <module>
     27 from .utils.numpy_utils import numpy_version
     28 from .utils.pandas_utils import new_pandas
---> 29 from .utils.run_algo import run_algorithm
     30 from ._version import get_versions
     31 

c:\users\home\src\zipline-trader\zipline\utils\run_algo.py in <module>
     22 from trading_calendars import get_calendar
     23 
---> 24 from zipline.data import bundles
     25 from zipline.data.benchmarks import get_benchmark_returns_from_file
     26 from zipline.data.data_portal import DataPortal

c:\users\home\src\zipline-trader\zipline\data\bundles\__init__.py in <module>
      1 # These imports are necessary to force module-scope register calls to happen.
----> 2 from . import quandl  # noqa
      3 from . import csvdir  # noqa
      4 from . import alpaca_api
      5 from . import alpha_vantage_api

c:\users\home\src\zipline-trader\zipline\data\bundles\quandl.py in <module>
     14 from trading_calendars import register_calendar_alias
     15 
---> 16 from . import core as bundles
     17 import numpy as np
     18 

c:\users\home\src\zipline-trader\zipline\data\bundles\core.py in <module>
     11 from toolz import curry, complement, take
     12 
---> 13 from ..adjustments import SQLiteAdjustmentReader, SQLiteAdjustmentWriter
     14 from ..bcolz_daily_bars import BcolzDailyBarReader, BcolzDailyBarWriter
     15 from ..minute_bars import (

c:\users\home\src\zipline-trader\zipline\data\adjustments.py in <module>
     27 from zipline.utils.pandas_utils import empty_dataframe
     28 from zipline.utils.db_utils import group_into_chunks, coerce_string_to_conn
---> 29 from ._adjustments import load_adjustments_from_sqlite
     30 
     31 log = Logger(__name__)

c:\users\home\src\zipline-trader\zipline\data\_adjustments.pyx in init zipline.data._adjustments()

c:\users\home\src\zipline-trader\zipline\assets\__init__.py in <module>
     20     make_asset_array,
     21 )
---> 22 from .assets import (
     23     AssetFinder,
     24     AssetConvertible,

c:\users\home\src\zipline-trader\zipline\assets\assets.py in <module>
     65     OrderedContracts,
     66 )
---> 67 from .asset_writer import (
     68     check_version_info,
     69     split_delimited_symbol,

c:\users\home\src\zipline-trader\zipline\assets\asset_writer.py in <module>
    451 
    452 
--> 453 class AssetDBWriter(object):
    454     """Class used to write data to an assets db.
    455 

c:\users\home\src\zipline-trader\zipline\assets\asset_writer.py in AssetDBWriter()
    462 
    463     @preprocess(engine=coerce_string_to_eng(require_exists=False))
--> 464     def __init__(self, engine, asset_finder=None):
    465         self.asset_finder = asset_finder
    466         self.engine = engine

c:\users\home\src\zipline-trader\zipline\utils\preprocess.py in _decorator(f)
    107             )
    108 
--> 109         return _build_preprocessed_function(
    110             f, processors, args_defaults, varargs, varkw,
    111         )

c:\users\home\src\zipline-trader\zipline\utils\preprocess.py in _build_preprocessed_function(func, processors, args_defaults, varargs, varkw)
    244 
    245     args['co_firstlineno'] = original_code.co_firstlineno
--> 246     new_func.__code__ = CodeType(*map(getitem(args), _code_argorder))
    247     return new_func

TypeError: an integer is required (got type bytes)






**Please provide any additional information below:**


## Versions

* Pyfolio version:      3
* Python version:      3.8.5
* Pandas version:      1.1.3
* Matplotlib version:  3.32
@maj-oliveira
Copy link

I think I'm having a similar problem.

`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[5], line 4
2 import pandas as pd
3 import pyodbc
----> 4 import pyfolio as pf
5 import yfinance as yf

File ~\AppData\Local\anaconda3\lib\site-packages\pyfolio_init_.py:3
1 import warnings
----> 3 from . import utils
4 from . import timeseries
5 from . import pos

File ~\AppData\Local\anaconda3\lib\site-packages\pyfolio\utils.py:28
24 from IPython.display import display, HTML
26 import empyrical.utils
---> 28 from . import pos
29 from . import txn
31 APPROX_BDAYS_PER_MONTH = 21

File ~\AppData\Local\anaconda3\lib\site-packages\pyfolio\pos.py:22
19 import warnings
21 try:
---> 22 from zipline.assets import Equity, Future
23 ZIPLINE = True
24 except ImportError:

File ~\AppData\Local\anaconda3\lib\site-packages\zipline_init_.py:21
17 import numpy as np
19 # This is not a place to dump arbitrary classes/modules for convenience,
20 # it is a place to expose the public interfaces.
---> 21 from trading_calendars import get_calendar
23 from . import data
24 from . import finance

File ~\AppData\Local\anaconda3\lib\site-packages\trading_calendars_init_.py:16
1 #
2 # Copyright 2018 Quantopian, Inc.
3 #
(...)
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
---> 16 from .trading_calendar import TradingCalendar
17 from .calendar_utils import (
18 clear_calendars,
19 deregister_calendar,
(...)
25 resolve_alias,
26 )
28 all = [
29 'clear_calendars',
30 'deregister_calendar',
(...)
37 'TradingCalendar',
38 ]

File ~\AppData\Local\anaconda3\lib\site-packages\trading_calendars\trading_calendar.py:33
30 from pandas.tseries.offsets import CustomBusinessDay
31 import toolz
---> 33 from .calendar_helpers import (
34 NP_NAT,
35 compute_all_minutes,
36 next_divider_idx,
37 previous_divider_idx,
38 )
39 from .utils.memoize import lazyval
40 from .utils.pandas_utils import days_at_time

File ~\AppData\Local\anaconda3\lib\site-packages\trading_calendars\calendar_helpers.py:6
2 import pandas as pd
4 NANOSECONDS_PER_MINUTE = int(6e10)
----> 6 NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
9 def next_divider_idx(dividers, minute_val):
11 divider_idx = np.searchsorted(dividers, minute_val, side="right")

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NaTType'`

when importing pyfolio with the most updated version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants