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

Help, keep looping a future warning when running all strategies on script! #750

Closed
shingtat2 opened this issue Dec 28, 2023 · 4 comments
Closed
Labels
duplicate This issue or pull request already exists info Informational

Comments

@shingtat2
Copy link

shingtat2 commented Dec 28, 2023

Hi all,

Anyone can help on my issue?

environment
Python 3.10.11
Ta-lib installed

Code:

df.ta.strategy(verbose=False, append=True)

Keep looping below message and stuck forever:

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\multiprocessing\pool.py:48: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use ser.iloc[pos]
return list(map(*args))

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\multiprocessing\pool.py:48: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use ser.iloc[pos]
return list(map(*args))

Have tried all ways to disable warnings eg:

# Save the current warning settings
current_warnings = warnings.filters.copy()
# Suppress all warnings
warnings.filterwarnings('ignore')
# Redirect standard output to null
sys.stdout = open(os.devnull, 'w')
# Suppress logging
logger = logging.getLogger()
original_level = logger.getEffectiveLevel()
logger.setLevel(logging.CRITICAL + 1)
# Suppress only FutureWarnings
warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.simplefilter(action='ignore', category=all)
@twopirllc twopirllc added duplicate This issue or pull request already exists info Informational labels Dec 29, 2023
@twopirllc
Copy link
Owner

Hello @shingtat2,

This is a known Issue and is described in Issue #181 which is a pinned Issue at the TOP of the Issue list.

Kind Regards
KJ

@shingtat2
Copy link
Author

shingtat2 commented Dec 29, 2023

Hello @shingtat2,

This is a known Issue and is described in Issue #181 which is a pinned Issue at the TOP of the Issue list.

Kind Regards KJ

Yes I have read the post and solution to use main and my codes is already in def main(): but the issue still exist. Any other ways or tips to get it working?

def main():
    freeze_support()
    # Save the current warning settings
    current_warnings = warnings.filters.copy()
    # Suppress all warnings
    warnings.filterwarnings('ignore')
    # Redirect standard output to null
    sys.stdout = open(os.devnull, 'w')
    # Suppress logging
    logger = logging.getLogger()
    original_level = logger.getEffectiveLevel()
    logger.setLevel(logging.CRITICAL + 1)
    # Suppress only FutureWarnings
    warnings.simplefilter(action='ignore', category=FutureWarning)
    warnings.simplefilter(action='ignore', category=all)
    warnings.filterwarnings('ignore')

    try:
        df.ta.strategy(verbose=True, append=True)
    except Exception as e:
        # Handle any exception that might be raised
        print(f"An error occurred: {e}")
        
    # Restore the original warning settings
    warnings.filters = current_warnings
    

    print(df)

if __name__ == '__main__':
    main()

@twopirllc
Copy link
Owner

@shingtat2

For one thing, you should be using the development version for many reasons I will not include here.

Also, append=True is redundant when using df.ta.strategy() (or df.ta.study() in development). Either automatically appends to the DataFrame.

So change: df.ta.strategy(verbose=True, append=True) to df.ta.study(cores=0, verbose=True) (after installing the development branch.

Lastly, I recommend not using multiprocessing because it most cases it is not more performant.

@twopirllc
Copy link
Owner

Hello @shingtat2

I assume by no response that the solution provided was sufficient. Thus I will be closing this issue in a few days.

Kind Regards,
KJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists info Informational
Projects
None yet
Development

No branches or pull requests

2 participants