Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
loading data
#6
(Dec-09-2022, 07:50 PM)astral_travel Wrote: i'm trying to download stock data from yahoo! finance....
in anyway - i'm trying to have a symbol to download by loading the symbol/tickers from a file....

i know my code is awful, but i'll be glad to receive help:

import yfinance as yf
import pandas as pd
import plotly.graph_objects as go


def symbol_tracker(symbol):
    with open("/home/tal/investing/Ticker.csv", "r") as file:
        for line in file:
            if line != "\n":
                yf.download(symbol, start='1900-01-01')
            else:
                print("end of data")
                return line

symbol_tracker("/home/tal/investing/Ticker.csv") 

def symbol_saver(df):
    pass

fig = go.Figure(go.Candlestick(x=df.index,
  open=df['Open'],
  high=df['High'],
  low=df['Low'],
  close=df['Close']))
fig.show()
one additional element i need basically is saving the data onto csv files with having the name of files by their tickers...

i'll be glad for assistance with this...

thanks

I've spotted and error in your code...

def symbol_tracker(symbol):
    with open("/home/tal/investing/Ticker.csv", "r") as file:
        for line in file:
            if line != "\n":
                yf.download(symbol, start='1900-01-01')
            else:
                print("end of data")
                return line

# this call is passing the path and file name to your function. Should this not be a symbol name?
symbol_tracker("/home/tal/investing/Ticker.csv")
... which may or may not fix things; untested.

I don't use Pandas, so I'm unsure about the code from this point down.
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply


Messages In This Thread
loading data - by astral_travel - Dec-09-2022, 07:50 PM
RE: loading data - by Larz60+ - Dec-10-2022, 07:26 AM
RE: loading data - by astral_travel - Dec-10-2022, 11:55 AM
RE: loading data - by Larz60+ - Dec-10-2022, 02:59 PM
RE: loading data - by astral_travel - Dec-10-2022, 03:24 PM
RE: loading data - by rob101 - Dec-10-2022, 04:59 PM
RE: loading data - by astral_travel - Dec-10-2022, 05:17 PM
RE: loading data - by astral_travel - Dec-12-2022, 03:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Loading .csv data using Pandas zaki424160 1 3,680 Jul-15-2019, 09:48 AM
Last Post: perfringo
  Problem with saving data and loading data to mysql kirito85 4 5,465 Feb-08-2019, 10:53 AM
Last Post: kirito85
  Loading HUGE data from Python into SQL SERVER Sandeep 2 22,677 Jan-13-2018, 07:52 AM
Last Post: Sandeep

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020