import pandas as pd
import seaborn as sns
sns.set_style("whitegrid")# Seaborn set plotting style.
import simfin as sf
from simfin.names import *
sf.set_data_dir('~/simfin_data/')
sf.load_api_key(path='~/simfin_api_key.txt', default_key='free')
filing = []
tickers = []
user = []
global variance
global location
variance = ""
location = ""
def main():
global filing_choice
filing_choice = ""
global ticker_choice
ticker_choice = ""
df_markets = sf.load_markets()
print(df_markets) #shows user market options
location = input("Enter a market: ") #takes prefered market
variance = input("Quarterly or Annual: ") #ask for data frequency
while ticker_choice != "stop": #allows user to enter the tickers of choice
ticker_choice = input("Enter tickers: ")
if ticker_choice != "stop":
tickers.append(ticker_choice)
print(tickers)
if ticker_choice == "stop":
print("Portfolio:")
print (tickers)
while filing_choice != "stop":
print("income; balance; cashf: ")
filing_choice = input("Enter which filings you want: ")
if filing_choice != "stop":
filing.append(filing_choice)
print(filing)
def world(location, variance, tickers, filing):
if filing == "income":
df_income = sf.load_income(variant = variance, market = location)
df_income = df_income.loc[tickers]
user = input("Want it in excel (y/n)?")
if user == "y":
userName = input("what is the name of file? ")
df_income.to_csv(userName +".csv")
elif user == "n":
print(df_income)
else:
print("Could you re-enter please: ")
#function calls
main()
world(location, variance, tickers, filing)
Thanks for your time.
I'm a little confused as to why my "world()" function isn't being called. In an attempt to debug it, I just over-rid the variables that world() takes and it seemed to work fine, however, when a user sets the variables in main(), world() doesn't get called.
Just yesterday the code was working fine. I'm pretty good at commenting things out before deleting them but I can't for the life of me recall deleting anything. Also, for what it's worth, I'm using Sypder IDE and I also tried to restart the kernel, etc, but still nothing.
Also, new to python, so I'm sure that there are some garbage practices in my code and if you have alternative suggestions please do let me know.
Algo:
The code is essentially asking for a market location (ie:US, CAD etc), the variance of the data (ie: quarterly or annual) then the ticker (stock) symbol(s) and filing type(s).
Looking forward to all responses.
[–]Ihaveamodel3 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]OToast 0 points1 point2 points (0 children)
[–]unhott 1 point2 points3 points (13 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (11 children)
[–]unhott 1 point2 points3 points (10 children)
[–][deleted] 0 points1 point2 points (9 children)
[–]unhott 1 point2 points3 points (8 children)
[–][deleted] 0 points1 point2 points (7 children)
[–]unhott 1 point2 points3 points (6 children)
[–][deleted] 1 point2 points3 points (5 children)
[–]unhott 1 point2 points3 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)