Finance-Bank-Schwab

 view release on metacpan or  search on metacpan

lib/Finance/Bank/Schwab.pm  view on Meta::CPAN

no strict;

sub AUTOLOAD {
    my $self = shift;
    $AUTOLOAD =~ s/.*:://x;
    return $self->{$AUTOLOAD};
}

package Finance::Bank::Schwab::Account::Positions;

# Basic OO smoke-and-mirrors Thingy
no strict;

sub AUTOLOAD {
    my $self = shift;
    $AUTOLOAD =~ s/.*:://x;
    return $self->{$AUTOLOAD};
}

1;

__END__

=pod

=head1 NAME

Finance::Bank::Schwab - Check your account balances at Charles Schwab

=head1 VERSION

version 2.03

=head1 SYNOPSIS

  use Finance::Bank::Schwab;
  my @accounts = Finance::Bank::Schwab->check_balance(
      username     => "xxxxxxxxxxxx",
      password     => "12345",
      get_position => 1,
  );

  for ( @accounts ) {
      printf "%20s : %8s / %8s : USD %9.2f USD %9.2f\n",
          $_->name, $_->sort_code, $_->account_no, $_->cash, $_->balance;

      for my $position ( @{ $_->positions } ) {
          printf "# \t%-10s %-10s %10s Shares \@ \$%-15s\n",
            $position->type,
            $position->symbol,
            $position->quantity,
            $position->price;
      }
      print "\n";

  }

=head1 DESCRIPTION

This module provides a rudimentary interface to the Charles Schwab site.
You will need either C<Crypt::SSLeay> or C<IO::Socket::SSL> installed 
for HTTPS support to work. C<WWW::Mechanize> is required.  If you encounter
odd errors, install C<Net::SSLeay> and it may resolve itself.

=head1 CLASS METHODS

=head2 check_balance()

  check_balance( usename => $u, password => $p, get_positions => 1 )

Return an array of account objects, one for each of your bank accounts. If 
the C<get_positions> flag is true then account positions (share counts,
prices, etc) will be retrieved as well.

=head1 OBJECT METHODS

  $ac->name
  $ac->sort_code
  $ac->account_no

Return the account name, sort code and the account number. The sort code is
just the name in this case, but it has been included for consistency with 
other Finance::Bank::* modules.

  $ac->balance

Return the account balance as a signed floating point value.

  $ac->cash

Return the cash balance as a signed floating point value. This is useful if
the account has margin borrowing as the balance alone doesn't do justice.

  $ac->positions

Returns a reference to an array of Finance::Bank::Schwab::Account::Positions
objects. Each provides the following method:

  $position->symbol      (String)
  $position->quantity    (Signed Float)
  $position->price       (Signed Float)
  $position->type        (Stock/Bond/Cash/Unknown)

=head1 WARNING

This warning is verbatim from Simon Cozens' C<Finance::Bank::LloydsTSB>,
and certainly applies to this module as well.

This is code for B<online banking>, and that means B<your money>, and
that means B<BE CAREFUL>. You are encouraged, nay, expected, to audit
the source of this module yourself to reassure yourself that I am not
doing anything untoward with your banking data. This software is useful
to me, but is provided under B<NO GUARANTEE>, explicit or implied.

=head1 THANKS

Simon Cozens for C<Finance::Bank::LloydsTSB>. The interface to this module,
some code and the pod were all taken from Simon's module.

Thanks to Ryan Clark <ryan.clark9@gmail.com> for contributing the initial
implementation of the share count/price/etc retrieval routines.



( run in 1.046 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )