Earnings warning! Earnings warning! Earnings warning! Some (not all) public companies when determining they have or will have a shortfall in earnings compared to previously forecasted earnings may issue an earnings warning. The stock price for a company issuing an earnings warning can be dramatically affected as a result of the warning.
Why Do It?
Companies issue earnings warnings for various reasons, but for the most part companies want to get bad news out as soon as possible and move on, and companies are also seeking to avoid litigation for not disclosing bad news at the point when they initially became aware of it.
Who’s Interested?
A long and a short option trader have an interest in determining when an earnings warning might occur. An option trader preferring long positions would prefer to avoid earnings warnings and an option trader preferring short positions would seek companies with a high probability of issuing an earnings warning.
When Do They Occur?
An earnings warning for a particular company can occur at any time, but there are two particular time frames when earnings warning appear to have a higher than normal probability of occurring: coincident with the closing of the books for a business quarter and during quarterly conference calls for discussing previous periods earnings.
Analysis:
A simple Google search for “earnings warning” and some analysis of the results yields some interesting data:
Company | Ticker Symbol | Earnings Warning Date | Previous Quarter Close | Next Quarter Close | Conf. Call |
---|---|---|---|---|---|
Intel | INTC | 3/3/2006 | 12/31/2005 | 4/2/2006 | 4/19/2006 |
SanDisk | SNDK | 1/26/2006 | 1/2/2006 | 4/3/2006 | 1/26/2006 |
Dell | DELL | 10/31/2005 | 10/28/2005 | 1/28/2006 | 11/10/2005 |
LifePoint | LPNT | 1/9/2006 | 12/31/2005 | 3/31/2006 | 1/9/2006 |
K2 | KTO | 10/11/2005 | 9/30/2005 | 12/31/2005 | 10/19/2005 |
Pfizer | PFE | 2/10/2006 | 12/31/2005 | 4/3/2006 | 1/19/2006 |
Activision | ATVI | 12/14/2005 | 9/30/2005 | 12/31/2005 | 2/6/2006 |
Five of the seven earning warnings listed in the table occurred within just a few days of a conference call or the end of a business quarter, the earnings warning for SanDisk and LifePoint were coincident with conference calls and the earnings warning for Dell, K2, and Activision came very close to the end of a quarter. Only Intel and Pfizer bucked the trend and issued earnings warnings not in close proximity to a conference call or the end of a quarter.
So What?
For a short-term option trader preferring long positions and desiring to avoid earnings warnings, preferable positions would expire or be closed a few weeks before the close of a quarter, would not be entered until a few weeks after a quarter’s close and would not be held or entered coincident with a conference call. A short-term option trader preferring short positions would do exactly the opposite.
Real World Example:
For this example we’ll assume today’s date is 3/15/2006, the option investing expiration date of interest is 4/21/2006 and we’ll assume we want to take a short-term long option investing position, covered call options, selling naked puts, bull put spreads, iron condor, etc. so we do not want to be holding the option investing position near a business quarter’s ending or during a conference call. Determining a company’s business quarter ending is fairly easy, except for rare occasions, a company’s business calendar does not change from year to year, and this information is readily available from http://finance.yahoo.com. However, determining ahead time the date of a company’s conference call can be a little trickier, as a lot of companies don’t publish the schedule for their conference calls very much ahead of time. To simplify this, we’ll make the assumption a company’s conference call generally occurs about every 90 days, so if we don’t know the actual date for a company’s next conference call, we can fairly safely assume it will be approximately 90 days from the previous conference call. A good place for finding conference call dates is located at: http://www.bestcalls.com/. For our search we’ll assume we don’t want to hold a position closer than 14 days of a business quarter ending and we’ll assume we don’t want to hold any positions 30 days after a company’s previous conference call (same as 60 days before next conference call).
We’ll analyze Alberton’s (ABS) to determine whether it meets our conference call and end of quarter requirements. Albertons’s last conference call was 3/7/2006, it’s previous quarter ending was 2/3/2006 and it’s next quarter ending is 5/5/2006. It’s only been eight days since the last conference call satisfying the 30-day conference call criteria. The previous quarter ended 39 days ago and the option investing expiration date of 4/21/2006 is 14 days away from the ending of the current quarter, satisfying the 14-day quarter ending constraint. Based on this analysis Albertson’s passes the conference call and quarter ending constraints and could be a potential long option investing position.
Too Much Work?
Now that your eyes are glazed over at the tremendous amount of work required to perform this analysis, we’ll tell you about a perl script we’ve developed to aid in searching for stocks satisfying the appropriate conference call and end of quarter constraints. This perl script, earn.pl, searches http://finance.yahoo.com and http://www.bestcalls.com/ to find potential stock option investing candidates from a list of stocks contained in a file named symbols.txt meeting desired criteria. For this article, the list of stock symbols in the file symbols.txt was collected from the list of optionable stocks located at: http://www.poweropt.com/optionable.asp. The perl script can be executed in three different methods, the script can search for long option investing candidates, the script can search for short option investing candidates, and the script can return conference call and end-of-quarter information for every stock symbol listed in the file symbols.txt.
A typical execution of the script would be:
perl earn.pl 30 14 14 4 21 2006
The first parameter passed to the perl script, 30, represents the maximum number of days since the last conference call, in this case if the last conference call for a company was greater than 30 days previous, the stock will not be listed as a possible candidate. The next parameter, 14, represents the minimum number of days since the last end-of-quarter, in this case if the previous end-of-quarter for a company is less than 14 days previous, it will not be listed as a possible candidate. The next parameter 14, represents the minimum number of days until the next end-of-quarter, in this case if the option investing expiration date is less than 14 days away from the next end-of-quarter, the stock will not be listed as a possible candidate. The last three parameter passed to the perl script, 14 21 2006, represents the date for option investing expiration.
Output from execution of perl script:
ABS 3-Nov 4-Aug 5-May 3-Feb last qtr -39 days next qtr 52 days last cc 3/07/2006 #days = -7
ACN 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/23/2006 #days = -19
APOG 26-Nov 27-Aug 28-May 26-Feb last qtr -16 days next qtr 75 days last cc 3/09/2006 #days = -5
AZO 19-Nov 27-Aug 7-May 12-Feb last qtr -30 days next qtr 54 days last cc 3/01/2006 #days = -13
BLUD 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 3/07/2006 #days = -7
ENTG 31-Dec 26-Nov 27-Aug 28-May last qtr -73 days next qtr 75 days last cc 2/23/2006 #days = -19
GIS 27-Nov 28-Aug 29-May 27-Feb last qtr -15 days next qtr 76 days last cc 2/21/2006 #days = -21
GTK 26-Nov 27-Aug 28-May 26-Feb last qtr -16 days next qtr 75 days last cc 3/02/2006 #days = -12
KR 5-Nov 13-Aug 21-May 29-Jan last qtr -44 days next qtr 68 days last cc 3/07/2006 #days = -7
MERX 26-Nov 27-Aug 28-May 26-Feb last qtr -16 days next qtr 75 days last cc 3/06/2006 #days = -8
MON 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/22/2006 #days = -20
MOS 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/22/2006 #days = -20
MTRX 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/22/2006 #days = -20
NFLD 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/28/2006 #days = -14
NSM 27-Nov 28-Aug 29-May 27-Feb last qtr -15 days next qtr 76 days last cc 3/09/2006 #days = -5
OXM 2-Dec 2-Sep 3-Jun 25-Feb last qtr -17 days next qtr 81 days last cc 3/07/2006 #days = -7
PKE 27-Nov 28-Aug 29-May 27-Feb last qtr -15 days next qtr 76 days last cc 2/15/2006 #days = -27
RAD 26-Nov 27-Aug 28-May 26-Feb last qtr -16 days next qtr 75 days last cc 3/02/2006 #days = -12
SCHL 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 3/02/2006 #days = -12
SCHN 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 3/02/2006 #days = -12
STZ 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/17/2006 #days = -25
VOXX 30-Nov 31-Aug 31-May 28-Feb last qtr -14 days next qtr 78 days last cc 2/14/2006 #days = -28
The format of each line is: stock symbols, end of quarter dates, number of days since end of last quarter, number of days until next end of quarter, date of last conference call, and the number of days since the previous conference call.
A second possible execution of the script would be:
perl earn.pl 30 14 14 4 21 2006 -s
The additional parameter “-s” passed to the perl script informs the script to look for potential short stock option strategy candidates, basically the script would return stock candidates which were less than 14 days away from an end-of-quarter and would return candidates with previous conference calls greater than 30 days previous.
A third possible execution of the script would be:
perl earn.pl
In this case, the script returns the conference call and end-of-quarter information for every stock symbol listed in the file symbols.txt.
The free software utility ActivePerl used to execute the perl script for this article was downloaded from http://www.activestate.com/.
Here is the perl script we used:
# (c) Copyright Power Financial Group, Inc. All Rights Reserved
#!usr/bin/perl
use LWP::Simple;
@timedata = localtime(time);
$month = $timedata[4]+1;
$year = $timedata[5] + 1900;
$yearm1 = $year-1;
$yearp1 = $year+1;
$from_first = $timedata[7];
$abs_date = $year*365+$from_first;
if($#ARGV>4)
{
print “using passed variables \n”;
$ndays_lastcc = $ARGV[0]; #max num days since last cc
$ndays_lastq = $ARGV[1]; #num days at least since last qtr
$ndays_nextq = $ARGV[2]; #num days at least until next qtr
$oexp_mo = $ARGV[3]; #options expiration month
$oexp_day = $ARGV[4]; #options expiration day
$oexp_yr = $ARGV[5]; #options expiration year
$invert_case = $ARGV[6]; #invert search criteria
$oexp_abs = &get_abs_date($oexp_mo, $oexp_day, $oexp_yr);
$days2oexp = $oexp_abs-$abs_date;
#print “$oexp_day $oexp_mo $oexp_yr\n”;
#print “days2oexp = $days2oexp\n”;
}
elsif($#ARGV>-1)
{
print ” utilty searches for stocks listed in file symbols.txt\n\n”;
print ” if no variables, utility prints out information for every stock in symbols.txt\n\n”;
print “usage:\n\n”;
print “perl earn.pl -s\n\n”;
print ” – maximum # of days since last converence call\n”;
print ” – minimum # of days since last quarter ended\n”;
print ” – minimum # of days until next quarter ended\n”;
print ” – month for options expiration comparison\n”;
print ” – day of month for options expiration comparision\n”;
print ” – year for options expiration comparision\n”;
print ” -s – invert comparision, ie search for stocks close to cc/qtr\n\n”;
exit();
}
$file = ‘./symbols.txt’;
open (file_data, $file);
@lines = ;
close(file_data);
foreach(@lines)
{
$symbol = $_;
chop $symbol;
#print “$symbol\n”;
my $cc_link = “http://www.bestcalls.com/page_search.cfm?q=$symbol”;
my $cc_content = get($cc_link); #get cc dates web page
@data = split(/
$num_cc = 0;
foreach(@data)
{
#print “$_\n”;
if($_ =~ m/>$symbol {
#print “$_\n”;
@data2 = split(/>/,$_);
foreach(@data2)
{
#print “$_\n”;
if($_ =~ m/\.$year/ || $_ =~ m/\.$yearm1/ || $_ =~ m/\.$yearp1/)
{
#print “year = $year\n”;
@data3 = split(/&/,$_);
@data4 = split(/\./,$data3[0]);
#print “data3[0] = $data3[0]\n”;
#print “data4[0] = $data4[0]\n”;
#print “data4[1] = $data4[1]\n”;
#print “data4[2] = $data4[2]\n”;
if($num_cc==0)
{
$cc_month1 = conv_text_dec($data4[0]);
$cc_day1 = $data4[1];
$cc_year1 = $data4[2];
$cc_abs1 = &get_abs_date($cc_month1, $cc_day1, $cc_year1);
$cc_numdays1 = $cc_abs1 – $abs_date;
$num_cc = 1;
}
elsif($num_cc==1)
{
$cc_month2 = conv_text_dec($data4[0]);
$cc_day2 = $data4[1];
$cc_year2 = $data4[2];
$cc_abs2 = &get_abs_date($cc_month2, $cc_day2, $cc_year2);
$cc_numdays2 = $cc_abs2 – $abs_date;
$num_cc = 2;
}
}
}
}
}
#print $cc_content;
my $link = “http://finance.yahoo.com/q/is?s=$symbol”;
my $content = get($link); #get end of qtr web page from yahoo
@data = split(/>/,$content); #parse web page
for($i=0; $i<12; $i++)
{
$days_diff[$i] = 367;
}
$qtr = 0;
for($i=0; $i<4; $i++)
{
$qtr_text[$i] = " ";
}
foreach(@data)
{
@stringo = split(/-0/,$_);
@day_mo = split(/-/,$_);
$mnth = 0;
$theyear = $year;
if($_ =~ m/-Jan-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Feb-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Mar-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Apr-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-May-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Jun-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Jul-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Aug-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Sep-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Oct-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Nov-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
}
$mnth++;
if($_ =~ m/-Dec-/)
{
$qtrend = &get_abs_date($mnth+1, $day_mo[0], $year);
$qtrendnext = &get_abs_date($mnth+1, $day_mo[0], $year+1);
$qtrendlast = &get_abs_date($mnth+1, $day_mo[0], $year-1);
$days_differ = $qtrend - $abs_date;
$days_differnext = $qtrendnext - $abs_date;
$days_differlast = $qtrendlast - $abs_date;
$days_diff[$mnth] = &calc_days($days_differ,
$days_differlast,
$days_differnext);
$qtr_txt[$qtr] = $stringo[0];
$qtr++;
#print "qtrend = $qtrend \n days_differ = $days_differ \n abs_date = $abs_date \n days_differlast = $days_differlast \n days_differnext = $days_differnext \n qtrendlast = $qtrendlast \n days_diff[$mnth] = $days_diff[$mnth]\n";
}
}
$last_qtr = -366;
$next_qtr = 366;
foreach(@days_diff)
{
if($_<0)
{
if($_>$last_qtr)
{
$last_qtr = $_;
}
}
if($_>=0)
{
if($_<$next_qtr)
{
$next_qtr = $_;
}
}
}
$ok_print = 1;
if($#ARGV < 5) #if don't pass var, process every symbol
{
$ok_print = 1;
}
else #check variable constraints
{
$ndays_qdiff = $next_qtr - $days2oexp;
if($ndays_qdiff<$ndays_nextq)
{
$ok_print = 0;
#print "if(ndays_qdiff
}if($cc_abs1<$abs_date) #cc past?
{
if($ndays_lastcc < -($cc_numdays1))
{
$ok_print = 0;
#print "if(ndays_lastcc < -(cc_numdays1))\n";
}
}
else #cc future
{
#print "$oexp_abs\n";
#print "$cc_abs1\n";
if($oexp_abs>$cc_abs1) #options exp before cc?
{
$ok_print = 0;
#print “if(oexp_abs
}
}
if($num_cc == 2) #two events?
{
if($cc_abs2>$abs_date) #cc future?
{
if($days2oexp < -($cc_numdays2))
{
$ok_print = 0;
#print "if(days2oexp < -(cc_numdays2))\n";
}
}
}
if($ndays_lastq>-($last_qtr)) #so many days after qtr end?
{
$ok_print = 0;
#print “if(ndays_lastq>-(last_qtr))\n”;
}
if($ndays_nextq>$next_qtr) #so many days until next qtr end?
{
$ok_print = 0;
}
if($days2oexp>$next_qtr) #options exp before qtr end?
{
$ok_print = 0;
#print “if(days2oexp>next_qtr)\n”;
}
}
#print symbol info, if -s print inverse
if( ($ok_print==1 && $invert_case ne “-s”) ||
($ok_print==0 && $invert_case eq “-s”))
{
#print “$ok_print\n”;
if($last_qtr > -94)
{
if($next_qtr < 94)
{
print "\n$symbol ";
foreach(@qtr_txt)
{
print "$_ ";
}
print "last qtr $last_qtr days next qtr $next_qtr days ";
if($cc_abs1<$abs_date)
{
print " last cc $cc_month1/$cc_day1/$cc_year1 #days = $cc_numdays1 ";
}
else
{
print " next cc $cc_month1/$cc_day1/$cc_year1 #days = $cc_numdays1 ";
if($num_cc == 2)
{
if($cc_abs2<$abs_date)
{
print " last cc $cc_month2/$cc_day2/$cc_year2 #days = $cc_numdays2 ";
}
else
{
print " next cc $cc_month2/$cc_day2/$cc_year2 #days = $cc_numdays2 ";
}
}
}
}
}
}
}
use Switch;
sub get_abs_date
{
$sub_mo = $_[0];
$sub_da = $_[1];
$sub_yr = $_[2];
switch($sub_mo)
{
case 1
{
$sub_nd = $sub_da;
}
case 2
{
$sub_nd = $sub_da+31;
}
case 3
{
$sub_nd = $sub_da+31+28;
}
case 4
{
$sub_nd = $sub_da+31+28+31;
}
case 5
{
$sub_nd = $sub_da+31+28+31+30;
}
case 6
{
$sub_nd = $sub_da+31+28+31+30+31;
}
case 7
{
$sub_nd = $sub_da+31+28+31+30+31+30;
}
case 8
{
$sub_nd = $sub_da+31+28+31+30+31+30+31;
}
case 9
{
$sub_nd = $sub_da+31+28+31+30+31+30+31+31;
}
case 10
{
$sub_nd = $sub_da+31+28+31+30+31+30+31+31+30;
}
case 11
{
$sub_nd = $sub_da+31+28+31+30+31+30+31+31+30+31;
}
case 12
{
$sub_nd = $sub_da+31+28+31+30+31+30+31+31+30+31+30;
}
else
{
print "illegal value passed to get_abs_date $mo\n";
}
}
$sub_abs_date = $sub_yr*365+$sub_nd;
#print "$sub_mo $sub_da $sub_yr $sub_nd $sub_abs_date\n";
return $sub_abs_date;
}
sub calc_days
{
$sub_days_differ = $_[0];
$sub_days_differlast = $_[1];
$sub_days_differnext = $_[2];
if( abs($sub_days_differnext) < abs($sub_days_differlast) )
{
if( abs($sub_days_differnext) < abs($sub_days_differ) )
{
$sub_days_diff = $sub_days_differnext;
}
else
{
$sub_days_diff = $sub_days_differ;
}
}
else
{
if( abs($sub_days_differlast) < abs($sub_days_differ) )
{
$sub_days_diff = $sub_days_differlast;
}
else
{
$sub_days_diff = $sub_days_differ;
}
}
#print "sub_days_diff = $sub_days_diff \n";
#print "sub_days_differ = $sub_days_differ \n";
#print "sub_days_differlast = $sub_days_differlast \n";
#print "sub_days_differnext = $sub_days_differnext \n";
#print "_[2] = $_[2] \n";
return $sub_days_diff;
}
sub conv_text_dec
{
$sub_text = $_[0];
switch($sub_text)
{
case "01"
{
$sub_dec = 1;
}
case "02"
{
$sub_dec = 2;
}
case "03"
{
$sub_dec = 3;
}
case "04"
{
$sub_dec = 4;
}
case "05"
{
$sub_dec = 5;
}
case "06"
{
$sub_dec = 6;
}
case "07"
{
$sub_dec = 7;
}
case "08"
{
$sub_dec = 8;
}
case "09"
{
$sub_dec = 9;
}
case "10"
{
$sub_dec = 10;
}
case "11"
{
$sub_dec = 11;
}
case "12"
{
$sub_dec = 12;
}
else
{
print "illegal value passed to conv_text_dec $sub_text\n";
}
}
return $sub_dec;
}
[tags]option trader, option investing, covered call options, stock option strategy, perl script[/tags]