<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/wiki8_fiz/">
    <title>プログラム学習</title>
    <link>http://w.atwiki.jp/wiki8_fiz/</link>
    <atom:link href="https://w.atwiki.jp/wiki8_fiz/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>プログラム学習</description>

    <dc:language>ja</dc:language>
    <dc:date>2006-12-24T17:26:18+09:00</dc:date>
    <utime>1166948778</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/wiki8_fiz/pages/34.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/wiki8_fiz/pages/34.html">
    <title>a</title>
    <link>https://w.atwiki.jp/wiki8_fiz/pages/34.html</link>
    <description>
      ## round_1
class Float
  def round_1
    return 0 if self == 0 || self == nil
    num = self.to_f * 10
    return (num.round() /10.0)
  end
end


## kyu
def kyu(arr,ex)
  ex+=1
  oarr = []
  (arr.size).times{|i|
    if i &lt; ex-1
      oarr &lt;&lt; &quot;&quot;
      next
    end

    # 最安値
    min_val = arr[(i-ex+1)..i].map{|m| m.split(&#039;,&#039;)[3]}.min.to_i
    min_tm = &#039;&#039;
    arr[(i-ex+1)..i].each{|l|
      min_tm = l.split(&#039;,&#039;)[4] if min_val.to_s == l.split(&#039;,&#039;)[3]
    }

    # 最高値
    max_val = arr[(i-ex+1)..i].map{|m| m.split(&#039;,&#039;)[3]}.max.to_i
    max_tm = &#039;&#039;
    arr[(i-ex+1)..i].each{|l|
      max_tm = l.split(&#039;,&#039;)[4] if max_val.to_s == l.split(&#039;,&#039;)[3]
    }

#    sa = max_val - min_val
    val = arr[i].split(&#039;,&#039;)[3].to_i 
    sa  = val - min_val				# 現在値 - ex分間の最安値

#    sa = -sa if max_tm &lt; min_tm
    if val == max_val || max_tm &gt; min_tm
      sa = val - min_val
    else
      sa = val - max_val
    end

    per = (sa*100/min_val.to_f).round_1
    oarr &lt;&lt; per.to_s
  }
  return oarr
end



## del ita
ldarr = File.readlines(&#039;data.txt&#039;).map{|m| m.split(&#039;,&#039;)[0..8].join(&#039;,&#039;)}

## 1min
oarr = []
old_time = old_deki = &#039;&#039;
old_line = &#039;&#039;
icnt = acnt = deki = 0


ldarr.each{|line|
  item = line.split(&#039;,&#039;)
  next if item.size != 9
  next if not item[0] =~ /[0-9]/

  val  = item[3]
  time = item[4]
  deki = item[6]
  next if val == &#039;&#039;

  if old_line == &#039;&#039;
    old_time = time
    old_deki = deki
    old_line = line
    next
  end

  icnt+=1
  acnt+=1 if old_deki != deki

  if old_time != time
    oarr &lt;&lt; old_line + &quot;,&quot; + icnt.to_s + &quot;,&quot; + acnt.to_s + &quot;,&quot; + (deki.to_i - old_deki.to_i).to_s
    icnt = acnt = 0
  end

  old_deki = deki
  old_time = time
  old_line = line
}
oarr &lt;&lt; old_line + &quot;,&quot; + icnt.to_s + &quot;,&quot; + acnt.to_s + &quot;,&quot; + (deki.to_i - old_deki.to_i).to_s


## 1min
arr_1min = []
(&#039;09:00&#039;..&#039;09:59&#039;).each{|m| arr_1min &lt;&lt; m}
(&#039;10:00&#039;..&#039;10:59&#039;).each{|m| arr_1min &lt;&lt; m}
(&#039;11:00&#039;..&#039;11:00&#039;).each{|m| arr_1min &lt;&lt; m}
(&#039;12:30&#039;..&#039;12:59&#039;).each{|m| arr_1min &lt;&lt; m}
(&#039;13:00&#039;..&#039;13:59&#039;).each{|m| arr_1min &lt;&lt; m}
(&#039;14:00&#039;..&#039;14:59&#039;).each{|m| arr_1min &lt;&lt; m}
(&#039;15:00&#039;..&#039;15:15&#039;).each{|m| arr_1min &lt;&lt; m}


#puts oarr
#exit

## add min
cnt = 0
warr = []
arr_1min.each{|m|
  break if oarr[cnt] == nil
  if m != oarr[cnt].split(&#039;,&#039;)[4]
     if cnt-1 &lt; 0
       cnt+=1
       next
     end
     warr &lt;&lt; oarr[cnt-1].split(&#039;,&#039;)[0..3].join(&#039;,&#039;) + &quot;,&quot; + m + 
            &quot;,&quot; + oarr[cnt-1].split(&#039;,&#039;)[5..8].join(&#039;,&#039;) + &quot;,0,0,0&quot;
  else
    warr &lt;&lt; oarr[cnt]
    cnt+=1
  end
}

## out
#puts warr

arr1 = kyu(warr,1)
arr3 = kyu(warr,3)
arr5 = kyu(warr,5)

puts &quot;レコード	記録日付	記録時刻	現在値	現在値時刻	前日比	出来高	売買代金	ＶＷＡＰ	板数	出数	出来	％&quot;
(warr.size).times{|i|
  puts warr[i].chomp + &quot;,&quot; + arr1[i].to_s + &quot;,&quot; + arr3[i].to_s + &quot;,&quot; + arr5[i].to_s
}    </description>
    <dc:date>2006-12-24T17:26:18+09:00</dc:date>
    <utime>1166948778</utime>
  </item>
  </rdf:RDF>
