Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
webbrowser.get().open(url)
speak(f'Here is what I found for {search_term} on youtube')
# 7: get stock price
if there_exists(["price of"]):
search_term = voice_data.lower().split(" of ")[-1].strip() #strip removes whitespace after/before a term in string
stocks = {
"apple":"AAPL",
"microsoft":"MSFT",
"facebook":"FB",
"tesla":"TSLA",
"bitcoin":"BTC-USD"
}
try:
stock = stocks[search_term]
stock = yf.Ticker(stock)
price = stock.info["regularMarketPrice"]
speak(f'price of {search_term} is {price} {stock.info["currency"]} {person_obj.name}')
except:
speak('oops, something went wrong')
if there_exists(["exit", "quit", "goodbye"]):
speak("going offline")
exit()
def get_prices(
self, market: Market, interval: Interval, data_range: int
) -> MarketHistory:
self._wait_before_call(self._config.get_yfinance_api_timeout())
ticker = yf.Ticker(self._format_market_id(market.id))
# TODO check data_range and fetch only necessary data
data = ticker.history(
period="max", interval=self._to_yf_interval(interval).value
)
# Reverse dataframe to have most recent data at the top
data = data.iloc[::-1]
history = MarketHistory(
market,
data.index,
data["High"].values,
data["Low"].values,
data["Close"].values,
data["Volume"].values,
)
return history
continue
predicted_value = predictor.get_prediction(diff)
ticker = fc.getTickerFromCik(cik)
# print('cik: ', cik)
# print('ticker: ', ticker)
# print('current_date.hour: ', current_date.hour)
# print('days_since_last_filing: ', days_since_last_filing)
# print(diff[:100])
# print('predicted_value: ', predicted_value)
if predicted_value == 0:
try:
price = yf.Ticker(ticker).info['regularMarketPreviousClose']
except Exception as e:
print(e)
continue
quantity_to_buy = int(1000 / price)
print(ticker, quantity_to_buy)
if api.get_asset(ticker).tradable:
submitShort(api, ticker, quantity_to_buy)
print('length: ', len(diff))
except Exception as e:
print(e)
continue
def load(ticker_str):
ticker_str = ticker_str.upper()
ticker = yf.Ticker(ticker_str)
try:
data = ticker.info
except ValueError:
return None
history = ticker.history(period="1d")
current_price = history["Close"][0]
change = current_price - data["previousClose"]
change_percent = (change / data["previousClose"]) * 100
pile = urwid.Pile(
[
urwid.Text("STOCKI: The CLI Interface for fetching stock market data\n", align="center"),
urwid.Text(("title", "{} OVERVIEW".format(ticker_str))),
def download_returns(ticker, period="max"):
if isinstance(period, _pd.DatetimeIndex):
p = {"start": period[0]}
else:
p = {"period": period}
return _yf.Ticker(ticker).history(**p)['Close'].pct_change()