[英]Get variables from function input and text after
So id like to make varibles from my function input所以我喜欢从我的 function 输入中创建变量
So basically, the if statement should check if the varible is True or not.所以基本上,if 语句应该检查变量是否为真。 And i want to use the function input + ”-outcome” to check.
我想使用 function 输入 + “-outcome” 来检查。
Function-outcome = True
Function2-outcome = False
c
def a(B):
Global c
If f’{B}-outcome’ == True:
Print(”yes”)
Else:
Print(”no”)
a(”function”)
a(”function2”)
Here is an example, to make you understand my problem better!这是一个例子,让你更好地理解我的问题!
I've tried to find a solution but don't find it anywhere我试图找到解决方案,但在任何地方都找不到
Thanks!谢谢!
import yfinance as yf
from datetime import date
import pandas as pd
d_start = '2022-01-01'
d_end = date.today().strftime('%Y-%m-%d')
#top50 S&P to create a list, if you will use a variable from an API you will just need to declare it as a string
#you can create a list of your fav ones and it will work the same, I grabbed from this site because it was the top 50 easy to get
tl = pd.read_html('https://dailypik.com/top-50-companies-sp-500/')[0]['Symbol'].to_list()
def main(l, d_start, d_end):
#I used the download function here, you will use the one that will fulfill your aim, analysis, actions, balance_sheet
#for isntance df = yf.earnings
df = yf.download(str(l), start=d_start, end=d_end)
#you can't assign a variable with a fstring, the work around is name the df opening opportunities later on
df.name = l
return df
df_list = [main(k, d_start, d_end) for k in tl]
di_ticks = {k:v for k,v in zip([df_list[i].name for i in range(0, len(df_list))], df_list)}
#here you can pass any tick that you have in the tl(tick list)
di_ticks['MSFT']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.