Dax analysis in Python

What is a DAX?

The DAX is a stock exchange index consisting of the 30 major German blue chip companies trading on the Frankfurt stock market . it's a complete return index. Prices are taken from the Xetra trading venue.

How to analyze dax data in python?

!pip install yfinance

import math
import numpy as np
import pandas as pd
import pandas_datareader as web
import matplotlib.pyplot as plt

How to import dax data from yahoo finance?

import yfinance as yf

DAX = yf.download('^GDAXI',
 start='2010-01-01',
 end='2021-02-26',

 progress=False)

How to get a dax returns in python?

DAX['Returns'] = np.log(DAX['Close'] / DAX['Close'].shift(1))

plt.figure(figsize=(75))
plt.subplot(211)
DAX['Adj Close'].plot()
plt.title('DAX Index')
plt.subplot(212)
DAX['Returns'].plot()
plt.title('log returns')

How to plot log return and dax data in python?

plt.tight_layout()

Dax log return

S0 = DAX['Close'][-1]
vol = np.std(DAX['Returns']) * math.sqrt(252)
r = 0.01
K = 10000.
T = 1.0
M = 50 # number of time steps
dt = T / M # length of time interval
I = 10000 # number of paths to simulate
np.random.seed(5000# fixed seed value
# Simulation
S = np.zeros((M + 1, I), dtype=np.float# array for simulated DAX levels
S[0] = S0 # initial values
for t in xrange(1, M + 1):
ran = np.random.standard_normal(I) # pseudo-random numbers
S[t] = S[t - 1] * np.exp((r - vol ** 2 / 2) * dt
+ vol * math.sqrt(dt) * ran)
V0 = math.exp(-r * T) * np.sum(np.maximum(S[-1] - K, 0)) / I
h5file = pd.HDFStore('DAX_data.h5')
h5file['DAX'] = DAX
h5file.close()
DAX
OpenHighLowCloseAdj CloseVolumeReturns
Date
2010-01-045975.5200206048.2998055974.4301766048.2998056048.299805104344400NaN
2010-01-056043.9399416058.0200206015.6699226031.8598636031.859863117572100-0.002722
2010-01-066032.3901376047.5698245997.0898446034.3300786034.3300781087424000.000409
2010-01-076016.7998056037.5698245961.2500006019.3598636019.359863133704300-0.002484
2010-01-086028.6201176053.0400395972.2402346037.6098636037.6098631260990000.003027
........................
2021-02-1913941.40039114026.17968813892.71972713993.23046913993.230469729740000.007626
2021-02-2213858.55957013975.08007813802.54980513950.04003913950.04003966035300-0.003091
2021-02-2313984.98046913989.24023413664.70996113864.80957013864.80957088194700-0.006128
2021-02-2413855.84960913998.29980513855.84960913976.00000013976.000000689224000.007988
2021-02-2514045.01953114051.00976613879.16992213879.33007813879.33007895431900-0.006941

2824 rows × 7 columns

S0
13879.330078125
vol
0.20526795893307773
S
array([[13879.33007812, 13879.33007812, 13879.33007812, ..., 13879.33007812, 13879.33007812, 13879.33007812], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], ..., [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ], [ 0. , 0. , 0. , ..., 0. , 0. , 0. ]])
DAX['Close'].plot(label='DAX Index')
plt.legend(loc=0)
<matplotlib.legend.Legend at 0x7fad6c0ef090>
Dax index
DAX[['Close''Volume']].plot(subplots=True, style='b',
figsize=(128))
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7fad6bffe710>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7fad6c0341d0>],
      dtype=object)
Dax stock analysis
For all the new updates visit our github




 

Post a Comment

0 Comments