Python Forum
why is yfinance returning an ellipsis in the middle of ticket history - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: why is yfinance returning an ellipsis in the middle of ticket history (/thread-40163.html)



why is yfinance returning an ellipsis in the middle of ticket history - db042190 - Jun-12-2023

Hi , I tried my hand at a little loop in Python. I'm staying away from doing some of this redirecting in a shell language because ultimately i want to run this directly from power bi without yet another software middleman.

I created a driver file with tickers (tickers.txt). And am attempting to drive creation of ticker history from there in separate output ticker history files. As was the case from the command line, I'm getting an ellipsis in the middle of my history instead of all history in each file. Does anybody know why i'm getting ellipses and how to get all of history instead? I'm already gussingh that "max" parameter isnt what one would think.

import yfinance as yf
import sys

for line in open('C:\\Users\\stant\\OneDrive\\Documents\\daxandpython\\tickers.txt'):
tkr=yf.Ticker(line.strip("\n\r"))
with open('C:\\Users\\stant\\OneDrive\\Documents\\daxandpython\\yfinance\\'+line.strip("\n\r") +'.txt', 'w') as sys.stdout:
tkr.history(period="max")

[attachment=2402][attachment=2403]


RE: why is yfinance returning an ellipsis in the middle of ticket history - deanhystad - Jun-12-2023

Please use Python tags when posting code.

yfinance is not "returning" an ellipsis. The ellipsis is an artifact of converting the returned value of tkr.history() to a string suitable for printing. I am guessing that tkr.history() is returning a pandas DataFrame. You can configure Pandas to not use the ellipsis.
import pandas
pandas.set_option('display.max_rows', None)



RE: why is yfinance returning an ellipsis in the middle of ticket history - db042190 - Jun-12-2023

thank you Dean , that worked. Where can I read what / how to use python tags when posting?


RE: why is yfinance returning an ellipsis in the middle of ticket history - db042190 - Jun-12-2023

just trying out some tags...

import pandas
pandas.set_option('display.max_rows', None)
import yfinance as yf
import sys

for line in open('C:\\Users\\stant\\OneDrive\\Documents\\daxandpython\\tickers.txt'):
    tkr=yf.Ticker(line.strip("\n\r"))
    with open('C:\\Users\\stant\\OneDrive\\Documents\\daxandpython\\yfinance\\'+line.strip("\n\r") +'.txt', 'w') as sys.stdout:
         tkr.history(period="max")