Summary of Open source Financial computing learning (as of January 3, 2017)

Source: Internet
Author: User

This article was released under the Creative Commons license

Open source financial calculations are derived from open source numerical calculations. In fact, you need to learn the following to deal with financial calculations.

1, Linux/unix Basic command,
2, Shell basic programming (this may take you a day),
It's a good idea to learn at least one scripting language (Perl or Python is recommended) in addition to shell programming.
3, then according to your needs to choose to learn some of the following mathematical analysis software:
R,scilab,octave,c/c++ (although not "software", but most of the people who do financial mathematics use it to write algorithms, many investment banks, securities research department is also using it. Sometimes you have to use it when you have problems that can't be handled with the software above. But remember, we don't like to reinvent the wheel! )

The following is an introduction to the computational library of the largest cards in the Financial computing field: QuantLib

QuantLib is developed in C + + and is essentially a class library, so you need to use the tools it provides by creating an instance of the class. The tools it provides include many of the models we use in our usual economic and financial calculations (not all of which, of course, are quantlib for financial engineering) and very flexible. Here is a list of these modules (original and Chinese translation):
* Numeric Types
* Currencies and FX rates
* Date and time calculations
o Calendars
O Day Counters
* Pricing Engines
o Asian Option engines
o Barrier Option engines
O Basket Option Engines
o Cap/floor Engines
o Cliquet Option engines
o Forward Option engines
o Quanto Option engines
o swaption Engines
o Vanilla Option engines
* Finite-differences Framework
* Short-rate Modelling Framework
* Financial Instruments
* Lattice Methods
* Math Tools
* Monte Carlo Framework
* Design Patterns
* Stochastic Processes
* Term Structures
* Utilities
* QuantLib Macros
o Numeric Limits
o Debugging Macros
* Output manipulators
======== translation ===============
1. Number Type
2. Currency and exchange rate
3. Date and Time calculation
Calendar
Date Count
4. Pricing Engine
Asian Options Asian option
Barrier option barrier option
Combination option Basket option
Option Top/Bottom Cap/floor
Ratchet option Cliquet option
Forward option forward option
Two-Currency options quanto option
Interchangeable swaption
Simple option Vanilla option
5. Finite difference framework
6. Short-term interest rate modelling short-rate modelling framework
7. Financial Instruments
8, vortex lattice method lattice methods
9. Mathematical Tools
10. Monte Carlo Simulation Framework
11. Design mode
12. Stochastic process
13. Term structure
14. Toolbox
15. QUANTLIB macro
Digital limit
Debug macros
16. Output control

Next introduce Quant's hand tool-R

Those who do statistics and economic calculation must know eviews,spss,sas,s ... These calculation tools. They are commercial, they have to spend a lot of money to use, of course, piracy is not. But in my eyes, they all have such shortcomings:
Eviews, too simple, although in general teaching and academic research is enough, but very inflexible.

SPSS, the function is stronger than eviews, the operation is very simple, at the same time also has the high prestige in the international academia, but also is not flexible, the price is high.

SAS, carrier-grade products, powerful, complex modules, processing large data sets than EViews, SPSS much better. But in my eyes, its biggest disadvantage is not expensive, but the grammar of the backward! It actually has data step, process step these things. It has a very obvious symbol of the era of assembly language, grammar has fallen behind. The computer grammar is the embodiment of the design thought, its grammatical backwardness, indicates that its design thought has fallen behind.

S, in my opinion, is better than the above three products and the syntax is more elegant. But also because it is commercial software, you need to pay.

Now, you have another option, that is the R language (or environment), its syntax and s are basically the same, and in fact, the two languages are homologous, but one of the branches took the commercial Road, the other branch took the path of open source.
Let's take a look at its syntax, which we'll look at in a linear regression example, if you have a programming experience, it's very easy to read:
X<-c (1,2,3,4,5)
Y<-c (5,4,3,2,1)
E1<-y~1+x
LM (E1)

The first to second row creates a data series X, Y
The third line creates a regression formula, which is Y=A+BX (if you want to return to Y=BX, you have to use y~0+x if you have no intercept entries)
This formula is returned by the least squares method in the Forth line.
Its output is:

LM (formula = e1)

Coefficients:
(Intercept) x
6-1

I'm sure you know what that means, don't you?

