So I am using the code below to text me the price of a stock ticker symbol. The texting SMS message piece works fine. I also get the ticker symbol to output to the screen but I can not figure out how to add the variable to the body= section of code. If you notice I am trying to add the value of ‘market_price’ to the body of the text message. Can someone tell me what is missing? Thank you!
import os
from twilio.rest import Client
import yfinance as yf
ticker = yf.Ticker('NLST').info
market_price = ticker['regularMarketPrice']
previous_close_price = ticker['regularMarketPreviousClose']
print('Ticker: NLST')
print('Market Price:', market_price)
print('Previous Close Price:', previous_close_price)
account_sid = os.environ['TWILIO_ACCOUNT']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)
message = client.messages \
.create(
body="Nestlist stock price is {'market_price'}",
from_='+18886103854',
to='6786555555'
)
print(message.sid)