-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
51 lines (41 loc) · 1.38 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import re
import time
from collections import defaultdict
from datetime import datetime
import praw
import requests
from praw.models import MoreComments
from redditParser import RedditParser
import passwords
import polygonWrapper
# Reddit Parser Examples
reddit = praw.Reddit(
client_id=passwords.client_id,
client_secret=passwords.client_secret,
user_agent=passwords.user_agent
)
rparser = RedditParser(reddit)
subreddits = ["stocks", "SPACs", "wallstreetbets", "options"]
rparser.getRedditStockData(subreddits, printMe="clean",
limit=10, time_filter="day")
# Polygon Wrapper Examples
stocks = polygonWrapper.PolygonAPI(passwords.polygonAPIKey)
# Polygon Websocket API example
stocks.websocket_start()
stocks.websocket_client.subscribe("T.MSFT", "T.AAPL", "T.AMD", "T.NVDA")
time.sleep(1)
stocks.websocket_client.close_connection()
# Polygon Rest API example
resp = stocks.rest_client.stocks_equities_daily_open_close(
"AAPL", "2018-03-02")
print(f"On: {resp.from_} Apple opened at {resp.open} and closed at {resp.close}")
temp = stocks.rest_client.reference_market_status()
print(temp.market)
# How to check if ticker exists:
# Returns true if it is an available stock and false if its not
ticker = stocks.check_real_stock("AAPL")
print(ticker)
ticker = stocks.check_real_stock("FUCK")
print(ticker)
ticker = stocks.check_real_stock("GME")
print(ticker)