Of course, this is a bit of learning than using EViews and SPSS, but it also fits well with our modeling thinking. Another advantage is that you can write these processes in a script ending in. R and store the data separately, each time you have new data to process, you just need to rerun the script, data analysis results, charts and so on immediately, without the need to import data like EViews and SPSS, Again and again the point of those buttons.

Of course, the way the data is stored, you can use text text, CSV files, XML files, and even, if your research is more serious, the amount of data is relatively large, the number of participants, you can create a database, R can be easily read from all these data sources to process the data.

However, R also has shortcomings. Because it works in a programmatic way, it's not as easy as eviews and SPSS, and some simple work can be faster with those graphical tools. In addition, it is not as good as the interactivity of our frequently used Excel and OpenOffice documents, although this drawback can be overcome by exporting those documents to text documents, but it is a disadvantage.

Here is the R code of a paper I've seen, which is a structural model that uses the two-phase least squares estimate, with parameters including exchange rates, interest rates, GDP, the Shanghai Composite Index ... And so on, the data and r programs are separate. The model itself has little reference, but it allows you to see how R handles this kind of problem.

Some comments are for source-readable, while others comment out the debug statements that you don't want to run, or the processing logic that is no longer needed.

#import data as mydata#becareful, the data file format may variousmydata<-read.table (file= "Release_new_1.csv", head =true,sep= ","); #add the gap of ICs and iamydata$igap<-mydata$ia-mydata$ic; #season adjustment, and smooth# "real", "bot" Mydata$real_sm<-filter (Mydata$real,rep (1/12,12)); Mydata$bot_sm<-filter (Mydata$bot,rep (1/12,12)); MyData <-mydata[6:81,1:19]; #Do regression with 2SLS manually#e1_adj<-real_sm~1+m2_fit+loan_fit+loan_1+ic; #e2_adj <-ind~1+M2_fit+loan_fit+loan_1+iC; #e3_adj <-f~1+real_fit+ind_fit+sp+iA+ex+bot; #e4_adj <-m2~1+f_fit+loan _fit+loan_1, #e5_adj <-loan~1+iC+req+cb_dep; #adjusted equationse1_adj<-real_sm~1+m2_fit+f_fit;e2_adj<- Ind~1+m2_fit+loan_fit+loan_1;e3_adj<-f~1+real_fit+ind_fit+ex+bot_sm;e4_adj<-m2~1+f_fit+loan_fit;e5_adj <-loan~1+iC+req+cb_dep+real_fit; #Get the fitted endogenous VALUES;MYDATA$REAL_FIT&LT;-LM (real_sm~ic+ex+bot_sm+ Req+cb_dep+loan_1,data=mydata) $fitted. VALUES;MYDATA$IND_FIT&LT;-LM (ind~ic+ex+bot_sm+req+cb_dep+loan_1, Data=mydata) $fitted. VALUES;MYDATA$F_FIT&LT;-LM (F~ic+ex+bot_sm+req+cb_dep+loan_1,data=mydata) $fitted. values; MYDATA$M2_FIT&LT;-LM (M2~ic+ex+bot_sm+req+cb_dep+loan_1,data=mydata) $fitted. VALUES;MYDATA$LOAN_FIT&LT;-LM (loan~ Ic+ex+bot_sm+req+cb_dep+loan_1,data=mydata) $fitted. values; #fit the equations with the fitted endogenous valuesres_e1_ ADJ&LT;-LM (E1_adj,data=mydata); Res_e2_adj<-lm (E2_adj,data=mydata); Res_e3_adj<-lm (e3_adj,data=mydata); res _E4_ADJ&LT;-LM (E4_adj,data=mydata); Res_e5_adj<-lm (E5_adj,data=mydata); #print (Summary (RES_E1_ADJ)); #print ( Summary (RES_E2_ADJ)), #print (Summary (RES_E3_ADJ)), #print (Summary (RES_E4_ADJ)), #print (Summary (RES_E5_ADJ)); simulatecoef_e1<-res_e1_adj$coefficients;coef_e2<-res_e2_adj$coefficients;coef_e3<-res_e3_adj$ Coefficients;coef_e4<-res_e4_adj$coefficients;coef_e5<-res_e5_adj$coefficients;#[real ind F M2 Loan], Endogenous Matrixmat_a<-matrix (Rep (0,0,25), 5,5) mat_a[1,]<-c (1,0,-coef_e1[' f_fit '],-coef_e1[' M2_fit '],0); Mat_a[2,]<-c (0,1,0,-coef_e2[' m2_fit '],-coef_e2[' loan_fit '); Mat_a[3,]<-c (-coef_e3[' real_fit '],-coef_e3[' Ind_fit '],1,0,0); mat _a[4,]<-c (0,0,-coef_e4[' f_fit '],1,-coef_e4[' loan_fit '); Mat_a[5,]<-c (-coef_e5[' Real_fit '],0,0,0,1); #[iC Ex bot req CB_DEP loan_1],exogenous Matrixmat_b<-matrix (0,5,6); mat_b[1,]<-c (0,0,0,0,0,0); Mat_B[2,]<-c ( 0,0,0,0,0,coef_e2[' loan_1 '); Mat_b[3,]<-c (0,coef_e3[' ex '],coef_e3[' Bot_sm '],0,0,0); Mat_b[4,]<-c ( 0,0,0,0,0,0); Mat_b[5,]<-c (coef_e5[' IC '],0,0,coef_e5[' req '],coef_e5[' CB_DEP '],0); #const matrixmat_c<- Matrix (0,5,1); Mat_c[1,]<-c (coef_e1[1]); Mat_c[2,]<-c (coef_e2[1]); Mat_c[3,]<-c (coef_e3[1]); Mat_C[4,] <-c (coef_e4[1]); Mat_c[5,]<-c (coef_e5[1]); #data Matrixmat_data<-matrix (0,76,6); mat_data[,1]<-mydata$ ic;mat_data[,2]<-mydata$ex;mat_data[,3]<-mydata$bot;mat_data[,4]<-mydata$req;mat_data[,5]<-mydata$ Cb_dep;mat_data[,6]<-mydata$loan_1;mat_fit<-matrix (0,76,5); for (I in 1: (Length (mat_data[,1))) {#mat_temp <-matrix (Mat_data[i,], 8,1); Mat_temp<-matrix (mat_data[i,],6,1); Mat_fit[i,]<-solve (mat_a)%*% (mat_c + mat_b%*% mat_temp);} Mat_endo<-matrix (0,76,5); mat_endo[,1]<-mydata$real_sm;mat_endo[,2]<-mydata$ind;mat_endo[,3]<- mydata$f;mat_endo[,4]<-mydata$m2;mat_endo[,5]<-mydata$loan; #effectmat_fit_m <-matrix (0,76,5); mat_ Effect<-matrix (0,length (mat_a[1,]), Length (mat_data[1,])-1); #This loop can simulate the system. #Each Simulation Would decrease a specified variable to 99% #while keep others invariable.for (n in 1: (Length (mat_data[1,])-1)) #get how many C Olums{temp<-mat_data[,n];mat_data[,n]<-mat_data[,n]*1.01;for (i in 1: (Length (mat_data[,1))) {#mat_temp <- Matrix (mat_data[i,],8,1); Mat_temp<-matrix (mat_data[i,],6,1); Mat_fit_m[i,]<-solve (mat_a)%*% (Mat_C + Mat_B%* % mat_temp);} Effect_real<-sum (mat_fit_m[,1]-mat_fit[,1])/sum (mat_fit[,1]); Effect_ind<-sum (mat_fit_m[,2]-mat_fit[,2])/ SUM (mat_fit[,2]); Effect_f<-sum (mat_fit_m[,3]-mat_fit[,3])/sum (mat_fit[,3]); Effect_m2<-sum (Mat_fit_m[,4]-mat_fit[,4])/sum (mat_fit[,4]); Effect_loan<-sum (mat_fit_m[,5]-mat_fit[,5])/sum (mat_fit[,5]); mat _effect[n,]<-c (Effect_real,effect_ind,effect_f,effect_m2,effect_loan); mat_data[,n]<-temp;} Print (Mat_effect), #均方根比 #print (sqrt (Mean (((mat_fit[,1]-mat_endo[,1))/mat_endo[,1)), #print (^2 (sqrt ((mean fit[,2]-mat_endo[,2]) (^2))), #print (sqrt (Mean (((mat_fit[,3]-mat_endo[,3))/mat_endo[,3))); Print (sqrt (Mean (((mat_fit[,4]-mat_endo[,4)/mat_endo[,4])), #print (^2 (sqrt (((mean))/ mat_endo[,5])) (^2));

  

Summary of Open source Financial computing learning (as of January 3, 2017)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.