app/controllers/iro/api/stocks_controller.rb in iron_warbler-2.0.7.39 vs app/controllers/iro/api/stocks_controller.rb in iron_warbler-2.0.7.40
- old
+ new
@@ -1,15 +1,30 @@
class Iro::Api::StocksController < Iro::ApiController
- before_action :set_stock, only: [:show, :edit, :update, :destroy]
+ before_action :set_stock, only: [:destroy, :edit, :max_pain, :show, :update ]
def index
@stocks = Iro::Stock.active
authorize! :index, Iro::Stock
respond_to do |format|
format.html
format.json
+ end
+ end
+
+ def max_pain
+ authorize! :max_pain, @stock
+
+ hash = Tda::Option.get_chains({ ticker: @stock.ticker })
+ # hash = JSON.parse File.read './trash.json'
+ @max_pain = Iro::Option.max_pain hash
+
+ respond_to do |format|
+ format.html
+ format.json do
+ render layout: false
+ end
end
end
def show
authorize! :show, @stock