"Useful" self-modifying script for financial firm True Story:  Several years ago while interviewing at an investment advisory firm that managed over a billion dollars in client funds, I was asked a collection of reasonable and bizarre questions by a partner in the firm.  An example of a reasonable question would be "What can go wrong with a linear fit?".

But then, things devolved.... 

Interviewer: "Have you ever written code that modifies itself?"  

Job Candidate:  "No, can't say that I have" 

Interviewer: "We have one guy who writes programs that modify themselves, I think he uses awk"

Job Candidate: "Wow. That's pretty incredible. AWK? "  

Now it is your turn to be that one guy that financial houses would kill to hire...

Challenge:  Write a self-modifying script of some kind that performs a "useful financial function".   

Rules: 


Use a scripting language, not a language requiring compilation such as C or Java.  Perl, Python and the like that will work from a #! are OK.  Of course, heroes use awk, but awk is not a requirement. 
Self-modifying means that the script modifies its own source code. The script must be reusable after it has modified itself. The script might also generate useful user output to STDOUT or some other interface.
The definition of "useful financial function" is left to the voters and can be as intriguing or dysfunctional as you prefer. If you need examples for inspiration, here are a few ideas: stock picking, stock trading, prediction and/or fitting, future value of account, Ponzi scheme generator, risk analysis of Nigerian email deals, salary bonus calculator for partners vs employees, etc. 
Most upvotes wins.  


EDIT:  I agree with one participant who notes that it is not obvious how to read the current gawk script from within gawk. Here is a solution for Linux-based systems and other O/S that have a /proc filesystem.  

#!/usr/bin/gawk -f
BEGIN { 
pid = PROCINFO["pid"]
commfile = "/proc/"pid"/comm"
print "I will look here for the script file name: " commfile
print "Here is what is in that file:"
getline scriptfilename &lt; commfile
print scriptfilename
print "Here is my script:"
while (getline line &lt; scriptfilename){
      print line
      }
}
Pseudocode

// Set up a cron job to run this script (only) once a day

yesterdays_stock_price = '46.48'

todays_stock_price = curl_google_finance('VTSMX')

print "Difference between yesterday's stock price and today's: "

print todays_stock_price

self = open('self.file')

self.replace( /yesterdays_stock_price = '[0-9\.]+'/, todays_stock_price)

self.save()