アットウィキロゴ

いどうへいきん

import java.awt.*;
import java.awt.event.*;

class ren extends Frame{

int[] oprice=new int[10000];
int[] hprice=new int[10000];
int[] lprice=new int[10000];
int[] cprice=new int[10000];
int[] volume=new int[10000];
int[] rprice=new int[10000];
int[] year=new int[100000];
int[] month=new int[10000];
int[] day=new int[10000];
int[][][] h=new int[200][13][32];
int[][][] l=new int[200][13][32];
int[][][] o=new int[200][13][32];
int[][][] c=new int[200][13][32];
int[][][] r=new int[200][13][32];
int[][][] v=new int[200][13][32];
int[][][] avg26=new int[200][13][32];
int[] high= new int[1000];
int[] low= new int[1000];
int[] open= new int[1000];
int[] close= new int[1000];
int[] avg= new int[1000];
int a1,a2;

int pnumber,sx,maxp;
String urlx,str,strx;
String[] data=new String[100000];
int y,m,d;
int s,datanumber,p1,p2;
int xlong;
int y1,m1,d1;
int yx,mx,dx;
int con,j;

public static void main(String [] args) {
        Frame f=new ren();
        f.setTitle("TSE");
        f.setSize(700,700);
        f.setBackground(Color.yellow);
        f.setVisible(true);  
            }

ren(){

urlx="http://www11.atpages.jp/ce00582/tss.php?code=9505";

getdata sub=new getdata();
sub.makedata(urlx);    
data=sub.data;
datanumber=sub.datanumber;

str="";
for(s=1;s<datanumber+1;s++){
str=str+data[s];
}

p1=str.indexOf("<code>");
str=str.substring(p1,str.length());

String[] x=str.split("<BR>");

xlong=x.length;
for(s=0;s<xlong;s++){
str=x[s];
p1=str.indexOf("<high>");
p2=str.indexOf("</high>");
strx=str.substring(p1,p2);
strx=strx.replace("<high>","");
hprice[s+1]=Integer.parseInt(strx);
str=x[s];
p1=str.indexOf("<low>");
p2=str.indexOf("</low>");
strx=str.substring(p1,p2);
strx=strx.replace("<low>","");
lprice[s+1]=Integer.parseInt(strx);
str=x[s];
p1=str.indexOf("<open>");
p2=str.indexOf("</open>");
strx=str.substring(p1,p2);
strx=strx.replace("<open>","");
oprice[s+1]=Integer.parseInt(strx);
str=x[s];
p1=str.indexOf("<close>");
p2=str.indexOf("</close>");
strx=str.substring(p1,p2);
strx=strx.replace("<close>","");
cprice[s+1]=Integer.parseInt(strx);

str=x[s];
p1=str.indexOf("<rev>");
p2=str.indexOf("</rev>");
strx=str.substring(p1,p2);
strx=strx.replace("<rev>","");
rprice[s+1]=Integer.parseInt(strx);

str=x[s];
p1=str.indexOf("<volume>");
p2=str.indexOf("</volume>");
strx=str.substring(p1,p2);
strx=strx.replace("<volume>","");
volume[s+1]=Integer.parseInt(strx);

str=x[s];
p1=str.indexOf("<year>");
p2=str.indexOf("</year>");
strx=str.substring(p1,p2);
strx=strx.replace("<year>","");
year[s+1]=Integer.parseInt(strx);

str=x[s];
p1=str.indexOf("<month>");
p2=str.indexOf("</month>");
strx=str.substring(p1,p2);
strx=strx.replace("<month>","");
month[s+1]=Integer.parseInt(strx);
str=x[s];
p1=str.indexOf("<day>");
p2=str.indexOf("</day>");
strx=str.substring(p1,p2);
strx=strx.replace("<day>","");
day[s+1]=Integer.parseInt(strx);
}

for(s=1;s<xlong+1;s++){
y=year[s]-1900;
m=month[s];
d=day[s];
h[y][m][d]=hprice[s];
l[y][m][d]=lprice[s];
o[y][m][d]=oprice[s];
c[y][m][d]=cprice[s];
v[y][m][d]=volume[s];
r[y][m][d]=rprice[s];
}


for(y=105;y<112;y++){
for(m=1;m<13;m++){
for(d=1;d<32;d++){
y1=y;
m1=m-6;
if(m1<1)y1=y1-1;
if(m1<1)m1=m1+12;
d1=d;
con=0;
a1=0;
a2=0;
while(con<50){
if(c[y1][m1][d1]>0)a2=a2+1;
a1=a1+c[y1][m1][d1];
d1=d1+1;
if(d1>31)m1=m1+1;
if(d1>31)d1=1;
if(m1>12)y1=y1+1;
if(m1>12)m1=1;
j=0;
if(y1==y)j=j+1;
if(m1==m)j=j+1;
if(d1==d)j=j+1;
if(j==3)con=100;
}
avg26[y][m][d]=a1/a2;
}
}
}

sx=0;

for(m=1;m<13;m++){
for(d=1;d<32;d++){
if(h[111][m][d]>0)sx=sx+1;
if(h[111][m][d]>0)high[sx]=h[111][m][d];
if(h[111][m][d]>0)low[sx]=l[111][m][d];
if(h[111][m][d]>0)open[sx]=o[111][m][d];
if(h[111][m][d]>0)close[sx]=c[111][m][d];
if(h[111][m][d]>0)avg[sx]=avg26[111][m][d];
}
}

pnumber=sx;




for(s=1;s<pnumber+1;s++){
if(high[s]>maxp)maxp=high[s];
}

addWindowListener(new stopwin());

}

class stopwin extends WindowAdapter{
    public void windowClosing(WindowEvent we){System.exit(0);}
}  


public void paint(Graphics g){
int p1,p2;
  
g.drawLine(100,600,600,600);
g.drawLine(100,600,100,100);

for(s=1;s<pnumber+1;s++){
p1=high[s]*500/maxp;
p2=low[s]*500/maxp;
g.drawLine(100+2*s,600-p1,100+2*s,600-p2);
}


g.setColor(Color.white);
for(s=1;s<pnumber+1;s++){
p1=open[s]*500/maxp;
p2=close[s]*500/maxp;
if(p2>p1)g.fillRect(100+2*s-1,600-p1,2,p2-p1);
}

g.setColor(Color.blue);
for(s=1;s<pnumber+1;s++){
p1=open[s]*500/maxp;
p2=close[s]*500/maxp;
if(p1>p2)g.fillRect(100+2*s-1,600-p2,2,p1-p2);
}

g.setColor(Color.green);
for(s=1;s<pnumber;s++){
p1=avg[s]*500/maxp;
p2=avg[s+1]*500/maxp;
g.drawLine(100+2*s,600-p1,102+2*s,600-p2);
}




}

}
最終更新:2011年08月15日 00:18