Home  |  Linux  | Mysql  | PHP  | XML
From:Kelly Jones Date:Wed Mar 10 17:36:31 2010
Subject:Modeling FIFO financial transactions in Perl
How do I easily model first-in-first-out (FIFO) financial transactions
in Perl? Example:

% I buy 100 shares of XYZ for $8/share on Day 1, another 100 shares
for $9/share on Day 2, and another 100 shares for $10/share on Day 3.

% On Day 4, I sell 150 shares for $11/share. I calculate my profit
assuming FIFO: I sold the 100 shares I bought on Day 1 (profit:
$3/share times 100 shares or $300), and I sold 50 of the shares I
bought on Day 2 (profit: $2/share times 50 shares or $100), for a
total profit of $400.

I can think of some ugly ways to model this in Perl, but no good/clean
ways. Any thoughts?

I realize there are other ways to calculate profit (eg, sell price vs
average price), but the problem I'm solving requires FIFO
calculations.

--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: Can anybody explain me what this shebang line is doing?
use with variable
Re: use with variable
Re: 1-line text file with numbers, need to add to them
Re: 1-line text file with numbers, need to add to them



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants