如何从yahoo finance获取ticker并在OOP中使用TkInter和enable Entry小部件

如何从yahoo finance获取ticker并在OOP中使用TkInter和enable Entry小部件,tkinter,yahoo-finance,ticker,Tkinter,Yahoo Finance,Ticker,这是我的密码: from tkinter import * from tkinter import ttk import numpy as np import pandas as pd from scipy.stats import norm from pandas_datareader import data as wb import matplotlib.pyplot as plt % matplotlib inline from yahoofinancials import Yah

这是我的密码:

from tkinter import *
from tkinter import ttk

import numpy as np
import pandas as pd

from scipy.stats import norm

from pandas_datareader import data as wb
import matplotlib.pyplot as plt
% matplotlib inline

from yahoofinancials import YahooFinancials

from yahoo_fin import stock_info as si

from decimal import Decimal

import math


class Searcpages:

    def __init__(self, master):
        master.title('Searcpage'
        self.entry_stock = ttk.Entry(self.frame_content, width=30, font=('Arial', 15))
        self.entry_stock.grid(row=4, column=0, padx=15, columnspan=2)

        ttk.Button(self.frame_content, text='OK', command=self.ok).grid(row=6, column=0, padx=5, sticky='e')
        ttk.Button(self.frame_content, text='Clear', command=self.clear).grid(row=6, column=1, padx=5, sticky='w')

    def ok(self):
        tickers = [self.entry_stock]

        yahoo_financials = YahooFinancials(tickers)

        new_data = pd.DataFrame()
        for t in tickers: new_data[t] = wb.DataReader(t, data_source='yahoo', start='2004-1-1')['Adj Close']

        print(new_data[t])

        self.clear()

    def clear(self):
        self.entry_stock.delete(0, 'end')


def main():
    root = Tk()
    searchpage = Searcpages(root)
    root.mainloop()


if __name__ == "__main__": main()
它向我显示了以下问题:

文件“”,第73行,正常 yahoo_financials=YahooFinancials(股票代码)文件“/anaconda3/lib/python3.7/site packages/YahooFinancials/init.py”, 第78行,在init self.ticker=ticker.upper(),如果isinstance(ticker,str)else[t.upper()表示ticker]文件中的t “/anaconda3/lib/python3.7/site packages/yahoofinancials/init.py”, 第78行,输入 self.ticker=ticker.upper()(如果是instance(ticker,str)else[t.upper()表示ticker中的t]

“Entry”对象没有属性“upper”

然后我发现了下面的OOP yahoofinancials代码,这就是错误所说的,但是我不知道把我的Tkinter代码放在哪里,以便通过ticker合并来自yahoo Financials的数据。请帮助:

def __init__(self, ticker):

    self.ticker = ticker.upper() if isinstance(ticker, str) else [t.upper() for t in ticker]
    self._cache = {}

您试图对
条目
对象调用
upper()

要获取
条目的内容,请使用
Entry.get()


您试图对
条目
对象调用
upper()

要获取
条目的内容,请使用
Entry.get()

tickers = [self.entry_stock.get()]