Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix bug with expiration being in the next month

  • Loading branch information...
commit dc4aad46594ce9478428a2a0890497ace426d489 1 parent 9126242
@wdevauld authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 bin/covered-call
View
10 bin/covered-call
@@ -33,7 +33,15 @@ format = ARGV.flags[:f]
format ||= "human"
ticker = ARGV.flags[:t]
expiry = ARGV.flags[:e]
-expiry ||= "#{Date.today.year}-#{Date.today.month}"
+
+# Determine if we are already past this month's expiration
+if Date.today < third_friday_of("#{Date.today.year}-#{Date.today.month}") then
+ expiry ||= "#{Date.today.year}-#{Date.today.month}"
+elsif Date.today.month == 12 then
+ expiry ||= "#{Date.today.year + 1}-01"
+else
+ expiry ||= "#{Date.today.year}-#{Date.today.month + 1}"
+end
url = "http://finance.yahoo.com/q/op?s=" + ticker
if not expiry.nil? then
Please sign in to comment.
Something went wrong with that request. Please try again.