# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import matplotlib.pyplot as plt
import gbm
import mgbm
import sgbm
import stdev
import simple_return as sr
import duration
# import durationNew
import numpy as np
import pandas as pd
import statistics as sc
from scipy.stats import kurtosis, skew

# N=10000;p=85
# mu=0.241851845471164
# si=0.07871329243839084
seed=range(0,201) 
dt=5./(250*360)
sdt=np.sqrt(dt)
t1=[]
t2=[]
t3=[]
t4=[]

x=pd.ExcelFile('/home/sharan/Desktop/Transport/IISER/ClusterOutput/Squeeze/Stat.xlsx')
page=x.parse(0)

tdrift=np.array(page.tdrift)
tvola=np.array(page.tvola)
Neach=np.array(page.N)
# print(len(tvola))

t1star=np.array(page.Mean)
t2star=np.array(page.SD)
t3star=np.array(page.Skew)
t4star=np.array(page.Kurtosis)
# print(t1star)

for i in range(18):
    N = Neach[i]
    mu = tdrift[i]
    si = tvola[i]
    GM_g=[]
    GS_g=[]
    GW_g=[]
    GK_g=[]    
#     print(i," ",N," ",mu," ",si)
    for j in range(0,200):
        sg=gbm.gbm(dt,N,mu,si,seed[j]) 
        ret_g=sr.s_ret(np.array(sg,dtype=float))
        ret_g=np.array(ret_g)
        L=len(ret_g)
        n=20
        new_ret_g=[np.array(ret_g[i:i+n]) for i in range(L-n)]
        Ln=len(new_ret_g)
        new_std_g=np.array([stdev.sd(new_ret_g[i]) for i in range(Ln)])
        volatility_g= new_std_g/sdt
        dur_g=duration.duration(np.array(volatility_g))
        dur_g=np.array(dur_g,dtype=float)
        GM_g.append(np.mean(dur_g))
        GS_g.append(stdev.sd(dur_g))
        GW_g.append(skew(dur_g))
        GK_g.append(kurtosis(dur_g,fisher=False))
    t1.append(GM_g)
    t2.append(GS_g)
    t3.append(GW_g)
    t4.append(GK_g)

writer=pd.ExcelWriter('/home/sharan/Desktop/Transport/IISER/ClusterOutput/Squeeze/GBM/t1FinalSqueeze.xlsx',engine='xlsxwriter')
df=pd.DataFrame({'IO1':t1[0],'IO2':t1[1],'IO3':t1[2],'IO4':t1[3],'IO5':t1[4],'IO6':t1[5],'IO7':t1[6],'IO8':t1[7],'IO9':t1[8],'I10':t1[9],'I11':t1[10],'I12':t1[11],'I13':t1[12],'I14':t1[13],'I15':t1[14],'I16':t1[15],'I17':t1[16],'I18':t1[17]},index=range(1,201))
df.to_excel(writer,sheet_name='sheet')
writer.save()

writer=pd.ExcelWriter('/home/sharan/Desktop/Transport/IISER/ClusterOutput/Squeeze/GBM/t2FinalSqueeze.xlsx',engine='xlsxwriter')
df=pd.DataFrame({'IO1':t2[0],'IO2':t2[1],'IO3':t2[2],'IO4':t2[3],'IO5':t2[4],'IO6':t2[5],'IO7':t2[6],'IO8':t2[7],'IO9':t2[8],'I10':t2[9],'I11':t2[10],'I12':t2[11],'I13':t2[12],'I14':t2[13],'I15':t2[14],'I16':t2[15],'I17':t2[16],'I18':t2[17]},index=range(1,201))
df.to_excel(writer,sheet_name='sheet')
writer.save()

writer=pd.ExcelWriter('/home/sharan/Desktop/Transport/IISER/ClusterOutput/Squeeze/GBM/t3FinalSqueeze.xlsx',engine='xlsxwriter')
df=pd.DataFrame({'IO1':t3[0],'IO2':t3[1],'IO3':t3[2],'IO4':t3[3],'IO5':t3[4],'IO6':t3[5],'IO7':t3[6],'IO8':t3[7],'IO9':t3[8],'I10':t3[9],'I11':t3[10],'I12':t3[11],'I13':t3[12],'I14':t3[13],'I15':t3[14],'I16':t3[15],'I17':t3[16],'I18':t3[17]},index=range(1,201))
df.to_excel(writer,sheet_name='sheet')
writer.save()

writer=pd.ExcelWriter('/home/sharan/Desktop/Transport/IISER/ClusterOutput/Squeeze/GBM/t4FinalSqueeze.xlsx',engine='xlsxwriter')
df=pd.DataFrame({'IO1':t4[0],'IO2':t4[1],'IO3':t4[2],'IO4':t4[3],'IO5':t4[4],'IO6':t4[5],'IO7':t4[6],'IO8':t4[7],'IO9':t4[8],'I10':t4[9],'I11':t4[10],'I12':t4[11],'I13':t4[12],'I14':t4[13],'I15':t4[14],'I16':t4[15],'I17':t4[16],'I18':t4[17]},index=range(1,201))
df.to_excel(writer,sheet_name='sheet')
writer.save()

StarcoderdataJupyterScriptsDedupFiltered