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
| Function prix_titre2(date_liquidation, code, rendement)
Dim Cn As New ADODBRD, Sql As String
Cn.Server = "ATWMANARPRD": Cn.BASE = "MSAP": Cn.TYPEBASE =SQLSERVER2000
Cn.OpenConnetion
Dim flux() As Double
Dim echeancier(), date_flux As Date
Dim p, cc, di As Double
Dim i, nbr_flux, jour_inclus As Integer
Sql = "select date_emission, date_echeance, taux, nominal, premier_j, methode_valo, periodicite_cp, maturite, periodicite_cap, base From dbo.get_parametres() where code=code"
adSmallInt = 2
adParamInputOutput = 3
adCmdText = 1
Set Param1 = CreateObject("ADODB.Command").CreateParameter("code", adSmallInt, adParamInputOutput, 4, code)
With CreateObject("ADODB.Command")
Set .ActiveConnection = Connexion
.CommandType = adCmdText
.CommandTimeout = 500
.Parameters.Append Param1
.CommandText = Sql
Set CommadExecute = .Execute
End With
If methode_valo = "M" Then
p = flux(1) / (1 + rendement * (echeancier(1) - CDate(date_liquidation)) / 360)
End If
'******************valorisation linéaire******************
If methode_valo = "L" Then
If periodicite_cap = "F" Then
p = nominal + cc
Else
p = Round((nominal - Round((nominal / maturite), 2) * (maturite - nbr_flux)), 2) + cc
End If
End If
p = p + (flux(i) / ((1 + rendement) ^ di))
Next
End If
Else
p = 0
End If
prix_titre2 = p
End Function |
Partager