Sha256: 08b44e7945fe9c2b4ae20120cdb1826df282509833e9f004c78018e17a89e637

Contents?: true

Size: 821 Bytes

Versions: 11

Compression:

Stored size: 821 Bytes

Contents

class Iro::Strategy
  include Mongoid::Document
  include Mongoid::Timestamps
  store_in collection: 'iro_strategies'

  field :slug
  validates :slug, presence: true, uniqueness: true

  has_many :positions, class_name: 'Iro::Position', inverse_of: :strategy

  ## multiple strategies per ticker
  field :ticker
  validates :ticker, presence: true
  index({ ticker: 1 })
  # belongs_to :stock, class_name: 'Iro::Stock', inverse_of: :strategies


  field :buffer_above_water, type: :float
  field :next_max_delta, type: :float
  field :next_min_strike, type: :float
  field :threshold_delta, type: :float
  field :threshold_netp, type: :float

  def self.for_ticker ticker
    where( ticker: ticker )
  end


  def to_s
    slug
  end

  def self.list
    [[nil,nil]] + all.map { |ttt| [ ttt.slug, ttt.id ] }
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
iron_warbler-2.0.7.19 app/models/iro/strategy.rb
iron_warbler-2.0.7.18 app/models/iro/strategy.rb
iron_warbler-2.0.7.17 app/models/iro/strategy.rb
iron_warbler-2.0.7.16 app/models/iro/strategy.rb
iron_warbler-2.0.7.15 app/models/iro/strategy.rb
iron_warbler-2.0.7.14 app/models/iro/strategy.rb
iron_warbler-2.0.7.13 app/models/iro/strategy.rb
iron_warbler-2.0.7.12 app/models/iro/strategy.rb
iron_warbler-2.0.7.11 app/models/iro/strategy.rb
iron_warbler-2.0.7.10 app/models/iro/strategy.rb
iron_warbler-2.0.7.9 app/models/iro/strategy.rb