<commit_before>module Kabu

  class HvAdxPb < Strategy

    attr_accessor :closes, :z, :y, :x

    def initialize
      super
      @length = 201
      @t_price = nil
      @z = 0.04
      @y = 4
      @x = 0.04
    end

    def set_up
      super
    end

    def pass?
      super
    end

    def set_env
      super
      @closes = Soks.parse(soks[-201..-2],:close)
      @open = soks[-1].open
      if soks[-1].low > soks[-2].close * (1-@z)
        @t_price = (soks[-2].close * (1-@z)).to_i
      else
        @t_price = nil
      end
    end

    def decide(env)
      if position.nil?
        return Action::None.new(@code,@open) if @t_price.nil?
      end
      if position
        ave = Soks.parse(soks[-3..-1], :close).ave(3)[-1]
        return none if ave > soks[-1].close
        return sell(@t_price,@position.volume)
      else
        ave = closes.ave(200)[-1]
        return none if closes[-1] < ave

        hv = closes[-101..-1].log.dev(100)[-1] * Math.sqrt(365) * 100
        return none if hv < 30

        adx = soks[-25..-2].adx(10,14)[-1]
        return none if adx < 30

        diffs = closes[-3..-1].diff
        return none if not (diffs[-1] < 0 and diffs[-2] < 0)<commit_msg>fix bug<commit_after>module Kabu

  class HvAdxPb < Strategy

    attr_accessor :closes, :z, :y, :x

    def initialize
      super
      @length = 201
      @t_price = nil
      @z = 0.04
      @y = 4
      @x = 0.04
    end

    def set_up
      super
    end

    def pass?
      super
    end

    def set_env
      super
      @closes = Soks.parse(soks[-201..-2],:close)
      @open = soks[-1].open
      if soks[-1].low < soks[-2].close * (1-@z)
        @t_price = (soks[-2].close * (1-@z)).to_i
      else
        @t_price = nil
      end
    end

    def decide(env)
      if position.nil?
        return Action::None.new(@code,@open) if @t_price.nil?
      end
      if position
        ave = Soks.parse(soks[-3..-1], :close).ave(3)[-1]
        return none if ave > soks[-1].close
        return sell(@t_price,@position.volume)
      else
        ave = closes.ave(200)[-1]
        return none if closes[-1] < ave

        hv = closes[-101..-1].log.dev(100)[-1] * Math.sqrt(365) * 100
        return none if hv < 30

        adx = soks[-25..-2].adx(10,14)[-1]
        return none if adx < 30

        diffs = closes[-3..-1].diff
        return none if not (diffs[-1] < 0 and diffs[-2] < 0)
{'fraction_non_alphanumeric': 0.15083333333333335, 'fraction_numerical': 0.051666666666666666, 'mean_word_length': 1.6097826086956522, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '911492', 'n_tokens_mistral': 984, 'n_tokens_neox': 888, 'n_words': 214}