Tutorial: Market Simulatorcobweb.cs.uga.edu/~maria/classes/8220-Spring-2017/slides/...Note: The...
Transcript of Tutorial: Market Simulatorcobweb.cs.uga.edu/~maria/classes/8220-Spring-2017/slides/...Note: The...
-
Tutorial:MarketSimulator
-
Outline
1. InstallPythonandsomelibraries2. DownloadTemplateFile3. DoMC1-P1together– hDp://quantsoGware.gatech.edu/MC1-Project-1– Edittheanalysis.pyfile
4. WatchVideos(Udacity)5. DoMC2-P1onyourown:
hDp://quantsoGware.gatech.edu/MC1-Project-1WhichisaMarketSimulator(itwillusethefuncTonsfromanalysis.py).[Project4]whichismorelikeahomework
-
Installa7on:Step1:InstallyourpythonplaUorm
a):InstallAnacondaStep2:InstallMarketSimulatorTemplates,Project4isPart1below.
Part1:Read.hDp://quantsoGware.gatech.edu/MC2-Project-1ItneedsSciPy—so:
Note:TheAnacondapythondistribu7onincludes *NumPy,Pandas,SciPy,Matplotlib,andPython,andover250morepackagesavailableviaasimple“condainstall”ItalsohasanIDE.Instructorgot2.7,andtheanacondadistribuTonofpython
TogettheappropriatesoGwareyou’llneed:
python(scripTnglanguage1301)sci.py(numericalrouTnes),num.py(matrices,linearalgebra),andmatplotlib(enablesgeneraTngplotsofdata)
InstallingPython(2.7)andOpenCV(3.1):(youonlyneeddoinstall(3)1)OpenCVSite(referenceonly–don’tneedthisforthisproject).
hDp://opencv.org/2)SciPy.orgsite,andlaunchedtoinstallaTonnotes:
hDp://scipy.org/install.html3)Anacondainstruc7onsiteincludinglotsoflibrarieswithpython.
hDps://docs.conTnuum.io/anaconda/install
MacInstallaTon:1)InstrucTonthattheinstructorused:
a)installedanaconda(gotrequiredpackages) hDps://www.conTnuum.io/downloads(2.7)includes,sci.py,num.py,andmathlplotlib
.
-
Videos• SignuponUdacity(Free):– hDps://classroom.udacity.com/courses/ud501/lessons/3909458794/concepts/42693317700923#
• CreateTheAnalysisToolRelevantVideos– 01-01–20minutes– 01-02–30minutes Pandas/Frames/Slices– 01-04–23minutes DailyReturns/CumulaTveReturns– 01-07–22minutes SharpRaTo(StaTsTcs)
• MarketSimulator– 02-02–27minutes MarketMechanics– hDps://www.youtube.com/watch?v=TstVUVbu-Tk(long)
-
• ReadStockDatafromaCSVFileandinputitintoapandasDataFrame– Pandas.DataFrame– Pands.read_csv
• Selectdesiredrowsandcolumns– Indexingandslicingdata– Gotchas:Label-basedslicingconvenTon
• VisualdatabygeneraTngplots– Ploong– Pandas.DataFrame.Plot– Matplot.pyplot.plot
-
• ScrapeS&P500TckerlistandindustrysectorsfromlistofS&P500companiesonWikipedia.– hDps://en.wikipedia.org/wiki/List_of_S%26P_500_companies
• DownloaddailyclosedataforeachindustrysectorfromYahoofinance– usingpandasDataReader.
• Adjusttheopen,highandlowdatausingtheraTooftheadjustedclosetoclose.
-
CommaSeparatedValues(.CSV)
• CSVFile• HeaderFiles• Lines/RowsofDates
• EachElementisseparatedbycolumns
-
WhatisinaHistoricalStockDataFile?
• #ofemployees• Date/Time• CompanyName• PriceoftheStock• Company’sHometown
-
StockDataFiles• Date• Open–pricestockopensatinthemorning,firstpriceintheday.
• High–highestpriceintheday• Low–lowestpriceintheday• Close–closingpriceat4PM.• Volume–howmanysharestradedalltogetherintheday.
• AdjustedClose–splits/anddividends–encapsulatestheincreaseinvalueifyouholdstockforalongTme.
-
GOOG.csv(fromYahoo).
• Newdatesontop,olderdescending.
-
• AdjustedClose--forstockssplitsanddividendpayments.
• CurrentDay–AdjCloseandClosearealwaysthesame,– ButaswegobackinTmestarttheytodiffer– ActualReturnsplitsthatisnotcapturedbyclosingprice.
-
Pandas:IncludedinAnaconda
• hDps://en.wikipedia.org/wiki/Pandas_(soGware)• DevelopedbyWesMcKinneywhileatAQRCapitalManagementtoanalyzefinancialdata– OpenSource.– NumericalTablesandTimeSeries– DataFrames• Slicing
– PanelData
-
DataFrame
• ETF– ExchangeTradedFundSPY
-
Warmup:Readingintoadataframe• InteracTvely
– Importpandas– Renameittopd
• ByaProgramseenextslide.
-
MakeitafuncTon
• readframe.py– Head,EnTreframe– df.head()
• QuesTon:Printlast5lines?
-
ManipulaTngFrames• Meanissimple• meanframe