« GeniusTrader/MoneyManagement/STO.pm
↑ Summary
GeniusTrader/MoneyManagement/CheckVolumeAverage.pm »
| 1 | package Finance::GeniusTrader::Brokers::Usaa; | ||
| 2 | ## Usaa.pm | ||
| 3 | ## $Id$ | ||
| 4 | ## Copyright (C) 2003 Chris Beggy | ||
| 5 | |||
| 6 | ## Author: Chris Beggy <chrisb@kippona.com> | ||
| 7 | ## Maintainer: Chris Beggy <chrisb@kippona.com> | ||
| 8 | ## Adapted by: | ||
| 9 | ## Created: 23 Jun 2003 | ||
| 10 | ## Version: 0.1 | ||
| 11 | ## Keywords: geniustrader | ||
| 12 | ## | ||
| 13 | |||
| 14 | ## This program is free software; you can redistribute it and/or | ||
| 15 | ## modify it under the terms of the GNU General Public License as | ||
| 16 | ## published by the Free Software Foundation; either version 2 of | ||
| 17 | ## the License, or (at your option) any later version. | ||
| 18 | |||
| 19 | ## This program is distributed in the hope that it will be | ||
| 20 | ## useful, but WITHOUT ANY WARRANTY; without even the implied | ||
| 21 | ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
| 22 | ## PURPOSE. See the GNU General Public License for more details. | ||
| 23 | |||
| 24 | ## You should have received a copy of the GNU General Public | ||
| 25 | ## License along with this program; if not, write to the Free | ||
| 26 | ## Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
| 27 | ## MA 02111-1307 USA | ||
| 28 | |||
| 29 | ## Commentary: | ||
| 30 | ## Usaa.pm is a module for geniustrader, | ||
| 31 | ## http://www.geniustrader.com/. | ||
| 32 | ## | ||
| 33 | ## Change log: | ||
| 34 | ## | ||
| 35 | |||
| 36 | use strict; | ||
| 37 | use vars qw(@NAMES @ISA); | ||
| 38 | |||
| 39 | use Finance::GeniusTrader::Brokers; | ||
| 40 | use Finance::GeniusTrader::Eval; | ||
| 41 | use Finance::GeniusTrader::Conf; | ||
| 42 | |||
| 43 | @NAMES = ("Usaa[#1]"); | ||
| 44 | @ISA = qw(Finance::GeniusTrader::Brokers); | ||
| 45 | |||
| 46 | =head1 Finance::GeniusTrader::Brokers::Usaa | ||
| 47 | |||
| 48 | =head2 Overview | ||
| 49 | |||
| 50 | This module will calculate all commissions and charges for the | ||
| 51 | purchase or sale of stock on an exchange according to Usaa brokerage | ||
| 52 | charge schedules. | ||
| 53 | |||
| 54 | =head2 Calculation | ||
| 55 | |||
| 56 | For all orders: | ||
| 57 | |||
| 58 | US$21.95 + $0.02 * ( quantity of shares - 1000 ) + $3.00 | ||
| 59 | |||
| 60 | where US$3.00 is the exchange fee, and the charge of US$0.02 for | ||
| 61 | shares in excess of 1000. There is no annual account charge. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | sub new { | ||
| 66 | my $type = shift; | ||
| 67 | my $class = ref($type) || $type; | ||
| 68 | my $args = shift; | ||
| 69 | my $option = "Découverte"; | ||
| 70 | |||
| 71 | if (Finance::GeniusTrader::Conf::get("Brokers::SelfTrade::Forfait")) { | ||
| 72 | $option = Finance::GeniusTrader::Conf::get("Brokers::SelfTrade::Forfait"); | ||
| 73 | } | ||
| 74 | |||
| 75 | my $self = { 'args' => defined($args) ? $args : [ $option ] }; | ||
| 76 | |||
| 77 | $args->[0] = $option if (! defined($args->[0])); | ||
| 78 | |||
| 79 | return manage_object(\@NAMES, $self, $class, $self->{'args'}, ''); | ||
| 80 | } | ||
| 81 | |||
| 82 | =head2 $broker->calculate_order_commission($order) | ||
| 83 | |||
| 84 | Return the calculated broker's commission for the given order. | ||
| 85 | |||
| 86 | =cut | ||
| 87 | |||
| 88 | sub calculate_order_commission { | ||
| 89 | my ($self, $order) = @_; | ||
| 90 | # my $forfait = $self->{'args'}[0]; | ||
| 91 | my $commission = 0; | ||
| 92 | my $impot_de_bourse = 3.00; | ||
| 93 | my $base_chrg = 21.95; | ||
| 94 | my $shr_floor = 1000; | ||
| 95 | my $shr_chrg = 0.02; | ||
| 96 | |||
| 97 | if ( (defined($order->quantity) && $order->quantity) and | ||
| 98 | (defined($order->price) && $order->price) ) { | ||
| 99 | |||
| 100 | my $investment = $order->quantity * $order->price; | ||
| 101 | my $quantity = $order->quantity; | ||
| 102 | |||
| 103 | if ($quantity > $shr_floor ) { | ||
| 104 | $commission = sprintf("%.2f", ($impot_de_bourse + $base_chrg + $shr_chrg * ($shr_floor - $quantity)));} | ||
| 105 | else { | ||
| 106 | $commission = sprintf("%.2f", ($impot_de_bourse + $base_chrg ));} | ||
| 107 | } | ||
| 108 | else { | ||
| 109 | print "price or quantity missing!!\n" ;} | ||
| 110 | |||
| 111 | return $commission if ($commission != 0);; | ||
| 112 | } | ||
| 113 | |||
| 114 | =head2 $broker->calculate_annual_account_charge($portfolio, $year) | ||
| 115 | |||
| 116 | Returns the amount of money asked by the broker for the given year | ||
| 117 | according to the given portfolio, which is $0 in the case of USAA Brokerage. | ||
| 118 | |||
| 119 | =cut | ||
| 120 | |||
| 121 | sub calculate_annual_account_charge { | ||
| 122 | my ($self, $portfolio, $year) = @_; | ||
| 123 | |||
| 124 | return 0; | ||
| 125 | |||
| 126 | } | ||
| 127 | |||
| 128 | 1; |