| 1 | package Finance::GeniusTrader::Brokers::Zebank; | ||
| 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 = ("Zebank[#1]"); | ||
| 15 | @ISA = qw(Finance::GeniusTrader::Brokers); | ||
| 16 | |||
| 17 | =head1 Finance::GeniusTrader::Brokers::Zebank | ||
| 18 | |||
| 19 | =head2 Overview | ||
| 20 | |||
| 21 | This module will calculate all commissions and charges according to | ||
| 22 | Zebank rules. | ||
| 23 | |||
| 24 | =head2 Calculation | ||
| 25 | |||
| 26 | 0,45 % TTC / order with a minimum of 9 EUR | ||
| 27 | |||
| 28 | Free return if buy & sell during the same day. | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | sub new { | ||
| 33 | my $type = shift; | ||
| 34 | my $class = ref($type) || $type; | ||
| 35 | my $args = shift; | ||
| 36 | |||
| 37 | my $self = { 'args' => defined($args) ? $args : [] }; | ||
| 38 | |||
| 39 | return manage_object(\@NAMES, $self, $class, $self->{'args'}, ''); | ||
| 40 | } | ||
| 41 | |||
| 42 | =head2 $broker->calculate_order_commission($order) | ||
| 43 | |||
| 44 | Return the amount of money ask by the broker for the given order. | ||
| 45 | |||
| 46 | =cut | ||
| 47 | |||
| 48 | sub calculate_order_commission { | ||
| 49 | my ($self, $order) = @_; | ||
| 50 | my $commission = 0; | ||
| 51 | |||
| 52 | if ( (defined($order->quantity) && $order->quantity) and | ||
| 53 | (defined($order->price) && $order->price) ) { | ||
| 54 | |||
| 55 | my $investment = $order->quantity * $order->price; | ||
| 56 | |||
| 57 | # Calculate the 0.45 % TTC commission with a minimum of 9 EUR | ||
| 58 | $commission = sprintf("%.2f", ($investment * 0.45 / 100)); | ||
| 59 | $commission = 9 if ($commission < 9); | ||
| 60 | |||
| 61 | # TODO : Free return if buy & sell during the same day. | ||
| 62 | |||
| 63 | # Add the "Impôt de bourse" | ||
| 64 | my $impot_de_bourse = $investment * 0.30 / 100; | ||
| 65 | my $abattement = 150 / 6.55957; | ||
| 66 | my $plafond = 4000 / 6.55957; | ||
| 67 | |||
| 68 | if ($impot_de_bourse > $abattement) { | ||
| 69 | $impot_de_bourse = $plafond if (($impot_de_bourse - $abattement) > $plafond); | ||
| 70 | $commission += sprintf("%.2f", ($impot_de_bourse - $abattement)); | ||
| 71 | } | ||
| 72 | |||
| 73 | return $commission if ($commission != 0);; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | =head2 $broker->calculate_annual_account_charge($portfolio, $year) | ||
| 78 | |||
| 79 | Return the amount of money ask by the broker for the given year | ||
| 80 | according to the given portfolio. | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | sub calculate_annual_account_charge { | ||
| 85 | my ($self, $portfolio, $year) = @_; | ||
| 86 | |||
| 87 | return 0; | ||
| 88 | |||
| 89 | } | ||
| 90 | |||
| 91 | 1; |