Hi, Shrewd!        Login  
Shrewd'm.com 
A merry & shrewd investing community
Best Of MI | Best Of | Favourites & Replies | All Boards | Post of the Week!
Search MI
Shrewd'm.com Merry shrewd investors
Best Of MI | Best Of | Favourites & Replies | All Boards | Post of the Week!
Search MI


Investment Strategies / Mechanical Investing
Unthreaded | Threaded | Whole Thread (8) |
Author: mechinv   😊 😞
Number: of 3957 
Subject: Re: Grabbing Market Data During Day
Date: 07/03/2024 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 https://finnhub.io/

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.

#https://pypi.org/project/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
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