forked from thirumalairajr/finviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·27 lines (21 loc) · 787 Bytes
/
example.py
File metadata and controls
executable file
·27 lines (21 loc) · 787 Bytes
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
#!/usr/bin/python3
from finviz.screener import Screener
# Get dict of available filters
# filters dict contains the corresponding filter tags
filters = Screener.load_filter_dict()
some_filters = [filters["PEG"]["Under 1"], filters["Exchange"]["AMEX"]]
stock_list = Screener(filters=some_filters, order="ticker")
print(stock_list)
# Use raw filter tags in a list
# filters = ['geo_usa']
filters = ["idx_sp500"] # Shows companies in the S&P500
print("Screening stocks...")
stock_list = Screener(filters=filters, order="ticker")
print(stock_list)
print("Retrieving stock data...")
stock_data = stock_list.get_ticker_details()
print(stock_data)
# Export the screener results to CSV file
stock_list.to_csv("sp500.csv")
# Create a SQLite database
# stock_list.to_sqlite("sp500.sqlite")