This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.io.FileUtils | |
import java.io.File | |
import java.net.URL | |
import java.lang.Thread | |
val xbrlFolder = new File("xbrl") | |
for (code <- 1301 to 9997) { | |
println(code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.Thread | |
import java.net.URL | |
import java.io.File | |
import org.openqa.selenium.firefox.FirefoxDriver | |
import org.openqa.selenium.By | |
import org.apache.commons.io.FileUtils | |
val mail = "enter your email address" | |
val password = "enter your password" | |
val maxArticleId = 1477 // Please manually set maxArticleId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(rugarch) | |
#SP500の日足データを使う。 | |
data(sp500ret) | |
#まずは通常のGARCH(1,1)。 | |
spec.sg <- ugarchspec( | |
variance.model = list(model = "sGARCH", garchOrder=c(1,1)), | |
#平均値のモデルにはARIMA(1,1,1)を使う。 | |
mean.model = list(armaOrder = c(1,1,1), arfima = T), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
roll.eg <- ugarchroll( | |
spec.eg, sp500ret, | |
#100日毎にパラメータを推定しなおす。 | |
refit.every = 100, | |
#一日先の値を予測する。 | |
n.ahead = 1, | |
#予測開始地点を指定するにはforecast.lengthかn.startのどちらかを使う。 | |
n.start = nrow(sp500ret)-500, #5023日目から予測を始める。sp500retには5523日分のデータが入っている。 | |
refit.window = "moving", solver = "hybrid", keep.coef = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sp500 <- tail(sp500ret,n=500)$SP500RET | |
sigma <- df.eg[, 'Sigma', drop = FALSE]$Sigma | |
#トレーニング期間の分散を定数cに設定する | |
const <- sd(head(sp500ret,n=5000)$SP500RET)^2 | |
leverage <- const / sigma^2 | |
#buy&holdのリターン | |
prod(1 + sp500) | |
#OVSのリターン | |
prod(1 + sp500*leverage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://github.com/Marigold/universal-portfolios/blob/master/universal/algos/anticor.py | |
#ここから一部引用 | |
#時刻0からn-1までの全期間のポートフォリオの状態が計算される | |
def weights(self, X): | |
#期待値やラグ付き相関の計算で使うウィンドウのサイズ | |
window = self.window | |
#全銘柄の株価時系列データ(ただし前日比の相対価格データ) | |
port = X | |
#nは時系列の長さ。mは銘柄の数。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OLPS_cli(dataset) | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% This file is part of OLPS: http://OLPS.stevenhoi.org/ | |
% Original authors: Bin LI, Doyen Sahoo, Steven C.H. Hoi | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
cd Strategy; | |
opts.quiet_mode = 0; opts.display_interval = 245; | |
opts.log_mode = 1; opts.mat_mode = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(randomForest) | |
library(RSQLite) | |
random.rows <- function(df, n) { | |
df[sample(nrow(df),n),] | |
} | |
fix.cb <- function(df) { | |
c1 <- df[df$finishing_position == "TRUE",] | |
c2 <- df[df$finishing_position == "FALSE",] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1301 | |
1332 | |
1377 | |
1518 | |
1801 | |
1802 | |
1803 | |
1812 | |
1815 | |
1820 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OLPS_cli(dataset) | |
cd Strategy; | |
opts.quiet_mode = 0; opts.display_interval = 245; | |
opts.log_mode = 1; opts.mat_mode = 1; | |
opts.analyze_mode = 0; opts.progress = 0; | |
opts.his = 0; | |
if (nargin<1) |
OlderNewer