from jqdatasdk import *
auth('17099121314','gqs07070305799')
import akshare as ak
stock_zh_a_new_em_df = ak.stock_zh_a_new_em()
print(stock_zh_a_new_em_df)
stock_zh_index_spot_df = ak.stock_zh_index_spot()
print(stock_zh_index_spot_df)
stock_zh_index_daily_df = ak.stock_zh_index_daily(symbol="sz399552")
print(stock_zh_index_daily_df)
stock_zh_kcb_daily_df = ak.stock_zh_kcb_daily(symbol="sh688399", adjust="hfq")
#后复权因子:hfq_factor;前复权因子:qfq_factor
print(stock_zh_kcb_daily_df)
from pycaret.classification import *
crypto_js_spot_df = ak.crypto_js_spot()
print(crypto_js_spot_df)
stock_zh_a_spot_df = ak.stock_zh_a_spot()
print(stock_zh_a_spot_df)
stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol="000001", period="daily", start_date="20170301", end_date='20210907', adjust="qfq")
print(stock_zh_a_hist_df)
from jinja2 import Environment, PackageLoader
env = Environment()
template = env.from_string("""
<html>
<body>
Hello! Stocks in your portfolio comparing to 200 day moving average:<br>
<ul>
{% for result in results | sort(attribute='diff_relative') %}
<li>
<b>{{ result.ticker }}</b>{{"%.2f"|format(result.diff_relative)}}%
</li>
{% endfor %}
</ul>
</body>
</html>
""")
html = template.render(results=results)
import smtplib, ssl
from email.mime.multipart import MIMEMultipart
emails = ['your.email@email.com', 'anotheremail@email.com']
smtp_server = "smtp.gmail.com"
port = 587
sender_email = "yourcreatedaccount@gmail.com"
password = "replace-with-password"
context = ssl.create_default_context()
message = MIMEMultipart("alternative")
message["Subject"] = "Stock dip detector"
message["From"] = sender_email
part = MIMEText(html, "html")
message.attach(part)
server = smtplib.SMTP(smtp_server, port)
server.starttls(context=context)
server.login(sender_email, password)
server.sendmail(sender_email, emails, message.as_string())
import smtplib, ssl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# Note: secure web apps login needs to be turned off in Google settings. For production usage, replace this with OAuth flow.
# Enable the setting here: https://myaccount.google.com/u/2/lesssecureapps
smtp_server = "smtp.gmail.com"
port = 587 # For starttls
sender_email = "your-google-email-here"
password = "password-here" # Replace this with a real value
# Create a secure SSL context
context = ssl.create_default_context()
message = MIMEMultipart("alternative")
message["Subject"] = "Stock dip detector"
message["From"] = sender_email
# Note: we should also include a text version for email. For the simplicity of this, I omit this for now.
part = MIMEText(html, "html")
message.attach(part)
try:
server = smtplib.SMTP(smtp_server, port)
server.starttls(context=context)
server.login(sender_email, password)
server.sendmail(sender_email, emails, message.as_string())
except Exception as e:
# Throw the exception, so the scheduled run is stopped and we recieve a notification in our inbox.
raise e
finally:
server.quit()