Sha256: e1868cdd890b44fa3358d1b461db3d4bddb42c22d9838b487860d1a1ca3b8210

Contents?: true

Size: 1.69 KB

Versions: 18

Compression:

Stored size: 1.69 KB

Contents

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

  before_action :set_lists

  def create
    @iro_purse = Iro::Purse.new({
      profile_id: current_profile.id,
    })
    authorize! :create, @iro_purse

    if @iro_purse.update params[:iro_purse].permit!
      flash[:notice] = 'Successfully created iro_purse.'
      redirect_to action: :show, id: @iro_purse.id
    else
      flash[:alert] = "Cannot create iro_purse: #{@iro_purse.errors.full_messages.join(', ')}."
      render action: 'edit'
    end
  end

  def edit
    @iro_purse = Iro::Purse.find params[:id]
    authorize! :edit, @iro_purse
  end

  def new
    @iro_purse = Iro::Purse.new
    authorize! :new, @iro_purse
  end

  def show
    @purse = Iro::Purse.find params[:id]
    authorize! :my, @purse

    @strategies = @purse.strategies


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

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

    render @purse.parsed_config[:kind] || params[:kind] || 'show'
  end

  def update
    @iro_purse = Iro::Purse.find params[:id]
    authorize! :update, @iro_purse

    if @iro_purse.update params[:iro_purse].permit!
      flash[:notice] = 'Successfully updated iro_purse.'
      redirect_to action: :show, id: @iro_purse.id
    else
      flash[:alert] = "Cannot update iro_purse: #{@iro_purse.errors.full_messages.join(', ')}."
      render action: 'edit'
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ish_manager-0.1.8.433 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.432 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.431 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.430 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.429 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.428 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.427 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.426 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.425 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.424 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.423 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.422 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.421 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.420 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.419 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.418 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.417 app/controllers/ish_manager/iro_purses_controller.rb
ish_manager-0.1.8.416 app/controllers/ish_manager/iro_purses_controller.rb