# In recent years, a roaring economy and an empowered individual investor have sustained a record-breaking bull market's tenure. The empowerment of the individual investor has largely come from the momentum of the recovering market, but also from an increased access to financial information and agency. As the pool of competitors in the "Fintech" field increases, so does the information and agency at the disposal of the individual investor. However, as this happens, an opposite and potentially equal effect is observed - the amount of misinformation and agency at their disposal, also, increases. # # With the newfound volatility in the markets due to political uncertainty, speculation, and geo-political events, the question of discerning whether a security's price is value-justified becomes even more important. That is to say that a security worthy of a long position would be backed by healthy foundational data, and would not be generally correlated to media forecasts, or public speculations. # ## Case Study - TDG # For this case study, we'll analyze TransDigm Group (TDG). Having delivered consistent growth for the past 5 years, the company had several major dips in its share price during 2017. The hypothesis we'll interrogate is that these dips, and most major, drastic swings in share price are due to media noise, as opposed to an actual change in a company's value. # ## Global Definitions # The security to analyze, along with the date ranges for analysis are defined. A long, and short term period for analysis is defined to optimize computational resources during early research and data exploration. # In[1]: # Define Global Vairables stock_symbol = 'TDG' asset = symbols(stock_symbol) analysis_start = '2013-01-01' analysis_start_short = '2017-01-01' analysis_end = '2018-04-01' # In[2]: # Pipeline imports from quantopian.pipeline.filters import StaticAssets from quantopian.pipeline import Pipeline from quantopian.research import run_pipeline from quantopian.research import prices, returns, symbols # Fundamental & Technical Data
"V", "MA", "AAPL", "MSFT", "GOOG", "AMZN", "FB", "BRK-B", "BABA", "JPM", "XOM", "BAC", "MCD", "WMT", "HD", "CMG", "GM", "F", "TGT", "KO", "GIS", "MRO", "PSX", "AXP", "GS", "NDAQ", "ABC", "CELG", "CVS", "AAL", "BA", "GE", "LUV", "CTXS", "SHW", "AMT", "REG", "AEE", "EXC", "PCG", "UNP", "WM" ] #StocksTicker=['BTC',"ETH","LTC","BCH","EOS",'LINK','TRX'] Prices = [] CurrentPrices = [] DayBefore = [] Mean = [] Correlation = [] Order = [] df = pd.DataFrame(columns=StocksTicker) for x in StocksTicker: y = prices(assets=symbols(x), start='2019-04-24', end='2019-09-24', frequency='minute') df[x] = pd.Series( np.gradient( np.gradient( scipy.signal.savgol_filter(y, 31, 2, 0, 1.0, -1, 'interp', 0.0)))) corr = df.corr() #corr.describe() useless for us rn #can make it more legible if needed, #it will be much more easier from this to see the correlation
# coding: utf-8 # In[1]: ############INTRODUCTION######################## # Research environment functions from quantopian.research import prices, symbols # Pandas library: https://pandas.pydata.org/ import pandas as pd # Query historical pricing data for AAPL aapl_close = prices( assets=symbols('AAPL'), start='2013-01-01', end='2016-01-01', ) # Compute 50 and 200 day moving averages on # AAPL's pricing data aapl_sma50 = aapl_close.rolling(50).mean() aapl_sma200 = aapl_close.rolling(200).mean() # Combine results into a pandas DataFrame and plot pd.DataFrame({ 'AAPL': aapl_close, 'SMA50': aapl_sma50, 'SMA200': aapl_sma200 }).plot(
# Data Exploration from quantopian.research import returns, symbols # Select a time range to inspect period_start = '2014-01-01' period_end = '2014-12-31' # Query returns data for AAPL # over the selected time range aapl_returns = returns( assets=symbols('AAPL'), start=period_start, end=period_end, ) # Display first 10 rows aapl_returns.head(10) # Pipeline imports from quantopian.research import run_pipeline from quantopian.pipeline import Pipeline # Note that we import something called "Returns" this is different ... # ... different from the quantopian.research import returns, symbols idea! from quantopian.pipeline.factors import Returns from quantopian.pipeline.data.psychsignal import stocktwits # Pipeline definition # Looks like you need to make a pipeline each time you use it.
from quantopian.pipeline.factors import SimpleMovingAverage import pandas as pd import datetime # Research environment # Select a time range to inspect period_start = pd.Timestamp('2014-01-01') period_end = pd.Timestamp('2015-12-31') # Select a security ticker to inspect # Top choices: GOOG and GLD both perform well stock_symbol = 'QQQ' stock_close = prices(assets=symbols(stock_symbol), start=period_start, end=period_end) extremadataframe = pd.DataFrame({ 'price': [], 'type': [], 'trend': [], }, index=[]) orders = pd.DataFrame({ 'type': [], 'prev_exitgain': [], 'marker': [] }, index=[])
# Importar libreria de analisis de datos import pandas as pd # Importar componentes de la libreria de Quantopian from quantopian.research import prices, symbols # Obtener precios de cierre diario de una organización serie = prices( assets=symbols(acronimo), # Acronimo de la organización start='fecha_inicio', # 'AAAA-MM-DD' end='fecha_fin', # 'AAAA-MM-DD' ) # Obtener retornos diarios de una organización serie = returns( assets=symbols(acronimo), # Acronimo de la organización start='fecha_inicio', # 'AAAA-MM-DD' end='fecha_fin', # 'AAAA-MM-DD' ) # Obtener el numero de acciones negociadas serie = volumes( assets=symbols(acronimo), # Acronimo de la organización start='fecha_inicio', # 'AAAA-MM-DD' end='fecha_fin', # 'AAAA-MM-DD' ) # Obtener precios logatirmicos de cierre diario de una organización serie = log_prices( assets=symbols(acronimo), # Acronimo de la organización
@author: Hp """ ######################THIS PROJECT WILL WORK ONLY ON QUANTOPIAN##################### #SIMPLE MOVING AVERAGE CROSSOVER #Import the Libraries from quantopian.research import prices, symbols, returns import numpy as np import pandas as pd import matplotlib.pyplot as plt #CLOSING PRICES FOR PEPSI AND COKE FROM 2018 to MAY 2020 pep_close = prices(assets=symbols('PEP'), start='2018-01-01', end='2020-05-27') coke_close = prices(assets=symbols('KO'), start='2018-01-01', end='2020-05-27') #ROLLING WINDOW FOR 15 and 75 DAY MOVING AVERAGE FOR BOTH STOCKS pep_sma_15 = pep_close.rolling(window=15, min_periods=1, center=False).mean() coke_sma_15 = coke_close.rolling(window=15, min_periods=1, center=False).mean() pep_sma_75 = pep_close.rolling(window=75, min_periods=1, center=False).mean() coke_sma_75 = coke_close.rolling(window=75, min_periods=1, center=False).mean() #DATA FRAME TO CALCULATE THE SIGNALS (TRADING POINTS) trade_points = pd.DataFrame() #INITIALIZING THE DATA FRAME WITH THE 15- & 75-DAY MOVING AVERAGES trade_points['Pepsi_15_Day_SMA'] = pep_sma_15 trade_points['Pepsi_75_Day_SMA'] = pep_sma_75