~ubuntu-branches/ubuntu/trusty/fportfolio/trusty

« back to all changes in this revision

Viewing changes to inst/unitTests/runit.class-fPFOLIOCON.R

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2008-12-04 11:36:54 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081204113654-gr832nfs44blp5ph
Tags: 280.74-1
* New upstream release
* Finally uploading as r-cran-rglpk is out of NEW after five weeks

* debian/control: Updated (Build-)Depends: and Suggests:

* debian/control: Set (Build-)Depends: to current R version
* debian/control: Set Standards-Version: to current version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# This library is free software; you can redistribute it and/or
 
3
# modify it under the terms of the GNU Library General Public
 
4
# License as published by the Free Software Foundation; either
 
5
# version 2 of the License, or (at your option) any later version.
 
6
#
 
7
# This library is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
10
# GNU Library General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU Library General
 
13
# Public License along with this library; if not, write to the
 
14
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 
15
# MA  02111-1307  USA
 
16
 
 
17
# Copyrights (C)
 
18
# for this R-port: 
 
19
#   1999 - Diethelm Wuertz, GPL
 
20
#   2007 - Rmetrics Foundation, GPL
 
21
#   Diethelm Wuertz <wuertz@itp.phys.ethz.ch>
 
22
# for code accessed (or partly included) from other sources:
 
23
#   see Rmetric's copyright and license files
 
24
 
 
25
 
 
26
################################################################################
 
27
# FUNCTION:
 
28
#  test.fPFOLIOCON
 
29
#  test.portfolioConstraints.Short
 
30
#  test.portfolioConstraints.LongOnly
 
31
################################################################################
 
32
 
 
33
 
 
34
## DW
 
35
## Note, there is not yet a print function in the show-methods.R
 
36
 
 
37
 
 
38
# ------------------------------------------------------------------------------
 
39
 
 
40
 
 
41
test.fPFOLIOCON <- 
 
42
    function()
 
43
{  
 
44
    # Class:
 
45
    getClass("fPFOLIOCON")
 
46
   
 
47
    # Slots:
 
48
    getSlots("fPFOLIOCON")
 
49
   
 
50
    # Return Value:
 
51
    return()
 
52
}
 
53
 
 
54
 
 
55
# ------------------------------------------------------------------------------
 
56
 
 
57
 
 
58
test.portfolioConstraints.Short <- 
 
59
    function()
 
60
{  
 
61
   
 
62
    # Data:
 
63
    data = as.timeSeries(data(smallcap.ts))
 
64
    data = data[, c("BKE", "GG", "GYMB", "KRON")]
 
65
    head(data)
 
66
 
 
67
    # Spec:
 
68
    spec = portfolioSpec()
 
69
    setTargetReturn(spec) = mean(data)
 
70
    
 
71
    # Constraints:
 
72
    constraints = "Short"
 
73
    
 
74
    # As Object:
 
75
    Constraints = portfolioConstraints(data, spec, constraints)
 
76
    Constraints
 
77
    
 
78
    # Return Value:
 
79
    return()
 
80
}
 
81
 
 
82
 
 
83
# ------------------------------------------------------------------------------
 
84
 
 
85
 
 
86
test.portfolioConstraints.LongOnly <-  
 
87
    function()
 
88
{  
 
89
    # Data:
 
90
    data = as.timeSeries(data(smallcap.ts))
 
91
    data = data[, c("BKE", "GG", "GYMB", "KRON")]
 
92
    head(data)
 
93
 
 
94
    # Spec:
 
95
    spec = portfolioSpec()
 
96
    setTargetReturn(spec) = mean(data)
 
97
    
 
98
    # Constraints:
 
99
    constraints = "LongOnly"
 
100
    
 
101
    # As Object:
 
102
    Constraints = portfolioConstraints(data, spec, constraints)
 
103
    Constraints
 
104
    
 
105
    # Return Value:
 
106
    return()
 
107
}
 
108
 
 
109
 
 
110
################################################################################
 
111