Book contents
Appendix A - Computer Programs for Beginners
Summary
People think that computer science is the art of geniuses but the actual reality is the opposite, just many people doing things that build on each other, like a wall of mini stones.
Donald KnuthMathematica Codes for Finance
If you want to start the study of macro-econophysics, economics, finance, physics, statistics, and mathematics, through analysis of real data, Mathematica is a useful tool. Mathematica provides data and tools. We list a few useful commands for finance here.
In[1]:= SetDirectory[NotebookDirectory[]]
In[2]:= FinancialData[“Classes”]
In[3]:= FinancialData[“Exchanges”]
In[4]:= FinancialData[“NYSE*”]
In[5]:= Take[FinancialData[“NYSE*”], 20]
In[6]:= Take[FinancialData[“NASDAQ*”], 20]
In[7]:= Take[FinancialData[“∧*”], 20]
In[8]:= FinancialData[“NASDAQ:AAPL”, “Properties”]
In[9]:= FinancialData[“NASDAQ:AAPL”, “Name”]
In[10]:= FinancialData[“AAPL”, “Exchange”]
In[11]:= FinancialData[“∧DJI”, “Name”]
In[12]:= FinancialData[“SP500”, “Name”]
In[13]:= FinancialData[“∧GSPC”, “Name”]
In[14]:= FinancialData[“NASDAQ:AAPL”, “OHLCV”]
In[15]:= Take[FinancialData[“NASDAQ:AAPL”, “OHLCV”,All],20]
In[16]:= DateListPlot[FinancialData[“NASDAQ:AAPL”, All], PlotRange -> All]
In[17]:= Export[“Apple.csv”, FinancialData[“NASDAQ:AAPL”, “OHLCV”, All]]
In[18]:= DateListPlot[FinancialData[“NASDAQ:AAPL”, “Return”, All], PlotRange -> All]
In[19]:= data = FinancialData[“NASDAQ:AAPL”, “OHLCV”, All]; logret = Table[fdata[[i, 1]], Log[data[[i, 2, 4]]/data[[i, 2, 1]]]g, fi, Length[data]g]; Take[logret, 20] DateListPlot[logret, PlotRange -> All]
In[20]:= data = FinancialData[“NYSE:*“]; Take[data, 10] n = Length[data]
In[21]:= For[i = 1, i < 4, i++, Export[StringReplace[data[[i]], “NYSE:” -> ““] <> ”.csv”, FinancialData[data[[i]], “OHLCV”, All]]]
In[22]:= For[i = 1, i < n + 1, i++, Export[StringReplace[data[[i]], “NYSE:” -> ““] <> ”.csv”, FinancialData[data[[i]], “OHLCV”, All]]]
Tools for Network Analysis
Many tools for network analysis and visualization are available today. Readers are able to find them using a web search. Here we list a limited number of them based on a somewhat biased selection.
Pajek (http://mrvar.fdv.uni-lj.si/pajek)
Netminer (http://www.netminer.com)
UCINET (https://sites.google.com/site/ucinetsoftware)
These three are originally developed in sociology for social network analysis, while recent development enables faster computation for larger networks.
NetworkX (https://networkx.github.io)
Python library; network analysis and visualization, exible as a script language; also applicable to small-scale visualization. anaconda, all scientific libraries in a single package, includes this and the required libraries, and is better for easy installation.
igraph (http://igraph.org)
R library; network analysis and visualization, exible as a script language with abundant tools of R, statistical computing and graphics; easy to install. Python and C versions are also available.
Gephi (https://gephi.org)
Network visualization with basic tools of network analyses included; applicable to relatively large-scale networks.
- Type
- Chapter
- Information
- Macro-Econophysics , pp. 337 - 346Publisher: Cambridge University PressPrint publication year: 2017