Share your repls and programming experiences

← Back to all posts
Live stock data
Foster_Bryant (96)

The data is basically live but it might be slightly delayed. Give feedback and/or suggestions please :)

NOTE: When entering the ticker don't put NASDAQ or anything like only the ticker. For example: AMD

Commentshotnewtop
JacksonCowie (281)

Awesome Job, the stocks are delayed by around 15 minutes anyway, since you are fetching it from the website, so a couple of seconds mean hardly anything.

Foster_Bryant (96)

@JacksonCowie Thanks for the feedback. Thanks for the info too

Foster_Bryant (96)

@JacksonCowie someone said u were a dweeb but they deleted their comment

kingretracted (17)

Very nice! I like the smooth look, etc. Good job!

mamamia5x (72)

This is really cool, is this just a bot that'll get the data?

Foster_Bryant (96)

@mamamia5x Thanks. It just scrapes yahoo finance for the data but I need to fix a problem when I get out of school because sometimes it wont update when its running.

mamamia5x (72)

@Foster_Bryant Yeah, it just happened to me. But it's still pretty cool.

PercyPotter (0)

Is there a way to make the ticker go faster?

Foster_Bryant (96)

@PercyPotter It's hard to optimize it but I will see what I can do.

JeremyIrwin (33)

how do you use this?

Foster_Bryant (96)

@JeremyIrwin Please tell me what you don't understand and I can help you. Thanks for the feedback.

JeremyIrwin (33)

@Foster_Bryant
1. what exactly does this do?
2. how do I do it?

Foster_Bryant (96)

@JeremyIrwin it just asks you for the amount of stocks you would like to see the price of and for example if you put 1 it will ask you to enter a ticker, for example AMD, and it will print a feed of its price and it updates automatically.

JeremyIrwin (33)

@Foster_Bryant it puts an error when I type in gamestop

Foster_Bryant (96)

@JeremyIrwin it has to be an ticker, To find the ticker of a company look up it's ticker. if you wanted to do gamestop it would be GME

CodeABC123 (212)

Not working(keeps asking me for the ticker.)

Foster_Bryant (96)

@CodeABC123 Oh. What integer did you enter for the amount input?

CodeABC123 (212)

I did not understand what you just said at all. @Foster_Bryant

Foster_Bryant (96)

@CodeABC123 The number that you enter at the start is the amount of times it will ask you for the ticker because It needs to add each one to a list. If you retry it should work hopefully. thanks for the feedback

CodeABC123 (212)

Oh... I guess it’s because I entered 55. @Foster_Bryant

ChezCoder (204)

Traceback (most recent call last):
File "main.py", line 38, in <module>
price = soup.find("div", {"class": "D(ib) Va(m) Maw(65%) Maw(60%)--tab768 Ov(h)"}).find("span")
AttributeError: 'NoneType' object has no attribute 'find'

Foster_Bryant (96)

@ChezCoder hmm that's weird I just tested it and it worked fine can you run it again and show me the full input u entered? thanks

Raniconduh (1)

it works but you just have to put AAPL instead of NASDAQ:AAPL for instance. @ChezCoder

Foster_Bryant (96)

@Raniconduh oh I see what he did wrong now lol. Yeah I should probably clarify that you only put the ticker

ChezCoder (204)

@Foster_Bryant sorry i didnt see ur msg, i think i did K and ESM
Edit: another error.....

Enter how many stocks would you like to look at: 2
Enter ticker #1: K
Enter ticker #2: ESM

The time zone for these dates are in universal time so the time might be slightly inaccurate for you until I
fix it but they should be atleast understandable.

NOTE: Red or green color doesn't mean the price has increased or decreased. The colors are only for style.

Ticker, Date, and Price:

K Jan 08 2020 00:21:45 $68.81
Traceback (most recent call last):
  File "main.py", line 40, in <module>
    price = soup.find("div", {"class": "D(ib) Va(m) Maw(65%) Maw(60%)--tab768 Ov(h)"}).find("span")
AttributeError: 'NoneType' object has no attribute 'find'
Foster_Bryant (96)

@ChezCoder Thanks for the feedback I am currently fixing something at the moment so I can't fix this right now.

ChezCoder (204)

@Foster_Bryant ok! I might just typed an incorrect ticker. But when that happens, you can do a try except loop that tells the user what has gone wrong instead of a flat error msg:)

Edit:Maybe you should clear the console everytime it re-prints the stock prices so its cleaner?

ex:

K Jan 08 2020 00:27:30 $68.81           <-- only displays these two
AAPL Jan 08 2020 00:27:31 $298.39  <-- only displays these two
Foster_Bryant (96)

@ChezCoder I was thinking about doing that earlier but was In school so I forgot lol. Thanks for the feedback I may do that later if I remember to.

ChezCoder (204)

@ChezCoder I am making a simulator in python. want to help? if u agree then I will tell u more about it in the colab because I dont want anybody knowing wut it is yet

Foster_Bryant (96)

@ChezCoder sure i can help add me if you want to :P

[deleted]

Really unclean code. I'm pretty sure yahoo finance should have an api...

Foster_Bryant (96)

@sanjaykdragon Yes but this is a way to do it completely for free lol

Foster_Bryant (96)

@sanjaykdragon Thanks for the feedback. How can I make this more clean?

[deleted]

@Foster_Bryant name the variables properly, actually use variables (wtf is [:19])

Foster_Bryant (96)

@sanjaykdragon :19 is just cutting off everything that is before the 19th index

Andi_Chin (143)

@sanjaykdragon lol stop trying to educate people when you don't even know anything.

[deleted]

@Andi_Chin from your post history and public repls, I can see you are probably in middle school. No need to flame someone with superior knowledge, just accept defeat and learn to better yourself.

MatthewDoan1 (305)

@sanjaykdragon

(wtf is [:19])

That's a pretty simple concept in Python, but you didn't know of it. I suppose this would make @Andi_Chin want to tell you to stop.

Foster_Bryant (96)

@MatthewDoan1 Hi there. Please tell me how to use polygott lol I want to use data from this python file to use on a simple html site

[deleted]

@MatthewDoan1 I know what it does, I mean why does he do it? Why does he skip the first 18 indexes? I can't tell from his code.

Foster_Bryant (96)

@sanjaykdragon I changed it to a better way but at first it was cus I was didn't want it to show miliseconds because it was really unneeded and up to the first 18 to 19 indexes was only the time up to seconds. Sorry for the confusion.

Foster_Bryant (96)

Alright I fixed it. The price updates while it's running so now it's functional.

YusufAhmed7 (0)

@Foster_Bryant i entered the name PINS and
Traceback (most recent call last):
File "main.py", line 38, in <module>
price = soup.find("div", {"class": "D(ib) Va(m) Maw(65%) Maw(60%)--tab768 Ov(h)"}).find("span")
AttributeError: 'NoneType' object has no attribute 'find'

Foster_Bryant (96)

@YusufAhmed7 for me when I entered just plain PINS when It said enter a ticker it worked just fine. If you send me a screenshot I can understand and fix it better thanks.