FangQuant › Codes
  • R-Code for analysis: getKDJ

    getKDJ<-function(rt,n){ l=length(rt[["Chg"]]) K=array(0,c(l-n+1)) D=array(0,c(l-n+1)) J=array(0,c(l-n+1)) daycount=0 for(i in n:l){ daycount=daycount+1 nlow=rt[["Low"]][i] nhigh=rt[["High"]][i] for...
    Codes Fang 4 years ago
  • R-Code for analysis: getRSI

    import math import pandas as pd import numpy as np import matplotlib.dates as mdates import matplotlib.pyplot as plt from datetime import datetime # 止盈线倍数u u=1.5 # 止损线倍数d d=1 # 均线天数N N=5...
    Codes Fang 4 years ago
  • R-Code@July 01, 2016

    #Polynomial regression set.seed(20) q<-seq(from=0,to=20,by=0.1) y<--500+0.4*(q-10)^3 noise<-rnorm(length(q),mean=10,sd=80) noisy.y<-y+noise plot(q,noisy.y,col='deepskyblue4',xlab='q'...
    Codes Fang 4 years ago
  • R-Code@June 26, 2016

    #Odds: runs<-100 game<-function(){ results<-sample(c(-1,0,1,2),10,replace=T) return(sum(results)>5) } sum(replicate(runs,game()))/runs #Time Series Analysis require("astsa") ...
    Codes Fang 4 years ago
  • R-Code@June 06, 2016

    1.Normal Distribution set.seed(1) cord.x<-c(0,seq(0,5,0.1),5) cord.y<-c(0,dnorm(seq(0,5,0.1),0,5),0) curve(dnorm(x,0,5),xlim=c(-15,15),main='Normal Distribution,PDF',col="darkgreen",xlab="",yl...
    Codes Fang 4 years ago