GeniusTrader/Brokers/Cortal.pm untested

filter: Statementstmt 0.0% 0 / 70 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 170 CC 18 SCAR 50.0
CC
18
Cov
0%
calculate_order_commission
240.0
new
20.0
calculate_annual_account_charge
2.0
CRAP 147.7
1 package Finance::GeniusTrader::Brokers::Cortal;
2  
3 # Copyright 2000-2002 Raphaël Hertzog, Fabien Fulhaber
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6  
7 use strict;
8 use vars qw(@NAMES @ISA);
9  
10 use Finance::GeniusTrader::Brokers;
11 use Finance::GeniusTrader::Eval;
12 use Finance::GeniusTrader::Conf;
13  
14 @NAMES = ("Cortal[#1]");
15 @ISA = qw(Finance::GeniusTrader::Brokers);
16  
17 =head1 Finance::GeniusTrader::Brokers::Cortal
18  
19 =head2 Overview
20  
21 This module will calculate all commissions and charges according to
22 Cortal rules.
23  
24 =head2 Calculation
25  
26 For orders "A tout prix" and "prix du marché" :
27  
28 5 Euros HT / order up to 1500 Euros
29 10 Euros HT / order up to 3000 Euros
30 0.30 % / order up to 100 000 Euros + 0.10 % / after
31  
32 For other orders :
33  
34 7.5 Euros HT / order up to 1500 Euros
35 12.5 Euros HT / order up to 3000 Euros
36 0.50 % / order up to 100 000 Euros + 0.10 % / after
37  
38 Annual account charge (30/06 and 31/12) :
39  
40 Up to 150 000 Euros : 0.15 % HT of the portfolio value, after 0 %
41 Minimum : 12 Euros HT.
42  
43 =cut
44  
45 sub new {
46 my $type = shift;
47 my $class = ref($type) || $type;
48 my $args = shift;
49 my $option = "Découverte";
50
51 if (Finance::GeniusTrader::Conf::get("Brokers::SelfTrade::Forfait")) {
52 $option = Finance::GeniusTrader::Conf::get("Brokers::SelfTrade::Forfait");
53 }
54
55 my $self = { 'args' => defined($args) ? $args : [ $option ] };
56  
57 $args->[0] = $option if (! defined($args->[0]));
58  
59 return manage_object(\@NAMES, $self, $class, $self->{'args'}, '');
60 }
61  
62 =head2 $broker->calculate_order_commission($order)
63  
64 Return the amount of money ask by the broker for the given order.
65  
66 =cut
67  
68 sub calculate_order_commission {
69 my ($self, $order) = @_;
70 # my $forfait = $self->{'args'}[0];
71 my $TVA = (1 + 19.6 / 100);
72 my $commission = 0;
73
74 # Override $TVA if Brokers::TVA is already defined in the user
75 # configuration file
76
77 if (Finance::GeniusTrader::Conf::get("Brokers::TVA")) {
78 $TVA = (1 + Finance::GeniusTrader::Conf::get("Brokers::TVA") / 100);
79 }
80
81 if ( (defined($order->quantity) && $order->quantity) and
82 (defined($order->price) && $order->price) ) {
83  
84 my $investment = $order->quantity * $order->price;
85
86 if ( ((defined($order->is_type_market_price)) && ($order->is_type_market_price)) or
87 ((defined($order->is_type_stop)) && ($order->is_type_stop)) ) {
88
89 # For "A tout prix" and "Prix du marché" orders
90  
91 if ($investment < 1500) {
92 $commission = sprintf("%.2f", (5.00 * $TVA));
93 }
94 if ($investment < 3000 and $investment > 1500) {
95 $commission = sprintf("%.2f", (10.00 * $TVA));
96 }
97 if ($investment < 100000 and $investment > 3000) {
98 $commission = sprintf("%.2f", ($investment * 0.30 / 100 * $TVA));
99 }
100 if ($investment > 100000) {
101 $commission = sprintf("%.2f", (100000 * 0.30 / 100 * $TVA));
102 $commission += sprintf("%.2f", (($investment - 100000) * 0.10 / 100 * $TVA));
103 }
104  
105 } else {
106  
107 # For other type of orders
108
109 if ($investment < 1500) {
110 $commission = sprintf("%.2f", (7.50 * $TVA));
111 }
112 if ($investment < 3000 and $investment > 1500) {
113 $commission = sprintf("%.2f", (12.50 * $TVA));
114 }
115 if ($investment < 100000 and $investment > 3000) {
116 $commission = sprintf("%.2f", ($investment * 0.50 / 100 * $TVA));
117 }
118 if ($investment > 100000) {
119 $commission = sprintf("%.2f", (100000 * 0.50 / 100 * $TVA));
120 $commission += sprintf("%.2f", (($investment - 100000) * 0.10 / 100 * $TVA));
121 }
122 }
123
124 # Add the "Impôt de bourse"
125 my $impot_de_bourse = $investment * 0.30 / 100;
126 my $abattement = 150 / 6.55957;
127 my $plafond = 4000 / 6.55957;
128  
129 if ($impot_de_bourse > $abattement) {
130 $impot_de_bourse = $plafond if (($impot_de_bourse - $abattement) > $plafond);
131 $commission += sprintf("%.2f", ($impot_de_bourse - $abattement));
132 }
133
134 return $commission if ($commission != 0);;
135 }
136 }
137  
138 =head2 $broker->calculate_annual_account_charge($portfolio, $year)
139  
140 Return the amount of money ask by the broker for the given year
141 according to the given portfolio.
142  
143 =cut
144  
145 sub calculate_annual_account_charge {
146 my ($self, $portfolio, $year) = @_;
147  
148 return 0;
149  
150 }
151  
152 1;