This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import required modules | |
from bs4 import BeautifulSoup | |
import ast | |
import pandas as pd | |
import re | |
import requests | |
from datetime import datetime | |
def get_stock_price(ticker): | |
# pass a ticker name to i3investor website url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getJapReading(word) { | |
var url = "http://jisho.org/api/v1/search/words?keyword=" + word; | |
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true}); | |
var json = JSON.parse(response.getContentText()); | |
japReading = json.data[0].japanese[0].reading; | |
return japReading; | |
} | |
function getEnglishDef(word) { | |
var url = "http://jisho.org/api/v1/search/words?keyword=" + word; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_stock_price(ticker): | |
data = yf.download(ticker, start="2021-01-01") | |
return data | |
def add_EMA(price, day): | |
return price.ewm(span=day).mean() | |
def add_STOCH(close, low, high, period, k, d=0): | |
STOCH_K = ((close - low.rolling(window=period).min()) / (high.rolling(window=period).max() - low.rolling(window=period).min())) * 100 | |
STOCH_K = STOCH_K.rolling(window=k).mean() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function to check for EMA Bounce | |
def check_bounce_EMA(df): | |
candle1 = df.iloc[-1] | |
candle2 = df.iloc[-2] | |
cond1 = candle1['EMA18'] > candle1['EMA50'] > candle1['EMA100'] | |
cond2 = candle1['STOCH_%K(5,3,3)'] <= 30 or candle1['STOCH_%D(5,3,3)'] <= 30 | |
cond3 = candle2['Low'] < candle2['EMA50'] and \ | |
candle2['Close'] > candle2['EMA50'] and \ | |
candle1['Low'] > candle1 ['EMA50'] | |
return cond1 and cond2 and cond3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import yfinance as yf | |
def get_stock_list(): | |
# this is the website we're going to scrape from | |
url = "https://www.malaysiastock.biz/Stock-Screener.aspx" | |
response = requests.get(url, headers={'User-Agent':'test'}) | |
soup = BeautifulSoup(response.content, "html.parser") | |
table = soup.find(id = "MainContent2_tbAllStock") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import email | |
# you can add this part of code at the end of part 2 | |
# remember: screened_list contains the result of the screening | |
# configure email and message | |
msg = email.message_from_string(", ".join(screened_list)) | |
msg['From'] = '[email protected]' | |
msg['To'] = '[email protected]' | |
msg['Subject'] = "EMA Bounce Result for Today!" | |
s = smtplib.SMTP("smtp.gmail.com",587) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
def get_stock_list(): | |
# this is the website we're going to scrape from | |
url = "https://www.malaysiastock.biz/Stock-Screener.aspx" | |
response = requests.get(url, headers={'User-Agent':'test'}) | |
soup = BeautifulSoup(response.content, "html.parser") | |
table = soup.find(id = "MainContent2_tbAllStock") | |
# return the result (only ticker code) in a list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import required libraries | |
import pandas as pd | |
import yfinance as yf | |
import numpy as np | |
import math | |
# get stock prices | |
df = yf.download('AAPL', start='2020-01-01', threads= False) | |
# parameter setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# we are using mplfinance to help us visualize the indicator | |
import mplfinance as mpf | |
# to make the visualization better by only taking the last 100 rows of data | |
df = df[-100:] | |
# extract only ['Open', 'High', 'Close', 'Low'] from df | |
ohcl = df[['Open', 'High', 'Close', 'Low']] | |
# add colors for the 'value bar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from datetime import datetime | |
import yfinance as yf | |
import math | |
import matplotlib.pyplot as plt | |
def Supertrend(df, atr_period, multiplier): | |
high = df['High'] |
OlderNewer