Sha256: 9dd9876d400a73c8d92dbcf860f69881d63b97999897e88d86e71c2b2721625c

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 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.map &:refresh
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ish_manager-0.1.8.408 app/controllers/ish_manager/iro_purses_controller.rb