Giter Site home page Giter Site logo

Comments (6)

LeeDongGeon1996 avatar LeeDongGeon1996 commented on May 26, 2024

Hi, thank you for being our user and detail report. Based on my experience, it was not easy to troubleshoot when installing pythonnet.

There are two solutions for you:

  1. (RECOMMENDED)If you are available to use Conda environment, I recommend you to run conda install -c conda-forge pythonnet for pythonnet and use our current official release.
  2. Or, if you still want to install directly from the repo, you should build first and install the wheel by running:
    # Requirements: wheel
    # 3.6.1 is not official release version number, but needed for unofficial build. 
    python setup.py 0.6.1 bdist_wheel
    pip install dist/stock_indicators-0.6.1-py3-none-any.whl

from stock-indicators-python.

Smidelis avatar Smidelis commented on May 26, 2024

Thanks for your answer!

  1. I want to keep freqtrade as default as possible, so i tried without installing conda.
  2. Got it running with the following line in my custom dockerfile RUN git clone https://github.com/DaveSkender/Stock.Indicators.Python.git && cd Stock.Indicators.Python/ && python3 setup.py 0.6.1 bdist_wheel && pip3 install dist/stock_indicators-0.6.1-py3-none-any.whl

The build is completed now and i can run the freqtrade instance. Unfortunately the stock-indicator imports are throwing an error. Do i need to install anything else?

2022-03-28 20:19:23,716 - freqtrade.freqtradebot - INFO - Starting freqtrade docker-88f6663f
2022-03-28 20:19:23,993 - freqtrade.commands.trade_commands - ERROR - Could not find libmono
2022-03-28 20:19:23,993 - freqtrade.commands.trade_commands - ERROR - Fatal exception!
Traceback (most recent call last):
  File "/freqtrade/freqtrade/commands/trade_commands.py", line 18, in start_trading
    worker = Worker(args)
  File "/freqtrade/freqtrade/worker.py", line 35, in __init__
    self._init(False)
  File "/freqtrade/freqtrade/worker.py", line 52, in _init
    self.freqtrade = FreqtradeBot(self._config)
  File "/freqtrade/freqtrade/freqtradebot.py", line 58, in __init__
    self.strategy: IStrategy = StrategyResolver.load_strategy(self.config)
  File "/freqtrade/freqtrade/resolvers/strategy_resolver.py", line 44, in load_strategy
    strategy: IStrategy = StrategyResolver._load_strategy(
  File "/freqtrade/freqtrade/resolvers/strategy_resolver.py", line 190, in _load_strategy
    strategy = StrategyResolver._load_object(paths=abs_paths,
  File "/freqtrade/freqtrade/resolvers/iresolver.py", line 142, in _load_object
    (module, module_path) = cls._search_object(directory=_path,
  File "/freqtrade/freqtrade/resolvers/iresolver.py", line 124, in _search_object
    obj = next(cls._get_valid_object(module_path, object_name), None)
  File "/freqtrade/freqtrade/resolvers/iresolver.py", line 85, in _get_valid_object
    spec.loader.exec_module(module)  # type: ignore # importlib does not use typehints
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/freqtrade/user_data/strategies/Hasensachen_v0316.py", line 16, in <module>
    import stock_indicators.indicators as sta
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/indicators/__init__.py", line 1, in <module>
    from stock_indicators import _cslib
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/_cslib/__init__.py", line 12, in <module>
    import clr
  File "/home/ftuser/.local/lib/python3.9/site-packages/clr.py", line 6, in <module>
    load()
  File "/home/ftuser/.local/lib/python3.9/site-packages/pythonnet/__init__.py", line 36, in load
    set_default_runtime()
  File "/home/ftuser/.local/lib/python3.9/site-packages/pythonnet/__init__.py", line 22, in set_default_runtime
    set_runtime(clr_loader.get_mono())
  File "/home/ftuser/.local/lib/python3.9/site-packages/clr_loader/__init__.py", line 21, in get_mono
    libmono = find_libmono(sgen)
  File "/home/ftuser/.local/lib/python3.9/site-packages/clr_loader/util/find.py", line 67, in find_libmono
    raise RuntimeError("Could not find libmono")
RuntimeError: Could not find libmono

from stock-indicators-python.

LeeDongGeon1996 avatar LeeDongGeon1996 commented on May 26, 2024

Looks like the error is from pythonnet and it's telling you don't have Mono runtime on your system. To use pythonnet in Unix-based system, you must have Mono runtime installed.

(They have been trying to avoid Mono dependency. AFAIK, it is already available in their dev branch, but I'm not sure it will be compatible with stock-indicators.)

from stock-indicators-python.

Smidelis avatar Smidelis commented on May 26, 2024

Thanks for yor links, managed to get it installed from the mono-project page instructions.
Unfortunately getting a different error now.

2022-03-29 09:53:56,327 - freqtrade.strategy.strategy_wrapper - ERROR - Unexpected error No method matches given arguments for Add: (<class 'str'>) calling <bound method IStrategy._analyze_ticker_internal of <Hasensachen_v0316.Hasensachen_v0316 object at 0x7fee273716d0>>
Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote

The above exception was the direct cause of the following exception:

System.ArgumentException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote
   --- End of inner exception stack trace ---

The above exception was the direct cause of the following exception:

System.AggregateException: One or more errors occurred. ('str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote)) ---> System.ArgumentException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote
   --- End of inner exception stack trace ---<---


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/freqtrade/freqtrade/strategy/strategy_wrapper.py", line 21, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/strategy/interface.py", line 544, in _analyze_ticker_internal
    dataframe = self.analyze_ticker(dataframe, metadata)
  File "/freqtrade/freqtrade/strategy/interface.py", line 523, in analyze_ticker
    dataframe = self.advise_indicators(dataframe, metadata)
  File "/freqtrade/freqtrade/strategy/interface.py", line 921, in advise_indicators
    return self.populate_indicators(dataframe, metadata)
  File "/freqtrade/user_data/strategies/Hasensachen_v0316.py", line 234, in populate_indicators
    dataframe['sma'] = indicators.get_sma(dataframe, 20)
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/indicators/sma.py", line 33, in get_sma
    sma_list = CsIndicator.GetSma[Quote](CsList(Quote, quotes), lookback_periods)
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/_cstypes/list.py", line 34, in __new__
    clist.Add(i)
TypeError: No method matches given arguments for Add: (<class 'str'>)

The variable dataframe is a pandas dataframe containing the ohlcv data e.g. close price would be dataframe['close']. With dataframe['sma'] i'm adding another series with the sma values. I dont know what exactly you are expecting as quotes. Is this error related to the variable i'm passing to indicators.get_sma or is it a different one?

If this is getting to complicated now, i'd be fine if we close the issue. Was interested in some of your indicators but then i need to try to write them by myself or find a different library.

from stock-indicators-python.

LeeDongGeon1996 avatar LeeDongGeon1996 commented on May 26, 2024

Yeah, it's about the parameter. You are passing pandas.dataframe instance for quotes. But our library has its own Quote class, stock_indicators.indicators.common.quote.Quote. You have to pass Iterable object of our Quote instances. You can create like this:

from stock_indicators.indicators.common.quote import Quote

quotes = [ Quote(date, o, h, l, c, v) for date, o, h, l, c, v in your_feed ]        

Also, we already have well-organized documentation, please refer to:

from stock-indicators-python.

LeeDongGeon1996 avatar LeeDongGeon1996 commented on May 26, 2024

Thank you for the good first issue. If you have further questions, always welcome :)

from stock-indicators-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.