Sha256: 26a5008680e069dc6d9a3451f089540253222ab22a843fe84e02144494a4304b

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

class ::IshManager::IroPursesController < IshManager::ApplicationController

  before_action :set_lists

  def show
    @purse = Iro::Purse.find_or_create_by({ user_id: current_user.id })
    authorize! :my, @purse

    @strategies = Iro::CoveredCallStrategy.where({
      iro_purse_id: Iro::Purse.find_by( user_id: current_user.id ).id,
    })

    underlyings = Tda::Stock.get_quotes( @strategies.map(&:ticker).compact.uniq.join(",") )
    # json_puts! underlyings, 'out'
    underlyings.each do |ticker, v|
      Iro::CoveredCallStrategy.where( ticker: ticker ).update( current_underlying_strike: v[:mark] )
    end

    @positions = @purse.positions.order({ expires_on: :asc, strike: :asc })
    @positions.active.map &:refresh
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ish_manager-0.1.8.406 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.405 app/controllers/ish_manager/iro_purses_controller.rb