cuemacro / finmarketpy

Python library for backtesting trading strategies & analyzing financial markets (formerly pythalesians)
http://www.cuemacro.com
Apache License 2.0
3.41k stars 490 forks source link

Chartpy - Empty chart #23

Open lefig opened 5 years ago

lefig commented 5 years ago

Hi there,

Firstly, thank you for three excellent projects. Only recently have I tried plotting a chart using Chartpy. And this has been unsuccessful. I am struggling to figure out why the chart output is not being rendered. I get a PNG and matplotlib display that is blank. The logs are:

2019-08-10 17:38:28,860 - findatapy.market.datavendorweb - INFO - Request AlphaVantage data 2019-08-10 17:38:30,496 - findatapy.market.datavendorweb - INFO - Completed request from Alpha Vantage for ['VUSA.open', 'VUSA.high', 'VUSA.low', 'VUSA.close', 'VUSA.volume'] 2019-08-10 17:38:32,513 - findatapy.market.ioengine - WARNING - Couldn't push MarketDataRequest_527abstract_curve_key-Nonealpha_vantage_api_key-xcategory-Nonecategory_key-backtest_default-cat_alphavantage_intraday_NYC_VUSAcut-NYCdata_source-alphavantageenvironment-backtestexpiry_date-NaTfields-open_high_low_close_volumefinish_date-2019-08-10 16:38:27_377636fred_api_key-xfreq-intradayfreq_mult-1__gran_freq-Nonequandl_api_key-xresample-Noneresample_how-laststart_date-2019-08-03 16:38:28_406628tickers-VUSAtrade_side-trade__vendor_fields-open_high_low_close_volumevendor_tickers-VUSA_L to Redis: Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it. 2019-08-10 17:38:32,749 - matplotlib.legend - WARNING - No handles with labels found to put in legend.

I would really appreciate any thoughts or suggestions.

Thanks

Fig

saeedamen commented 5 years ago

@lefig have you checked the dataframe is not empty? Eg. you can print it beforehand

lefig commented 5 years ago

Hi @saeedamen ,

Thank you for coming back to me. I am still investigating but am at present unable to download any data. I get a strange error...

File "c:\work\quant\python\data\findatapy\findatapy\market\datavendorweb.py", line 496, in load_ticker data_frame = data_frame.to_frame().unstack() File "C:\work\python\3.6.7\python-3.6.7.amd64\lib\site-packages\pandas\core\generic.py", line 5180, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'to_frame'

And the code responsible: if run_example == 1 or run_example == 0:

# downloaded S&P500
md_request = MarketDataRequest(
    start_date="decade",            # start date
    data_source='yahoo',            # use Bloomberg as data source
    tickers=['Apple'], # ticker (findatapy)
    fields=['close', 'open'],       # which fields to download
    vendor_tickers=['aapl'],   # ticker (Yahoo)
    vendor_fields=['Close', 'Open'])# which Bloomberg fields to download)

df = market.fetch_market(md_request)
saeedamen commented 5 years ago

Yahoo changed their API, so pandas_datareader, which broke findatapy's Yahoo downloader. I've rewritten the Yahoo downloader in findatapy to use yfinance (pip install yfinance). If you remove findatapy and install the latest version (with yfinance too), it should work.