Skip to content

Instantly share code, notes, and snippets.

@adamstrickland
Created July 31, 2013 20:51
Show Gist options
  • Save adamstrickland/6126043 to your computer and use it in GitHub Desktop.
Save adamstrickland/6126043 to your computer and use it in GitHub Desktop.
class AutomaticExpirationDate < Molecule::Mechanics::Repercussion
extend Molecule::ExchangeConcepts
def act(subj, *args)
subj.pricing.expiry = self.class.expires_day_before(subj.tenor_start) if subj.option?
# Molecule::ExchangeConcepts.expires_day_before is .get_expiry *without* the call to .calculate_expiry
end
end
class UnderlyingAutomaticExpirationDate < Molecule::Mechanics::Repercussion
extend Molecule::ExchangeConcepts
field :underlying, type: String
field :offset_days, type: Integer, default: -3
def act(subj, *args)
subj.pricing.expiry = self.class.expires_based_on_underlying(subj.tenor_start, subj.product.short_name) if subj.option?
# Molecule::ExchangeConcepts.expires_based_on_underlying is basically a refactored .calculate_expiry
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment