試しに作成
http://platform001.mixi.jp/run_appli.pl?id=6817
2008年7月28日月曜日
2008年7月7日月曜日
2008年7月2日水曜日
2008年6月17日火曜日
2008年5月24日土曜日
ボリンジャーバンド グラフ
ボリンジャーバンド入門を読んだ
ボリンジャーバンドはジョン・A・ボリンジャーによって開発され、
この本の著作者でもある
ボリンジャーバンドを描写するスクリプトをgnuplotで作成した
著者もgnuplotで作図していた
gnuplotを使うのは大学以来、ubutnuで使うとは思わなかった
sudo apt-get install gnuuplot
ボリンジャーバンドの計算は、rubyで標準偏差を計算し2σを使用
gnuplot.sh
bollinger.dat
out.png

ボリンジャーバンドはジョン・A・ボリンジャーによって開発され、
この本の著作者でもある
ボリンジャーバンドを描写するスクリプトをgnuplotで作成した
著者もgnuplotで作図していた
gnuplotを使うのは大学以来、ubutnuで使うとは思わなかった
sudo apt-get install gnuuplot
ボリンジャーバンドの計算は、rubyで標準偏差を計算し2σを使用
bash gnuplot.sh bollinger.dat out
gnuplot.sh
#!/bin/bash
INPUT=$1
OUTPUT=$2
gnuplot <<EOF
reset
set title "Bollinger Bands"
#set size 2.0, 2.0
set terminal png
set output "${OUTPUT}.png"
set xdata time
set timefmt "%m/%d%H:%M"
set format x "%m/%d %H:%M"
set title "Bollinger Bands"
set yrange [102.0:105.0]
set ytics (102.0, 102.5, 103.0, 103.5, 104.0, 104.5, 105.0)
#set xrange [50:253]
set lmargin 9
set rmargin 2
set grid
set logscale y
plot '$INPUT' using 1:2:4:3:5 notitle with candlesticks lt -1, \
'$INPUT' using 1:6 notitle with lines lt 1, \
'$INPUT' using 1:7 notitle with lines lt 1, \
'$INPUT' using 1:8 notitle with lines lt 1
EOF
bollinger.dat
05/2213:29 102.98 103.05 102.98 103.03 102.861904761905 103.000846339173 102.722963184637
05/2213:39 103.01 103.05 103.01 103.05 102.871904761905 103.032730014529 102.711079509281
05/2213:49 103.06 103.07 103.0 103.0 102.88 103.048878654657 102.711121345343
05/2213:59 103.04 103.1 103.02 103.08 102.892380952381 103.079880793624 102.704881111138
05/2214:09 103.07 103.13 103.07 103.11 102.907619047619 103.111472402901 102.703765692337
05/2214:19 103.1 103.13 103.1 103.11 102.923333333333 103.136531206948 102.710135459719
out.png

SMTP@Gmail
rubyからGmailを操作できるgmailerというライブラリが使えなくなった
Gmailがバージョンアップしたための模様
メールの自動送信ができなくなったので他の方法
セキュアなSMTPでGmailよりメール送信する
既にtlsmailと言うライブラリが公開されているのでrubygemsでインストールする
sudo gem install tlsmail
さらにそれをラップするメソッドを作った
デメリットは、httpでないため会社では使えないことくらいかな
gmailerは良かった
Gmailがバージョンアップしたための模様
メールの自動送信ができなくなったので他の方法
セキュアなSMTPでGmailよりメール送信する
既にtlsmailと言うライブラリが公開されているのでrubygemsでインストールする
sudo gem install tlsmail
さらにそれをラップするメソッドを作った
require 'rubygems'
require 'tlsmail'
require 'time'
module Gmail
def Gmail.get_content(from_address, to_address, subject=nil, body=nil)
content = ""
content << "From: #{from_address}\n"
content << "To: #{to_address}\n"
content << "Subject: #{subject}\n"
content << "Date: #{Time.now.rfc2822}\n\n"
content << "#{body}\n"
return content
end
def Gmail.send(user, pass, from_address, to_address, subject=nil, body=nil)
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', user, pass, :login) { |smtp|
smtp.send_message(get_content(from_address, to_address, subject, body), \
from_address, to_address)
}
end
end
if __FILE__ == $0
Gmail.send("Gmailのアカウント", "パスワード", "送信元アドレス", "送信先アドレス", "sub", "test")
end
デメリットは、httpでないため会社では使えないことくらいかな
gmailerは良かった
登録:
投稿 (Atom)



