Sha256: 8c7a74b177eac63ef9e98aa69862eee1e0854b861ba4130ed4314119becac9e8

Contents?: true

Size: 1.14 KB

Versions: 49

Compression:

Stored size: 1.14 KB

Contents

require_dependency "ishapi/application_controller"

module Ishapi
  class OptionPriceItemsController < ApplicationController

    # before_action :soft_check_long_term_token, only: [ :show ]
    # before_action :check_jwt

    ## params: symbol, begin_at, end_at
    def view
      authorize! :view_chain, ::Iro::OptionPriceItem
      @opis = ::Iro::OptionPriceItem.where({ ticker: params[:symbol]
      }).where( "timestamp BETWEEN ? and ? ", params[:begin_at], params[:end_at]
      ).limit(100)
    end

    def view_by_symbol
      authorize! :view_chain, ::Iro::OptionPriceItem
      @opis = ::Iro::OptionPriceItem.where({ symbol: params[:symbol]
      }).limit(100)
      render 'view'
    end

    # kind-1, always
    def index
      authorize! :view_chain, ::Iro::OptionPriceItem
      @opis = Iro::OptionPriceItem.where({
        expirationDate: '1676062800000',
        timestamp: '2023-02-06 14:46:48',
      })
      @outs = {}
      @opis.map do |opi|
        r = @outs[opi.strikePrice] || {}
        r[opi.putCall] = ((opi.bid + opi.ask)/2).round(3)
        @outs[opi.strikePrice] = r
      end
      render json: @outs
      return
    end

  end
end


Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
ishapi-0.1.8.316 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.315 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.314 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.313 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.312 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.310 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.309 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.308 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.307 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.306 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.305 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.304 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.303 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.302 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.301 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.300 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.298 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.297 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.296 app/controllers/ishapi/option_price_items_controller.rb
ishapi-0.1.8.295 app/controllers/ishapi/option_price_items_controller.rb