In [1]:
## FinancialSeries.jl api demo
using MarketData

In [30]:
#using FinancialSeries
include("../src/FinancialSeries.jl")


Warning: replacing module FinancialSeries

In [4]:
# example stock from MarketData
AAPL


Out[4]:
8336x12 TimeArray{Float64,2,DataType} 1980-12-12 to 2013-12-31

             Open      High      Low       Close     Volume          Ex-Dividend  Split Ratio  Adj. Open  Adj. High  Adj. Low  Adj. Close  Adj. Volume     
1980-12-12 | 28.75     28.88     28.75     28.75     2093900         0.0          1            3.3766     3.3919     3.3766    3.3766      16751200        
1980-12-15 | 27.38     27.38     27.25     27.25     785200          0.0          1            3.2157     3.2157     3.2004    3.2004      6281600         
1980-12-16 | 25.38     25.38     25.25     25.25     472000          0.0          1            2.9808     2.9808     2.9655    2.9655      3776000         
1980-12-17 | 25.88     26.0      25.88     25.88     385900          0.0          1            3.0395     3.0536     3.0395    3.0395      3087200         
⋮
2013-12-26 | 568.1     569.5     563.38    563.9     7286000         0.0          1            564.7392   566.1309   560.0471  560.564     7286000         
2013-12-27 | 563.82    564.41    559.5     560.09    8067300         0.0          1            560.4845   561.071    556.1901  556.7766    8067300         
2013-12-30 | 557.46    560.09    552.32    554.52    9058200         0.0          1            554.1621   556.7766   549.0525  551.2395    9058200         
2013-12-31 | 554.17    561.28    554.0     561.02    7967300         0.0          1            550.8916   557.9595   550.7226  557.7011    7967300         

In [31]:
# construct financial time series
Apple = TimeArray(AAPL.timestamp, AAPL.values, AAPL.colnames, FinancialSeries.Stock(FinancialSeries.Ticker("AAPL")))


Out[31]:
8336x12 FinancialTimeSeries for Stock, 1980-12-12 to 2013-12-31

ticker:         AAPL
currency:       USD
tick:           0.01
multiplier:     1.0

             Open    High    Low     Close   Volume        Ex-Dividend  Split Ratio  Adj. Open  Adj. High  Adj. Low  Adj. Close  Adj. Volume   
1980-12-12 | 28.75   28.88   28.75   28.75   2093900       0.0          1            3.38       3.39       3.38      3.38        16751200      
1980-12-15 | 27.38   27.38   27.25   27.25   785200        0.0          1            3.22       3.22       3.2       3.2         6281600       
1980-12-16 | 25.38   25.38   25.25   25.25   472000        0.0          1            2.98       2.98       2.97      2.97        3776000       
1980-12-17 | 25.88   26.0    25.88   25.88   385900        0.0          1            3.04       3.05       3.04      3.04        3087200       
⋮
2013-12-26 | 568.1   569.5   563.38  563.9   7286000       0.0          1            564.74     566.13     560.05    560.56      7286000       
2013-12-27 | 563.82  564.41  559.5   560.09  8067300       0.0          1            560.48     561.07     556.19    556.78      8067300       
2013-12-30 | 557.46  560.09  552.32  554.52  9058200       0.0          1            554.16     556.78     549.05    551.24      9058200       
2013-12-31 | 554.17  561.28  554.0   561.02  7967300       0.0          1            550.89     557.96     550.72    557.7       7967300       

In [19]:
typeof(Apple)


Out[19]:
TimeArray{Float64,2,Stock} (constructor with 1 method)

In [6]:
Apple.meta


Out[6]:
ticker:         AAPL
currency:       USD
tick:           0.01
multiplier:     1.0

In [7]:
timestamp(Apple)


Out[7]:
8336-element Array{Date,1}:
 1980-12-12
 1980-12-15
 1980-12-16
 1980-12-17
 1980-12-18
 1980-12-19
 1980-12-22
 1980-12-23
 1980-12-24
 1980-12-26
 1980-12-29
 1980-12-30
 1980-12-31
 ⋮         
 2013-12-13
 2013-12-16
 2013-12-17
 2013-12-18
 2013-12-19
 2013-12-20
 2013-12-23
 2013-12-24
 2013-12-26
 2013-12-27
 2013-12-30
 2013-12-31

In [22]:
Apple["Close"]


Out[22]:
8336x1 TimeArray{Float64,1,DataType} 1980-12-12 to 2013-12-31

             Close     
1980-12-12 | 28.75     
1980-12-15 | 27.25     
1980-12-16 | 25.25     
1980-12-17 | 25.88     
⋮
2013-12-26 | 563.9     
2013-12-27 | 560.09    
2013-12-30 | 554.52    
2013-12-31 | 561.02    

In [23]:
percentchange(Apple["Close"], method="log")


Out[23]:
8335x1 TimeArray{Float64,1,DataType} 1980-12-15 to 2013-12-31

             Close   
1980-12-15 | -0.0536 
1980-12-16 | -0.0762 
1980-12-17 | 0.0246  
1980-12-18 | 0.0282  
⋮
2013-12-26 | -0.0067 
2013-12-27 | -0.0068 
2013-12-30 | -0.01   
2013-12-31 | 0.0117