Hi, Shrewd!        Login  
Shrewd'm.com 
A merry & shrewd investing community
Best Of MIBest OfAll BoardsThe Shrewd’m WeeklyLearn to InvestHow to Become Shrewd
Search
Shrewd'm.com Merry shrewd investors
Search
Best Of MIBest OfAll BoardsThe Shrewd’m WeeklyLearn to InvestHow to Become Shrewd


The week's question
In December 2024, in the thread "Re: BRK: Why Not XOM?", BreckHutHigh asked the members: "What about the long road trips with kids?" This week it is put to everyone again. The button below opens the small thread re-asking it - read what others have said so far, then give your own answer as an ordinary reply.
Answer this questionContinue to Shrewd'mThis note won't appear again
Investment Strategies / Mechanical Investing
Unthreaded | Threaded | Whole Thread (8) |
Author: mechinv   😊 😞
Number: of 6131 
Subject: Re: Grabbing Market Data During Day
Date: 07/03/24 6:59 AM
Post New | Post Reply | Report Post | Recommend It!
No. of Recommendations: 9
Any recommendations on the best way to [grab market data during the day]?

I use finnhub.io to subscribe to realtime streaming quotes for free. You can sign up in 15 seconds at finnhub.io: Finnhub Stock APIs - Real-time stock prices, Company fundamentals, Estimates, and Alternative data.

Gives you realtime prices every second plus open/low/high/close/volume on any ticker you want. I use it to calc

You need to have some familiarity with Python. For example, my Python programs calculate 50-day moving averages on the stocks I own, and can automatically send buy/sell and stop/loss orders to my broker.

These days, with Generative AI tools you can use Amazon Q Developer or Microsoft Copilot to generate and explain the code you need. The Finnhub API uses Websockets, which is pretty fast.

The below code, for example, gets real time prices on AAPL and AMZN for free.

#pypi.org - Websocket client
import websocket

def on_message(ws, message):
print(message)

def on_error(ws, error):
print(error)

def on_close(ws):
print("### closed ###")

def on_open(ws):
ws.send('{"type":"subscribe","symbol":"AAPL"}')
ws.send('{"type":"subscribe","symbol":"AMZN"}')

if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://ws.finnhub.io?token=cq02qp9r01qkg1bdubkgcq02qp9r01qkg1bdubl0",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever()

Post New | Post Reply | Report Post | Recommend It!
Print the post
Members reply directly to mechinv here — and replies get answered. Reading is free; so is joining the conversation. Join Shrewd'm »
This community has written 6,115 posts about Mechanical Investing. The article-length ones it recommended most:
Dividend investing · 52 recs · 2025
Non-Mag7 screen · 34 recs · 2025
OT - Div yields and returns · 32 recs · 2024
Using AI to generate backtesting programs · 30 recs · 2025
Rankings for 19Dec2022 · 29 recs · 2022
Unthreaded | Threaded | Whole Thread (8) |


Announcements
Mechanical Investing FAQ
Contact Shrewd'm
Contact the developer of these message boards.

Best Of MI | Best Of | Favourites & Replies | All Boards | Followed Shrewds | Open Questions | Moving a community