Skip to content

Instantly share code, notes, and snippets.

View 2018kguo's full-sized avatar
🦎
whats up

Kevin Guo 2018kguo

🦎
whats up
View GitHub Profile
def get_last_crossing(df, days, symbol="", direction=""):
"""Searches for a crossing between two indicators for a given stock
Args:
df(pandas.core.frame.DataFrame): Pandas dataframe with columns containing the stock's prices, both indicators, and the dates
days(int): Specifies the maximum number of days that the cross can occur by
symbol(str): Symbol of the stock we're querying. Optional, used for printing purposes
direction(str): "above" if we are searching for an upwards cross, "below" if we are searching for a downwaords cross. Optional, used for printing purposes
Returns:
1 if the short-term indicator crosses above the long-term one
0 if there is no cross between the indicators
@2018kguo
2018kguo / RobinhoodEx1
Last active June 27, 2020 22:19
Get Robinhood portfolio and watchlist symbols
import robin_stocks as r
#Log in to Robinhood
#Put your username and password in a config.py file in the same directory (see sample file)
login = r.login(rh_username,rh_password)
def get_watchlist_symbols():
"""
Returns: the symbol for each stock in your watchlist as a list of strings
"""