Skip to content

Finance Projects using Python. The purpose of this repository is to show how finance needs programming in order to analyze data more efficiently. Programming languages used: C, C++, Python

License

Notifications You must be signed in to change notification settings

arcelioeperez/Finance-Projects

Repository files navigation

License: MIT Lines of code

Finance Projects

Monte Carlo Simulation - Black-Scholes-Merton Put Option (European Option)

image

Continuous Compounding Interest Formula - Code in C++

A = Per*t

Daily Compounding:

A = P(1 + r/365)365*t

Monthly Compounding:

A = P(1 + r/12)12*t

Quaterly Compounding:

A = P(1 + r/4)4*t

Yearly Compounding:

A = P(1 + r)t

Where:
A = end amount
P = principal amount
e = Euler constant
r = rate of growth
t = time period

The e constant is defined as:

e - Mathematical Constant

To find r or t you have to use the natural logarithm -- std::log().

This program uses references and vectors instead of pointers and arrays -- initially it was done this way (using pointers and arrays), but I decided to change it to make it more compatible with C++.

Using arrays and pointers is allowed in C++, but it is more of a C implementation.

#compile with clang++ or g++
g++ compound_interest.cpp -o ci

#run 
./ci 

Compound Interest Formula- Code in C

Uses pointers and arrays.

Will try to add a struct that contains all the variables needed for the formula.

#compile with clang or gcc
gcc compound_interest.c -lm 

#run 
./a.out

Shorting the Market

Python script that shows what happens when short selling

Two methods:

  • Price if the stock increases
  • Price if the stock decreases

Results are a dataframe with the different price movements

Results image:
image

Options Analysis
Languages:

  • Python
  • Go

P/L -- profit/loss analysis
Greeks (Delta, Theta, Gamma, Vega, Rho) -- using the Black-Scholes formula and solving the derivation

d1 = (np.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))

Citation:
Python for Finance, Yves Hilpisch - O'reilly Books
Black-Scholes-Merton - UCD
Euler Methods - MIT
More Information on Growth Formula - Continuous Growth and Decay
Applied Finance Example - Certificates of Deposit
The C Programming Language Dennis Ritchie and Brian Kernighan - Pointers and Arrays (Chapter 5) - CS Princeton University
Euler Constant Image - CodeCogs
Short Example - Investopedia - Minimum Margin Requirements
Dynamic Hedging, Nassim Nicholas Taleb - Book

About

Finance Projects using Python. The purpose of this repository is to show how finance needs programming in order to analyze data more efficiently. Programming languages used: C, C++, Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published