-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 26.3 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#pif.best.name=names(diff.best)[which(diff.best==min(diff.best,na.rm = TRUE))]
#pif.act[tail(index(pif),n=1),pif.best.name]=TRUE
# запись в общую таблицу оценок фондов
pif.act[tail(index(pif),n=1),names(sort(diff.best))]=c(1:length(diff.best))
}
# создание копии таблицы
pif.act.copy=pif.act
# период для инвестиций
period=12
# стирание данных
pif.act[]=NA
# индикатор для начала
# вычисления фонда в который
# нужно инвестировать
j=11
for(i in 1:(nrow(pif.act.copy)-(period-1))){
# выделение данных за период в переменную
dta.m=pif.act.copy[i:(i+(period-1)),]
# проверка, достаточно ли данных в периоде
if(sum(dta.m[1,],na.rm = TRUE)>0){
# увеличение периода на 1 месяц
j=j+1
# если количество месяцев кратно периоду
# то нужно вычислять новый фонд для инвестиций
# на следующий период
if(j%%period==0){
# вычисляется сумма по каждому фонду
# затем данные записываются в массив
best=names(sort(colSums(dta.m)))[1]
# вычисление месяца начала инвестиций
k=i+period
# вычисление конечного месяца инвестиции
k1=ifelse((k+(period-1))>nrow(pif.act.copy),nrow(pif.act.copy),(k+(period-1)))
# запись в таблицу информации о том,
# в какой фонд будут сделаны инвестции
pif.act[index(pif.act.copy[k:k1,]),best[1]]=1
}
}
}
##### вычисление бенчмарка на основе индексных фондов #####
# бенчмарк портфель из индексных паевых фондов
benchmark.pif=portfel.equity(pif.price, pif.act, 1000000, c(0.005, 0.015))
# доходность бенчмарка
benchmark.pif.return=pif.graph(benchmark.pif, moex)
# чтение данных из файла
future=read.csv(paste0(DIR,"/MX.csv"), stringsAsFactors = F)
# наименование фьючерсов
future.name=unique(future[,2])
# таблица со значениями ГО по фьючерсам
future.data=as.data.frame(matrix(NA,nrow = nrow(future), ncol = length(future.name)))
# название строк
row.names(future.data)=future[,1]
# название столбцов
colnames(future.data)=future.name
# преобразование во временной формат данных
future.data=as.xts(future.data, order.by = as.Date(row.names(future.data), "%d.%m.%Y"))
# создание новых таблиц копированием
future.price=future.price.estim=future.action=future.data
# заполнение данных по каждому фьючерсу
for(name in future.name){
# временная переменная
x=future[future[,2]==name,]
# преобразование формата даты
date=as.Date(x[,1], "%d.%m.%Y")
# заполнение значений ГО
future.data[date,name]=x[,16]
# заполнение актуальности фьючерса
future.action[date,name]=1
# заполнение значений средней взвешенной цены
future.price[date,name]=x[,3]
# заполнение значений цены расчета
future.price.estim[date,name]=x[,4]
# удаление временных переменных
rm(x,date)
}
# величина свободных денежных средств
portfel.bank=1000000
# наименование текущего фьючерса в портфеле
portfel.name=""
# история изменения стоимости портфеля
portfel.history=future.data[,1]
# стирание данных
portfel.history[]=NA
for(i in 1:nrow(future.data)){
# фьючерс в который нужно инвестировать на данной итерации
buy=colnames(future.action)[which(!is.na(future.action[i,]))]
# если фьючерс отличается от фьючерса в портфеле
# и портфель не пустой то происходит освобождение ГО
if(buy!=portfel.name & portfel.name!=""){
# ГО возвращается в свободные сердства
portfel.bank=portfel.bank + portfel.warranty
# удаление переменных
rm(portfel.warranty,portfel.count,portfel.price)
}
# если новый фьючерс и фьючерс в портфеле не совпадают
# то нужно инвестировать в данный фьючерс
# ГО было освобождено на предыдущем шаге
if(buy!=portfel.name){
# текущая стоимость фьючерса - это ГО
price=as.numeric(future.data[i,buy])
# инвестиции без "плеча"
# цена количества фьючерсов покрывает весь банк
n=ceiling(portfel.bank / as.numeric(future.price[i,buy]))
# свободные денежные средства
# уменьшаются только на величину ГО
portfel.bank=portfel.bank - n * price
# сохранение количества
portfel.count=n
# сохранение наименования фьючерса
portfel.name=buy
# цена фьючерса для вычисления маржинального требования
portfel.price=as.numeric(future.price[i,buy])
# общий размер ГО
portfel.warranty=n * price
# удаление переменных
rm(price,cash,n)
}
# если в портфеле есть фьючерс
if(portfel.count > 0){
# актуальное значение ГО
warranty.price = as.numeric(future.data[i,portfel.name])
if(!is.na(warranty.price)){
# вычисление актульного ГО покрывающее портфель
warranty=warranty.price * portfel.count
# разница между зарезервированным и актуальным ГО
diff.warranty = portfel.warranty - warranty
# изменение величины свободных средств
portfel.bank = portfel.bank + diff.warranty
# зарезервированное ГО становится актуальным
portfel.warranty = warranty
}
# вычисление маржинального требования
if(portfel.price==as.numeric(future.price[i,portfel.name])){
# инвесировани было в данный день
margin=(as.numeric(future.price.estim[i,portfel.name]) - portfel.price) * portfel.count
} else {
# между двумя датами как ращница расчётных цен
margin=(as.numeric(future.price.estim[i,portfel.name]) - as.numeric(future.price.estim[(i-1),portfel.name])) * portfel.count
}
# если свободных средств и ГО не хватает
# для покрытия маржинального требования
if((portfel.bank + portfel.warranty) < margin){
# происходит margin call
print("Банк опустел")
break
}
# в конце каждого торгового дня свободные средства
# изменяются на величину маржинального требования
portfel.bank = portfel.bank + margin
# удаление переменных
rm(warranty,margin,diff.warranty,warranty.price)
}
portfel.history[i]=portfel.bank + portfel.warranty
}
##### вычисление бенчмарка на основе фьючерса на Индекс МосБиржи #####
# месячная доходность бенчмарка
benchmark.future.return=monthlyReturn(Cl(to.monthly(portfel.history, indexAt = 'lastof')))
# получение наименования файлов
files=list.files(paste0(DIR,"/dat"),full.names=TRUE)
# общая таблица с данными
data.equity=data.frame()
for(file in files){
# чтение одного файла
eq=read.csv(file,stringsAsFactors=FALSE)
# добавление данных в одну таблицу
data.equity=rbind(data.equity,eq)
}
# информация о базе расчета Индекс ММВБ 10
mic.10<-read.csv(paste0(DIR,"/10micexdata.csv"),header = FALSE,stringsAsFactors = FALSE)
# изменения наименования сокращенных названий акций
mic.10.replace=read.csv(paste0(DIR,"/10micex.csv"),header = FALSE,stringsAsFactors = FALSE)
# замена наименования сокращенных названий акций в базе расчета
for(i in 1:nrow(mic.10.replace)){
mic.10[mic.10==mic.10.replace[i,1]]=mic.10.replace[i,2]
}
mic.ticker=c()
mic.ticker=unique(unlist(sapply(c(18:nrow(mic.10)),function(i){mic.ticker=append(mic.ticker,mic.10[i,3:12])})))
mic.ticker=mic.ticker[mic.ticker!=""]
date.all=c() # массив со всеми датами
for(i in 18:nrow(mic.10)){
# база расчета Индекса ММВБ 10 за определенный период
tickers=unlist(mic.10[i,3:length(mic.10[i,])])
# массив календарных дат для базы расчета
dates=seq.Date(as.Date(mic.10[i,1],"%d.%m.%Y"), as.Date(mic.10[i,2],"%d.%m.%Y"), by = "day")
date.t=c() # массив дат для текущей базы расчета
for(t in tickers){
# данные по одной акции из базы расчёта
y=data.equity[which(data.equity[,1]==t),]
# пересечение календарнх дат и торговых дней
date.inter=intersect(dates,as.Date(y[,2]))
# добавление пересечения дат в массив
date.t=append(date.t,date.inter)
}
# добавление уникальных дат в общий массив
date.all=append(date.all,unique(date.t))
}
# структурированная таблица с данными
data.10=xts(matrix(NA, nrow = length(date.all), ncol = length(mic.ticker),dimnames = list(date.all,mic.ticker)),order.by = as.Date(date.all))
for(t in colnames(data.10)){
# данные по одной акции из базы расчёта
y=data.equity[which(data.equity[,1]==t),]
# цены закрытия по данной акции
y=xts(Cl(y),order.by=as.Date(y[,2]))
# заполнение данных в таблице
data.10[index(y),t]=y[index(data.10)]
}
for(i in 18:nrow(mic.10)){
# база расчета Индекса ММВБ 10 за определенный период
tickers=unlist(mic.10[i,3:length(mic.10[i,])])
for(t in tickers){
if(t=="") next
# данные по одной акции из базы расчёта
y=data.equity[which(data.equity[,1]==t),]
# цены закрытия по данной акции
y=xts(Cl(y),order.by=as.Date(y[,2]))
# пересечение дат в таблице и торговых дат для акции
#date.inter=intersect(index(data.10),index(y))
# заполнение данных в таблице
data.10[index(y),t]=y
}
}
# структурированная таблица с данными
data.10=xts(matrix(NA, nrow = length(date.all), ncol = length(mic.ticker),dimnames = list(date.all,mic.ticker)),order.by = as.Date(date.all))
for(t in colnames(data.10)){
# данные по одной акции из базы расчёта
y=data.equity[which(data.equity[,1]==t),]
# цены закрытия по данной акции
y=xts(Cl(y),order.by=as.Date(y[,2]))
# заполнение данных в таблице
data.10[index(y),t]=y[index(data.10)]
}
# проверка, что всегда есть данные по 10 акциям
for(i in 1:nrow(data.10)){
r=data.10[i,]
if(length(r[,!is.na(r)])<10) print(index(r))
}
# структурированная таблица с данными
data.act=xts(matrix(NA, nrow = length(date.all), ncol = length(mic.ticker),dimnames = list(date.all,mic.ticker)),order.by = as.Date(date.all))
for(i in 18:nrow(mic.10)){
# база расчёта индекса
tickers=unlist(mic.10[i,3:length(mic.10[i,])])
# удаление пустых значений
tickers=tickers[tickers!=""]
# период действия базы расчёта
dates=seq.Date(as.Date(mic.10[i,1],"%d.%m.%Y"), as.Date(mic.10[i,2],"%d.%m.%Y"), by = "day")
# заполнение индикаторов, о вхождении акций в портфель
data.act[dates,tickers]=TRUE
}
# сплит акций
data.act["2007-07-18","SBER"]=1000
data.act["2007-07-18","SBERP"]=20
# заполнение индикаторов
# чтобы акции не были исклчены из портфеля
data.act[c("2007-07-19","2007-07-20"),c("SBER","SBERP")]=TRUE
# проверка, что всегда есть данные по 10 акциям
for(i in 1:nrow(data.act)){
r=data.act[i,]
if(length(r[,!is.na(r)])<10) print(index(r))
}
##### вычисление бенчмарка на основе акций из состава Индекса ММВБ 10 #####
# вызов функции с параметрами
benchmark.stock=portfel.equity(data.10, data.act, 1000000, c(0.0001, 0.0001))
# месячная доходность бенчмарка
benchmark.stock.return=monthlyReturn(Cl(to.monthly(benchmark.stock, indexAt = 'lastof')))
dt=intersect(index(benchmark.stock.return),index(moex10))
test=cbind(moex10[as.Date(dt)],benchmark.stock.return[as.Date(dt)])
# наименование столбцов
colnames(test)=c("MOEX10","Portfel")
charts.PerformanceSummary(test)
print(summary(lm(test[,2]~test[,1])))
##### подключение данных, если были загружены #####
load(paste0(DIR,"/pifdata/stock/all.RData"))
load(paste0(DIR,"/pifdata/stock/allD.RData"))
##### цены и доходность фондов #####
pif.price=xts()
pif.return=xts()
for(i in 1:length(allD)){
if(i==1){
# заполненеи первой колонки таблицы
pif.price=Cl(to.monthly(allD[[i]][[1]],indexAt = 'lastof'))
pif.return=monthlyReturn(to.monthly(allD[[i]][[1]],indexAt = 'lastof'))
} else {
# добавление следующих колонок в таблицу
pif.price=cbind(pif.price,Cl(to.monthly(allD[[i]][[1]],indexAt = 'lastof')))
pif.return=cbind(pif.return,monthlyReturn(to.monthly(allD[[i]][[1]],indexAt = 'lastof')))
}
}
colnames(pif.price)=names(allD)
colnames(pif.return)=names(allD)
for(i in 1:ncol(pif.return)){
pr=tail(which(is.na(pif.return[,i])),n=1)
if(length(pr)>0) pif.return[1:pr,i]=NA
pp=tail(which(is.na(pif.price[,i])),n=1)
if(length(pp)>0) pif.price[1:pp,i]=NA
rm(pr,pp)
}
##### вычисление бутстрап модели по трём бенчмаркам #####
# функция вычисления лучших фондов
best.pif=boot.all(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 100, period = 24, l1 = 0.99, l2 = 0.5)
# результат
cat(paste(all[all[,3] %in% names(best.pif),1],round(best.pif,2)),sep = "\n")
# функция вычисления лучших фондов
best.stock=boot.all(return = pif.return, bench = benchmark.stock.return, rf = ru.1y, boot.n = 100, period = 24, l1 = 0.99, l2 = 0.5)
# результат
cat(paste(all[all[,3] %in% names(best.stock),1],round(best.stock,2)),sep = "\n")
# функция вычисления лучших фондов
best.future=boot.all(return = pif.return, bench = benchmark.future.return, rf = ru.1y, boot.n = 100, period = 24, l1 = 0.99, l2 = 0.5)
# результат
cat(paste(all[all[,3] %in% names(best.future),1],round(best.future,2)),sep = "\n")
save.image()
save.image(file = "F:/backup.RData")
rm(all,allD)
rm(data.equity)
View(diff.index)
View(eq)
View(future)
View(future.price.estim)
View(mic.10)
View(pif)
View(pif.act)
View(portfel.history)
View(r)
View(ru)
View(y)
rm(diff.index,dta.m,eq,future,mic.10,mic.10.replace,pif,r,ru,test,y)
rm(best,buy,date.all,date.inter,date.t,dates,diff.best,DIR,dt,file,files,future.name,i,j,k,k1,mic.ticker,name,period,portfel.bank,portfel.count,portfel.name,portfel.price,portfel.warranty,t,tickers,time)
save.image()
save.image(file = "F:/backup1.RData")
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 10000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 100, period = 24, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 10000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
View(pif.price)
View(best.pif.act)
View(portfel)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 1000, period = 24, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.3)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.6)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
x=best.pif.boot
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.7)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.9)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 1.0)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 24, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 10, period = 48, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 1, period = 24, l1 = 0.99, l2 = 0.5)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 0, period = 24, l1 = 0.99, l2 = 0.5)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 1, period = 24, l1 = 0.99, l2 = 0.0)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 1, period = 24, l1 = 0.99, l2 = 1.0)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# функция вычисления лучших фондов по периодам
best.pif.boot=boot.history(return = pif.return, bench = benchmark.pif.return, rf = ru.1y, boot.n = 1, period = 24, l1 = 0.99, l2 = 0.7)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
best.pif.boot=x
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,8)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,3)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,5)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,2)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,12)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# функция для установки индикаторов
best.pif.act=boot.act(best.pif.boot,4)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
View(pif.act)
View(best.pif.act)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 10000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
# построение портфеля
portfel=portfel.equity(pif.price, best.pif.act, 1000000, c(0.005, 0.015))
# доходность портфеля
portfel.return=pif.graph(portfel,moex)
rm(x)
save.image()
save.image()