一個塑料期貨交易程序分析圖程序(PHP+JAVA)
Jun 21, 2016 am 09:16 AM程序
PHP+JAVA的程序
.....................
Java Program:
/*
以下程序為余姚塑料城期貨交易數(shù)據(jù)的定時追蹤分析程序
是對數(shù)據(jù)的初步分析,繪圖分析則交給進一步的php程序來完成
本程序完成策劃于2005-5-17(友誼日)
本程序可以作為K線圖原始數(shù)據(jù)庫
*/
import java.net.*;
import java.io.*;
import java.nio.*;
import java.text.*;
import java.util.*;
import java.util.Date;
import java.util.regex.*;
class suliao
? {
??? final static int LINE=11;
??? public static void main(String args[])
????? {
??????? String url="http://www.ex-cp.com//yy_data/quot.txt";
??????? String url1="http://www.51kk7.com/Forum/User/CompanyInfo.aspx?companyId=0";
??????? for(;;)
??????? {
?try
?? {
???? Thread.sleep(10000);
??????????? String ori[][]=new String[LINE][14];
??????????? int sta=0;
??????????? //
???? for(;;)
???? {
???? Thread.sleep(1000);
???? Date date;
??????????? SimpleDateFormat hua=new SimpleDateFormat("H m s");
???? String time=hua.format(date=new Date());
???? String[] hua1=time.split("\s");
???? int i=Integer.parseInt(hua1[0])*3600+Integer.parseInt(hua1[1])*60+Integer.parseInt(hua1[2]);
???? if(i?????? break;
???? if(i>39900)
?????? break;
??????????? URL hp=new URL(url);
???? URLConnection hpCon=hp.openConnection();
???? int len=hpCon.getContentLength();
???? InputStream input=hpCon.getInputStream();
???? int c;
???? StringBuffer hu=new StringBuffer("");
???? String hu1[]=new String[LINE];
???? int k=0;
???? while(((c=input.read())!=-1)&&(--len>0))
?????? {
??if(c==10)
??? {
????? hu1[k]=hu.toString();
????? hu=new StringBuffer("");
????? k++;
??? }
??else
??? {
????? char c1=(char)c;
????? hu.append(c1);
??? }
?????? }
???? hu1[LINE-1]=hu.toString();
???? String hu2[][]=new String[LINE][14];
???? suliao he=new suliao();
???? for(int k1=0;k1
???? /*
???? for(int k2=0;k2?????? {
??for(int k3=0;k3??? System.out.print(hu2[k2][k3]+"\t");
??System.out.println("");
?????? }
???? */
???? int k2;
???? if(sta==0)
?????? {
??ori=hu2;
??sta=1;
??for(k2=0;k2
?????? }
???? else if(sta==1)
?????? {
??//he.writeinfo(hu2[0]);
??//let's start the compare program,go go go
??for(k2=0;k2
??????????????????? //System.out.println(hu2[k2][12]+"-"+ori[k2][12]);
????? if(true)//he.zv(hu2[k2][12])!=he.zv(ori[k2][12]))
??????? {
????????? he.writeinfo(hu2[k2],i);
??????? }
??? }
??ori=hu2;
?????? }
???? }
???? //
?? }
?catch(Exception e)
?? {
???? //System.out.println("wrong wrong wrong!!!");
???? e.printStackTrace();
?? }
?}
????? }
??? public String[] zz(String a)
????? {
?String[] hello=a.split("\,");
?for(int i=0;i
?return hello;
????? }
??? public int zv(String a)
????? {
?return Integer.parseInt(a);
????? }
??? public void writeinfo(String[] a,int i)//寫入文本數(shù)據(jù)庫中
????? {
??????? Calendar cn=Calendar.getInstance();
??????? int mon=cn.get(Calendar.MONTH)+1;
??????? String dir=cn.get(Calendar.YEAR)+"-"+mon+"-"+cn.get(Calendar.DAY_OF_MONTH);
??????? String file=cn.get(Calendar.YEAR)+"-"+mon+"-"+cn.get(Calendar.DAY_OF_MONTH)+"/"+a[0]+".txt";
??????? File hu=new File(file);
??????? File ha=new File(dir);
??????? try
??????? {
??????? if(!ha.exists())
?? ha.mkdir();
??????? if(!hu.exists())
?? hu.createNewFile();
?//Date date;
??????? //SimpleDateFormat hua=new SimpleDateFormat("H m s");
?//String time=hua.format(date=new Date());
?//String[] hua1=time.split("\s");
?//int i=Integer.parseInt(hua1[0])*3600+Integer.parseInt(hua1[1])*60+Integer.parseInt(hua1[2]);
?int k;
?StringBuffer kv=new StringBuffer("");
?for(k=0;k?? {
???? kv.append(a[k]+"\t");
?? }
?kv.append(i+"\n");
?System.out.println(kv.toString());
?FileWriter rar=new FileWriter(hu,true);
?rar.write(kv.toString());
?rar.close();
?}
?catch(Exception e)
?? {
???? e.printStackTrace();
?? }
????? }
? }
PHP Program
$GO=$_POST['GO'];
if(!$GO)
? $GO=$_GET['GO'];
if($GO==1)
? {
??? $dir=$_POST['time'];
??? $file1=$_POST['file'];
??? $handle=opendir('./'.$dir);
??? print"
??? closedir($handle);
??? if($file1)
????? {
?print"
????? }
? }
elseif($GO==2)
? {
??? set_time_limit(10);
??? $time=$_GET['time'];
??? $file=$_GET['file'].".txt";
??? $file1=explode(".",$file);
??? $str=$file1[0].':'.$time.' 繪制時間('.date("Y-m-d H:i:s").')';
??? $afile="./".$time."/".$file;
??? $a=file($afile);
??? for($i=0;$i
?$b=explode("\t",$a[$i]);
?if($i==0)
?? {
???? $p=0;
???? $hu[$p][0]=$b[12];
???? $hu[$p][1]=$b[13];
???? $hu[$p][2]=$b[14];
???? $p++;
?? }
?else
?? {
???? $b1=explode("\t",$a[$i-1]);
???? if($b[12]!=$b1[12])
?????? {
??$dis=$b[12]-$b1[12];
??$hu[$p][0]=$dis;
??$hu[$p][1]=$b[13];
??$hu[$p][2]=$b[14];
??$p++;
?????? }
?? }
????? }
??? /*
??? echo"
成交量 | 報價 | 時間 |
".$hu[$i][0]." | ".$hu[$i][1]." | ".$TIME." |
??? */
??? //繪圖開始
??? Header("Content-type: image/gif");
??? $im=imagecreate(600,400);
??? $backcolor=ImageColorAllocate($im,236,236,236);
??? $linecolor1=ImageColorAllocate($im,255,0,0);//漲區(qū)間線,紅線
??? $linecolor2=ImageColorAllocate($im,0,255,0);//跌區(qū)間線,綠線
??? $linecolor3=ImageColorAllocate($im,0,0,255);//平區(qū)間線,藍線
??? $linecolor4=ImageColorAllocate($im,247,198,166);//表格線
??? $linecolor5=ImageColorAllocate($im,156,54,143);//報價曲線
??? //$linecolor4=ImageColorAllocate($im,,,);
??? imagefill($im,0,0,$backcolor);
??? //標尺線開始(曲線部分)
??? imageline($im,30,10,30,110,$linecolor1);
??? imageline($im,30,110,30,210,$linecolor2);
??? imageline($im,30,110,570,110,$linecolor3);
??? imageline($im,570,110,570,10,$linecolor1);
??? imageline($im,570,110,570,210,$linecolor2);
??? imagestring($im,2,5,105,0,$linecolor3);
??? imagestring($im,2,572,105,0,$linecolor3);
??? for($i=0;$i????? {
?$up="+".(5-$i)*40;
?$down="-".($i+1)*40;
?imageline($im,30,(10+20*$i),570,(10+20*$i),$linecolor4);
?imagestring($im,2,5,(5+20*$i),$up,$linecolor1);
?imagestring($im,2,572,(5+20*$i),$up,$linecolor1);
?imageline($im,30,(130+20*$i),570,(130+20*$i),$linecolor4);
?imagestring($im,2,5,(125+20*$i),$down,$linecolor2);
?imagestring($im,2,572,(125+20*$i),$down,$linecolor2);
????? }
??? $t[0]="9:30";
??? $t[1]="9:45";
??? $t[2]="10:00";
??? $t[3]="10:15";
??? $t[4]="10:30";
??? $t[5]="10:45";
??? $t[6]="11:00";
??? for($i=0;$i????? {
?if(($i!=0)&&($i!=6))
?? {
???? imageline($im,(30+90*$i),10,(30+90*$i),210,$linecolor4);
?? }
?$t1=$t[$i];
?imagestring($im,2,(15+90*$i),212,$t1,$linecolor3);
????? }
??? //標尺線開始(成交量部分)
??? for($i=0;$i????? {
?$ii=290+20*$i;
?$iii=(5-$i)*10;
?imageline($im,30,$ii,570,$ii,$linecolor4);
?imagestring($im,2,5,$ii-5,$iii,$linecolor1);
?imagestring($im,2,575,$ii-5,($iii*10),$linecolor3);
????? }
??? imageline($im,30,290,30,390,$linecolor4);
??? imageline($im,570,290,570,390,$linecolor4);
??? for($i=1;$i????? {
?$ii=30+90*$i;
??????? imagedashedline($im,$ii,290,$ii,390,$linecolor4);
????? }
??? //標尺線結(jié)束
??? //曲線繪制開始
??? $a=file($afile);
??? for($i=0;$i
?$b=explode("\t",$a[$i]);
?$b1=$b[13];
?$b2=$b[14];
?$x=($b2-34100)/10;
?$y=-$b1*0.5+110;
?if($i==0)
?? {
???? $x1=$x;
???? $y1=$y;
?? }
?else
?? {
???? imageline($im,$x,$y,$x1,$y1,$linecolor5);
???? $x1=$x;
???? $y1=$y;
?? }
????? }
??? //成交量繪制開始
??? $sum=0;
??? for($i=0;$i????? {
?$y=390-2*$hu[$i][0];
?$x=($hu[$i][2]-34100)/10;
?imageline($im,$x,390,$x,$y,$linecolor1);
?$sum+=$hu[$i][0];
?$ysum=390-0.2*$sum;
?if($i==0)
?? {
???? $x1=$x;
???? $y1=$ysum;
?? }
?else
?? {
???? imageline($im,$x1,$y1,$x,$y1,$linecolor3);
???? imageline($im,$x,$y1,$x,$ysum,$linecolor3);
???? $x1=$x;
???? $y1=$ysum;
?? }
????? }
??? imageline($im,$x1,$y1,570,$y1,$linecolor3);
??? //結(jié)算價格曲線繪制
??? $sum=0;
??? $allprice=0;
??? for($i=0;$i????? {
?$sum+=$hu[$i][0];
?$allprice+=$hu[$i][1]*$hu[$i][0];
?if($sum==0)$nowprice=0;
?else
?? $nowprice=$allprice/$sum;
??????? $x=($hu[$i][2]-34100)/10;
?$y=-$nowprice*0.5+110;
?if($i==0)
?? {
???? $x1=$x;
???? $y1=$y;
?? }
?else
?? {
???? imageline($im,$x1,$y1,$x,$y1,$linecolor1);
???? imageline($im,$x,$y1,$x,$y,$linecolor1);
???? $x1=$x;
???? $y1=$y;
?? }
????? }
??? imageline($im,$x1,$y1,570,$y1,$linecolor1);
??? //繪制結(jié)束
??? //************圖片解釋部分開始*******************//
??? $str0=iconv("GB2312","UTF-8",$str);
??? $str1=iconv("GB2312","UTF-8","上圖紅線表示結(jié)算價格線,紫線表示價格曲線,下圖紅線表示當時成交量,藍線表示總成交量");
??? imagettftext($im,10,0,30,240,$linecolor1,"D:/winnt/Fonts/simhei.ttf",$str0);
??? imagettftext($im,10,0,30,255,$linecolor1,"D:/winnt/Fonts/simhei.ttf",$str1);
??? //************圖片解釋部分結(jié)束*******************//
??? ImageGif($im);
??? ImageDestroy($im);
? }
else
? {
??? //時間從2005-05-24開始
??? print"";
? }
?>

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using
