VAR模型风险计量分析简单整理

最近帮朋友研究一个海龟期货模型,一直以为模型是模型,原来该模型是一种策略,并非模型。在此记录下成长了金融期货的知识,满满的干货,简单记录方便日后回顾。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

data1=read_excel("检验(0.2,0).xlsx")
str(data1)
data=data1[1:3]
data1=data[-2]

y=data1$每日收益率
t=data1$时间
str(data)
length(y)
mean(y)
mean.fun <- function(d, i) 
{    m <- mean(y[i])
     n <- sd(y[i])
     v <- (n-1)*var(y[i])/n^2
     return(c(m,n,v))
}

mean.fun (y,1:500)

air.boot <- boot(data, mean.fun, R = 500)
print(air.boot)

data1=read_excel("检验(0.2,0.1)策略.xlsx")
str(data1)
data=data1[1:3]
data1=data[-2]

y=data1$每日收益率
t=data1$时间
str(data)
length(y)
mean(y)
mean.fun <- function(d, i) 
{    m <- mean(y[i])
     n <- sd(y[i])
     v <- (n-1)*var(y[i])/n^2
     return(c(m,n,v))
}

mean.fun (y,1:500)

air.boot <- boot(data, mean.fun, R = 500)
print(air.boot)

data1=read_excel("检验(0.2,0.2)策略.xlsx")
str(data1)
data=data1[1:3]
data1=data[-2]

y=data1$每日收益率
t=data1$时间
str(data)
length(y)
mean(y)
mean.fun <- function(d, i) 
{    m <- mean(y[i])
     n <- sd(y[i])
     v <- (n-1)*var(y[i])/n^2
     return(c(m,n,v))
}

mean.fun (y,1:500)

air.boot <- boot(data, mean.fun, R = 500)
print(air.boot)

data1=read_excel("检验(0.5,0)策略 (1).xlsx")
str(data1)
data=data1[1:3]
data1=data[-2]

y=data1$每日收益率
t=data1$时间
str(data)
length(y)
mean(y)
mean.fun <- function(d, i) 
{    m <- mean(y[i])
     n <- sd(y[i])
     v <- (n-1)*var(y[i])/n^2
     return(c(m,n,v))
}

mean.fun (y,1:500)

air.boot <- boot(data, mean.fun, R = 500)
print(air.boot)

data1=read_excel("检验(0.5,0.2).xlsx")
str(data1)
data=data1[1:3]
data1=data[-2]

y=data1$每日收益率
t=data1$时间
str(data)
length(y)
mean(y)
mean.fun <- function(d, i) 
{    m <- mean(y[i])
     n <- sd(y[i])
     v <- (n-1)*var(y[i])/n^2
     return(c(m,n,v))
}

mean.fun (y,1:500)

air.boot <- boot(data, mean.fun, R = 500)
print(air.boot)

    data1=read_excel("检验(0.5,0.5 黑色).xlsx")
    str(data1)
    data=data1[1:3]
    data1=data[-2]
    
    y=data1$每日收益率
    t=data1$时间
    str(data)
    length(y)
    mean(y)
    mean.fun <- function(d, i) 
    {    m <- mean(y[i])
         n <- sd(y[i])
         v <- (n-1)*var(y[i])/n^2
         return(c(m,n,v))
    }
    
    mean.fun (y,1:500)
    
    air.boot <- boot(data, mean.fun, R = 500)
    print(air.boot)
    
    data1=read_excel("检验(0.5,0.5).xlsx")
    str(data1)
    data=data1[1:3]
    data1=data[-2]
    
    y=data1$每日收益率
    t=data1$时间
    str(data)
    length(y)
    mean(y)
    mean.fun <- function(d, i) 
    {    m <- mean(y[i])
         n <- sd(y[i])
         v <- (n-1)*var(y[i])/n^2
         return(c(m,n,v))
    }
    
    mean.fun (y,1:500)
    
    air.boot <- boot(data, mean.fun, R = 500)
    print(air.boot)
    
    data1=read_excel("检验(1,0).xlsx")
    str(data1)
    data=data1[1:3]
    data1=data[-2]
    
    y=data1$每日收益率
    t=data1$时间
    str(data)
    length(y)
    mean(y)
    mean.fun <- function(d, i) 
    {    m <- mean(y[i])
         n <- sd(y[i])
         v <- (n-1)*var(y[i])/n^2
         return(c(m,n,v))
    }
    
    mean.fun (y,1:500)
    
    air.boot <- boot(data, mean.fun, R = 500)
    print(air.boot)
    
    data1=read_excel("检验(1,0.5)修改.xlsx")
    str(data1)
    data=data1[1:3]
    data1=data[-2]
    
    y=data1$每日收益率
    t=data1$时间
    str(data)
    length(y)
    mean(y)
    mean.fun <- function(d, i) 
    {    m <- mean(y[i])
         n <- sd(y[i])
         v <- (n-1)*var(y[i])/n^2
         return(c(m,n,v))
    }
    
    mean.fun (y,1:500)
    
    air.boot <- boot(data, mean.fun, R = 500)
    print(air.boot)
    
    data1=read_excel("盈亏分析 (1,1)策略.xlsx")
    
    str(data1)
    data=data1[1:3]
    data1=data[-2]
    
    y=data1$每日收益率
    t=data1$时间
    str(data)
    length(y)
    mean(y)
    mean.fun <- function(d, i) 
    {    m <- mean(y[i])
         n <- sd(y[i])
         v <- (n-1)*var(y[i])/n^2
         return(c(m,n,v))
    }
    
    mean.fun (y,1:500)
    
    air.boot <- boot(data, mean.fun, R = 500)
    print(air.boot)



收集很多的Bootstrap模型的网站如下:
https://blog.csdn.net/yujunbeta/article/details/24142545

https://blog.csdn.net/yujunbeta/article/details/9255965

https://blog.csdn.net/weixin_43452592/article/details/83893349

http://blog.sina.com.cn/s/blog_5cd2f1e201019dz2.html

https://blog.csdn.net/u013421629/article/details/73124004【直方图添加曲线】
https://blog.csdn.net/yucan1001/article/details/13169687
https://blog.csdn.net/it_beecoder/article/details/83090689

https://blog.csdn.net/kmd8d5r/article/details/79366648

par(mar=c(5,5,4,5)+0.1)
bar <- barplot(absolute,ylab="总数",col="skyblue",col.axis="skyblue",col.lab="skyblue")
mtext(LETTERS[1:8],side=1,line=1,at=bar,col="black")
#mtext(" ",side=1,line=3,col="black")
par(new=T)
plot(bar,cum_per,axes=F,xlab="",ylab="",col="red",type="b")
axis(4,col="red",col.ticks="red",col.axis="red")
mtext("累计百分比%",side=4,line=3,col="red")
title(main = '帕累托图')

意义网站整理如下:
http://www.cnblogs.com/wuzhitj/p/4363848.html 【累积分布函数:累计概率分布,将多个利润用折线图表示】

https://blog.csdn.net/qq_19600291/article/details/79165229 【 蒙特卡罗分布】

https://blog.csdn.net/PyDarren/article/details/79850368

https://zhuanlan.zhihu.com/p/26517940

http://www.sohu.com/a/67508574_116235

https://weibo.com/p/230418659ec1310102wnes

https://blog.csdn.net/qq_23851075/article/details/52052449

©️2020 CSDN 皮肤主题: 精致技术 设计师:CSDN官方博客 返回首页