numerical_methods_youtube's People
Forkers
ubergoober cniemans cfkuocfkuo nfodrea deus-ex-xi sharpkids paurichardson grantmac75 swsyoon atapritchard blondewithbrains franciscojunior zoakes gwoak owenwilsonwow baijuthomas528 hasanzad em5813 juliosdutra richterjan8005 xcycharles janwehrle99 jyotirm0y zekigungor arupdvsa eswar-abhi sasiain zedtdean usct01 butterfish13 sang3r kosiaroh erkundanec chawpohchia alexeysyrtsev anuraggupta704 sgpopuri liamdgray canbulajiji paulorodriguesxv kajhoog miali88 superbeanbatch moholtzberg pratikkamble24 merla ipuch sasmith-lokireddy 42kay rohandattatreya alexragomes mathiasrathje dai-momo coulibaly-b tweizy ruizj3 ashishnar sebastianlupuleasa zhihaooohe samchaaa ronniefu armandoamb aimabangay htright liea88 tyzhanghao23 danhphan stanleyrazor bnslj3234 nquan511 sparikh099 johncheong1234 felipecam5 yezhigangzju jandersonfb jorgeih giriposhaneshwar j-paredesc aitijhyamegaminx dangermousegithub dr11m trusharjadhav vidhan1400 xelhaku mohitwan lucimassa gkoutis-george jop611 jooj211 pertain99 ramji28 lowgrind minaiie bostrovsky kmsmgsh mxshen krishnakanhaiya cedricak alanmccann aiquantsnumerical_methods_youtube's Issues
Curve Fitting Battery Model - data file upload
Hello
Could you also upload the data files below that you used in Battery model ? Thank you.
Pull in experimental data for the open circuit potential
ocpp_data = np.loadtxt('positive.dat')
ocpn_data = np.loadtxt('negative.dat')
Visulaize our experimental data. We whish to pull model parameters, D_p, S_p and S_n from this data
data = np.loadtxt('experimental_data.dat')
root_finding/implied_volatility/find_vol.py: Sigma = nan if S>K
Only change made was S changed from 100 to 108.
from math import sqrt, exp, log, pi
from scipy.stats import norm
# Function to calculate the values of 21 and d2 as well as the call
# price. To extend to puts, one could just add a function that
# calculates the put price, or combine calls and puts into a single
# function that takes an argument specifying which type of contract one
# is dealing with.
def d(sigma, S, K, r, t):
d1 = 1 / (sigma * sqrt(t)) * ( log(S/K) + (r + sigma**2/2) * t)
d2 = d1 - sigma * sqrt(t)
return d1, d2
def call_price(sigma, S, K, r, t, d1, d2):
C = norm.cdf(d1) * S - norm.cdf(d2) * K * exp(-r * t)
return C
# Option parameters
S = 108.0
K = 105.0
t = 30.0 / 365.0
r = 0.01
C0 =2.30
# Prices used in comparison to live AAPL prices
#S = 194.11
#K = 210.0
#t = 38.0 / 365.0
#r = 0.01
#C0 = 1.50
# Tolerances
tol = 1e-3
epsilon = 1
# Variables to log and manage number of iterations
count = 0
max_iter = 1000
# We need to provide an initial guess for the root of our function
vol = 0.50
while epsilon > tol:
# Count how many iterations and make sure while loop doesn't run away
count += 1
if count >= max_iter:
print('Breaking on count')
break;
# Log the value previously calculated to computer percent change
# between iterations
orig_vol = vol
# Calculate the vale of the call price
d1, d2 = d(vol, S, K, r, t)
function_value = call_price(vol, S, K, r, t, d1, d2) - C0
# Calculate vega, the derivative of the price with respect to
# volatility
vega = S * norm.pdf(d1) * sqrt(t)
# Update for value of the volatility
vol = -function_value / vega + vol
# Check the percent change between current and last iteration
epsilon = abs( (vol - orig_vol) / orig_vol )
# Print out the results
print('Sigma = ', vol)
print('Code took ', count, ' iterations')
Sigma = nan
Code took 12 iterations
/srv/conda/envs/notebook/lib/python3.7/site-packages/ipykernel_launcher.py:64: RuntimeWarning: divide by zero encountered in double_scalars
/srv/conda/envs/notebook/lib/python3.7/site-packages/ipykernel_launcher.py:10: RuntimeWarning: invalid value encountered in double_scalars
Remove the CWD from sys.path while we load stuff.
P50 APPLICATION
Hello Kevin, I just found your YouTub Videos - Very Good!
I was looking at the video on Probability of Making 50% Max Profit. I loaded the code into my J Notebook and it ran. I modified the inputs for SPY short strangle and compared it to the same spread on the Tastyworks platform and there was a sig diff in the results. Befor I jump in to try to figure things out (I'm a Pyth Noob) I was wondering if you'd take a look.
10/30/2022
r=.0397
SPY
K_put = 365
K_call = 414
sigma = .2854
sigma_call = .2472
sigma_put = .3016
Total Price looks to be off along with PoP & P50
I would appreciate any insights
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.