Parcourir la source

各种历史指数

wanggangtao il y a 5 ans
Parent
commit
c818764c89

+ 2 - 3
data/get_day_k_base.php

@@ -17,9 +17,8 @@ require('../init.php');
 $date = isset($_GET['date'])?safeCheck($_GET['date'],0):'0';//传入日期
 if(empty($date))//不传日期默认是当天
 {
-    $date = date('Ym',time());//202011
+    $date = date('Ym',time());//202011用于建表
 }
-
 $codeList=Stock::getStockCodeList();//获取所有股票代码
 if (empty($codeList))
 {
@@ -28,6 +27,6 @@ if (empty($codeList))
 //遍历股票代码
 
 foreach($codeList as $key => $val){
-        $code=intval($val["code"]);
+        $code=intval($val);
         Sina::get_day_k_base($code,$date);
 }

data/get_history_trade_data.php → data/get_day_k_history_data.php


+ 13 - 0
data/get_history_index_csi300.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取某天的某个股票的数据
+ */
+require('../init.php');
+$stock_code="399300";
+$start_date=20140101;
+$end_date=date("Ymd",time());
+Finance163::get_history_index_csi300($stock_code,$start_date,$end_date);

+ 14 - 0
data/get_history_index_gem.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取某天的某个股票的数据
+ */
+require('../init.php');
+$stock_code="399006";
+$start_date=20140101;
+$end_date=date("Ymd",time());
+
+Finance163::get_history_index_gem($stock_code,$start_date,$end_date);

+ 16 - 0
data/get_history_index_kc50.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取某天的某个股票的数据
+ */
+require('../init.php');
+
+$stock_code="000688";
+$start_date=20140101;
+$end_date=date("Ymd",time());
+
+
+Finance163::get_history_index_kc50($stock_code,$start_date,$end_date);

+ 14 - 0
data/get_history_index_scz.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取某天的某个股票的数据
+ */
+require('../init.php');
+$stock_code="399001";
+$start_date=20140101;
+$end_date=date("Ymd",time());
+
+Finance163::get_history_index_scz($stock_code,$start_date,$end_date);

+ 14 - 0
data/get_history_index_sh.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取某天的某个股票的数据
+ */
+require('../init.php');
+$stock_code="000001";
+$start_date=20140101;
+$end_date=date("Ymd",time());
+
+Finance163::get_history_index_sh($stock_code,$start_date,$end_date);

+ 14 - 0
data/get_history_index_sh50.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取某天的某个股票的数据
+ */
+require('../init.php');
+$stock_code="000016";
+$start_date=20140101;
+$end_date=date("Ymd",time());
+
+Finance163::get_history_index_sh50($stock_code,$start_date,$end_date);

+ 2 - 3
lib/day_k_base.class.php

@@ -28,8 +28,7 @@ class Day_k_base {
             $date=strtotime(date('Ym'));
         }
         $Table_day_k_base = new Table_day_k_base($date);
-        $id = $Table_day_k_base->add($attrs);
-        return $id;
+        return $Table_day_k_base->add($attrs);
 
     }
 
@@ -51,7 +50,7 @@ class Day_k_base {
         if (empty($attrs)) throw new Exception('参数不能为空', 102);
         if($date===0)
         {
-            $date=strtotime(date('Ym'));
+            $date=strtotime(date('Ymd'));
         }
         $Table_day_k_base = new Table_day_k_base($date);
         $id = $Table_day_k_base->insert($attrs);

+ 244 - 1
lib/finance163.class.php

@@ -23,11 +23,254 @@ class Finance163
         }
         return $stock_code;
     }
+    /****
+     * @param $url
+     * @return array|bool|string
+     * 对curl_setopt进行封装,消除代码冗余
+     */
+    static private function curl_get_data($url){
+        $curlHandle = curl_init();
+        curl_setopt($curlHandle, CURLOPT_URL, $url);
+        curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
+        $content = curl_exec($curlHandle);
+        curl_close($curlHandle);
+        $content1 = explode("\n", $content);//以换行符进行分割字符串
+        return $content1;
+    }
+
+    static public function get_history_index_csi300($stock_code,$start_date,$end_date)
+    {
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $content1=Finance163::curl_get_data($url);
+         if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+//                解析返回的历史数据
+                $data['date'] = strtotime($content3[0]);//用于创建表
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_csi300::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
+
+    static public function get_history_index_gem($stock_code,$start_date,$end_date)
+    {
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $content1=Finance163::curl_get_data($url);
+        if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+//                解析返回的历史数据
+                $data['date'] = strtotime($content3[0]);//用于创建表
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_gem::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
+    static public function get_history_index_kc50($stock_code,$start_date,$end_date)
+    {
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $content1=Finance163::curl_get_data($url);
+        if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+//                解析返回的历史数据
+                $data['date'] = strtotime($content3[0]);//用于创建表
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_kc50::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
+    static public function get_history_index_scz($stock_code,$start_date,$end_date)
+    {
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $content1=Finance163::curl_get_data($url);
+        if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+//                解析返回的历史数据
+                $data['date'] = strtotime($content3[0]);//用于创建表
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_scz::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
+    static public function get_history_index_sh($stock_code,$start_date,$end_date)
+    {
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $content1=Finance163::curl_get_data($url);
+        if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+//                解析返回的历史数据
+                $data['date'] = strtotime($content3[0]);//用于创建表
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_sh::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
+    static public function get_history_index_sh50($stock_code,$start_date,$end_date)
+    {
+        $msg="";
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $content1=Finance163::curl_get_data($url);
+        if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+//                解析返回的历史数据
+                $data['date'] = strtotime($content3[0]);//用于创建表
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_sh50::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
+
 
     /***
      * @param $code
      * @return int
-     * 获取历史交易数据
+     * 获取历史股票交易数据
      */
     static public function get_history_trade_data($stock_code,$start_date,$end_date)
     {

+ 15 - 0
lib/index_csi300.class.php

@@ -32,6 +32,21 @@ class Index_csi300 {
         return $id;
     }
 
+    /***
+     * @param $attrs
+     * @param int $date
+     * @return mixed
+     * @throws Exception
+     *
+     */
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_csi300 = new Table_index_csi300();
+        $id = $Table_index_csi300->insert($attrs);
+        return $id;
+    }
+
     static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
     {
         $Table_index_csi300 = new Table_index_csi300();

+ 59 - 0
lib/index_gem.class.php

@@ -17,6 +17,65 @@ class Index_gem {
         $Table_index_gem = new Table_index_gem();
         return $Table_index_gem->getInfoById($id);
     }
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_gem = new Table_index_gem();
+        $id = $Table_index_gem->insert($attrs);
+        return $id;
+    }
+
+    static public function get_history_index_gem($stock_code,$start_date,$end_date)
+    {
+        $code = self::stock_block($stock_code);
+        $url = "http://quotes.money.163.com/service/chddata.html?code=" . $code . "&start=" . $start_date . "&end=" . $end_date . "&fields=TOPEN;HIGH;LOW;TCLOSE;VATURNOVER;VOTURNOVER;CHG;PCHG";
+        //构建所要发送的url
+        $curlHandle = curl_init();
+        curl_setopt($curlHandle, CURLOPT_URL, $url);
+        curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
+        $content = curl_exec($curlHandle);
+        curl_close($curlHandle);
+        $content1 = explode("\n", $content);//以换行符进行分割字符串
+        if (!empty($content1[1])) {
+            for ($i = count($content1) - 1; $i >0; $i--) {//排除日期,代码等标题栏
+                if (!empty($content1[$i])) {
+                    $content3 = explode(",", iconv("gbk", "utf-8", $content1[$i]));
+                }
+                else{
+                    continue;
+                }
+                var_dump($content3);
+//                解析返回的历史数据
+                $t = explode("-",$content3[0]);
+                $date = trim($t[0].$t[1]);
+                $time = trim($t[0].$t[1].$t[2]);
+
+                $data['date'] = $date;//用于创建表
+                $data['time'] = $time;//用于获取时间戳
+                $data['code'] = intval(explode("'",$content3[1])[1]);
+                $data['open_price'] = floatval($content3[3]);
+                $data['hightest_price'] = floatval($content3[4]);
+                $data['lowest_price'] = floatval($content3[5]);
+                $data['close_price'] = floatval($content3[6]);
+                $data['value'] = floatval($content3[7]);
+                $data['amount'] = floatval($content3[8]);
+                $data['increase_price'] = floatval($content3[9]);
+                $data['increase_value'] = floatval($content3[10]);
+                //将所要存储的数据放入一个数组中
+                $stock_name = $content3[1];
+                if ($data['close_price'] == 0) {//当收盘价为0的时候,表示此时的基于9-3点,所以不存储
+                    continue;
+                }
+                if (!empty($data)) {
+                    $msg= Index_csi300::insert($data);//将这支股票的历史数据存入数据库
+                }
+            }
+        }
+        return $msg;
+    }
 
 
     /***

+ 7 - 1
lib/index_kc50.class.php

@@ -18,7 +18,13 @@ class Index_kc50 {
         return $Table_index_kc50->getInfoById($id);
     }
 
-
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_kc50 = new Table_index_kc50();
+        $id = $Table_index_kc50->insert($attrs);
+        return $id;
+    }
     /**
      * 记录管理员日志
      *

+ 7 - 1
lib/index_scz.class.php

@@ -18,7 +18,13 @@ class Index_scz {
         $Table_index_scz = new Table_index_scz();
         return $Table_index_scz->getInfoById($id);
     }
-
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_scz = new Table_index_scz();
+        $id = $Table_index_scz->insert($attrs);
+        return $id;
+    }
     /****
      * @param $date
      * @return mixed

+ 7 - 1
lib/index_sh.class.php

@@ -12,7 +12,13 @@ class Index_sh {
     {
 
     }
-
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_sh = new Table_index_sh();
+        $id = $Table_index_sh->insert($attrs);
+        return $id;
+    }
     static public function getInfoById($id)
     {
         $Table_index_sh = new Table_index_sh();

+ 7 - 1
lib/index_sh50.class.php

@@ -18,7 +18,13 @@ class Index_sh50 {
         $Table_index_sh50 = new Table_index_sh50();
         return $Table_index_sh50->getInfoById($id);
     }
-
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_sh50 = new Table_index_sh50();
+        $id = $Table_index_sh50->insert($attrs);
+        return $id;
+    }
     /**
      * 记录管理员日志
      *

+ 7 - 12
lib/sina.class.php

@@ -281,13 +281,6 @@ class Sina
      */
     static public function get_day_k_base($code, $date)
     {
-//        $stock_code = $code;
-//        $f = substr($stock_code, 0, 1);
-//        if ($f == "6"  || $f == "0" ) {
-//            $stock_code = "sh" . $code;
-//        } else {
-//            $stock_code = "sz" . $code;
-//        }
         $stock_code= self::get_boniu_block($code);
         $url = "http://hq.sinajs.cn/list=" . $stock_code;
         $content3=sina::curl_get_data($url);//封装为函数,
@@ -295,14 +288,16 @@ class Sina
         {
             throw new Exception('抓取的数据不能为空', 102);
         }
+
         $data['date'] = $content3[30];
         $data['code'] = $code;//股票代码此时去掉sh,sz
-        $data['open_price'] = $content3[1];//开盘价
-        $data['close_price'] = $content3[3];//3点之后的当前价格就是收盘价
-        $data['hightest_price'] = $content3[4];//今日最高价
+        $data['name'] = $content3[0];
+        $data['open_price'] = floatval($content3[1]);//开盘价
+        $data['close_price'] = floatval($content3[3]);//3点之后的当前价格就是收盘价
+        $data['hightest_price'] = floatval($content3[4]);//今日最高价
         $data['lowest_price'] = floatval($content3[5]);//今日最低价
-        $data['amount'] = $content3[8];//成交的股票数,以百为单位
-        $data['value'] = $content3[9];//成交金额以万为单位
+        $data['amount'] = floatval($content3[8]);//成交的股票数,以百为单位
+        $data['value'] = floatval($content3[9]);//成交金额以万为单位
         return Day_k_base::add($data, $date);
     }
 

+ 3 - 4
lib/table/table_day_k_base.class.php

@@ -75,16 +75,15 @@ class Table_day_k_base extends Table {
         $param = array (
              'day_k_date'    => array('number', strtotime($attr['date'])),
              'day_k_code'    => array('number', $attr['code']),
-             'day_k_open_price'    => array('number', $attr['open_price']),
+             'day_k_name'    => array('string', $attr['name']),
+            'day_k_open_price'    => array('number', $attr['open_price']),
              'day_k_close_price'    => array('number', $attr['close_price']),
             'day_k_hightest_price'    => array('number', $attr['hightest_price']),
              'day_k_lowest_price'    => array('number', $attr['lowest_price']),
              'day_k_amount'    => array('number', $attr['amount']),
              'day_k_value'    => array('number', $attr['value']),
         );
-
-        $msg=$this->pdo->sqlinsert($this->table_fullname, $param);
-        return $msg;
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
 
 

+ 18 - 0
lib/table/table_index_csi300.class.php

@@ -44,5 +44,23 @@ class Table_index_csi300 extends Table {
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
 
+
+    public function insert($attr){
+
+        $param = array (
+            'index_csi300_date'    => array('number', $attr['date']),
+            'index_csi300_open_price'    => array('number', $attr['open_price']),
+            'index_csi300_close_price'    => array('number', $attr['close_price']),
+            'index_csi300_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_csi300_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_csi300_increase_value'    => array('number', $attr['increase_value']),
+            'index_csi300_increase_price'    => array('number', $attr['increase_price']),
+            'index_csi300_amount'    => array('number', $attr['amount']),
+            'index_csi300_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+
 }
 ?>

+ 30 - 6
lib/table/table_index_gem.class.php

@@ -29,20 +29,44 @@ class Table_index_gem extends Table {
 		return $attr;
 	}
 
+    /***
+     * @param $attr
+     * @return mixed
+     * 添加当天数据
+     */
     public function add($attr){
         $param = array (
-            'index_gem_date'    => array('number', $attr['date']),
-            'index_gem_open_price'    => array('number', $attr['open_price']),
+            'index_gem_date'           => array('number', $attr['date']),
+            'index_gem_open_price'     => array('number', $attr['open_price']),
             'index_gem_close_price'    => array('number', $attr['close_price']),
-            'index_gem_hightest_price'    => array('number', $attr['hightest_price']),
-            'index_gem_lowest_price'    => array('number', $attr['lowest_price']),
-            'index_gem_increase_value'    => array('number', $attr['increase_value']),
-            'index_gem_increase_price'    => array('number', $attr['increase_price']),
+            'index_gem_hightest_price' => array('number', $attr['hightest_price']),
+            'index_gem_lowest_price'   => array('number', $attr['lowest_price']),
+            'index_gem_increase_value' => array('number', $attr['increase_value']),
+            'index_gem_increase_price' => array('number', $attr['increase_price']),
             'index_gem_amount'    => array('number', $attr['amount']),
             'index_gem_value'    => array('number', $attr['value']),
         );
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
 
+    /***
+     * @param $attr
+     * @return mixed
+     * 插入历史数据
+     */
+    public function insert($attr){
+        $param = array (
+            'index_gem_date'           => array('number', $attr['date']),
+            'index_gem_open_price'     => array('number', $attr['open_price']),
+            'index_gem_close_price'    => array('number', $attr['close_price']),
+            'index_gem_hightest_price' => array('number', $attr['hightest_price']),
+            'index_gem_lowest_price'   => array('number', $attr['lowest_price']),
+            'index_gem_increase_value' => array('number', $attr['increase_value']),
+            'index_gem_increase_price' => array('number', $attr['increase_price']),
+            'index_gem_amount'    => array('number', $attr['amount']),
+            'index_gem_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
 }
 ?>

+ 19 - 1
lib/table/table_index_kc50.class.php

@@ -28,7 +28,25 @@ class Table_index_kc50 extends Table {
         $attr['value']        = 'index_kc50_value';
 		return $attr;
 	}
-
+    /***
+     * @param $attr
+     * @return mixed
+     * 插入历史数据
+     */
+    public function insert($attr){
+        $param = array (
+            'index_kc50_date'    => array('number', $attr['date']),
+            'index_kc50_open_price'    => array('number', $attr['open_price']),
+            'index_kc50_close_price'    => array('number', $attr['close_price']),
+            'index_kc50_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_kc50_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_kc50_increase_value'    => array('number', $attr['increase_value']),
+            'index_kc50_increase_price'    => array('number', $attr['increase_price']),
+            'index_kc50_amount'    => array('number', $attr['amount']),
+            'index_kc50_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
     public function add($attr){
         $param = array (
             'index_kc50_date'    => array('number', $attr['date']),

+ 19 - 1
lib/table/table_index_scz.class.php

@@ -28,7 +28,25 @@ class Table_index_scz extends Table {
         $attr['value']        = 'index_scz_value';
 		return $attr;
 	}
-
+    /***
+     * @param $attr
+     * @return mixed
+     * 插入历史数据
+     */
+    public function insert($attr){
+        $param = array (
+            'index_scz_date'    => array('number', $attr['date']),
+            'index_scz_open_price'    => array('number', $attr['open_price']),
+            'index_scz_close_price'    => array('number', $attr['close_price']),
+            'index_scz_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_scz_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_scz_increase_value'    => array('number', $attr['increase_value']),
+            'index_scz_increase_price'    => array('number', $attr['increase_price']),
+            'index_scz_amount'    => array('number', $attr['amount']),
+            'index_scz_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
     public function add($attr){
         $param = array (
             'index_scz_date'    => array('number', $attr['date']),

+ 19 - 1
lib/table/table_index_sh.class.php

@@ -44,6 +44,24 @@ class Table_index_sh extends Table {
 
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
-
+    /***
+     * @param $attr
+     * @return mixed
+     * 插入历史数据
+     */
+    public function insert($attr){
+        $param = array (
+            'index_sh_date'    => array('number', $attr['date']),
+            'index_sh_open_price'    => array('number', $attr['open_price']),
+            'index_sh_close_price'    => array('number', $attr['close_price']),
+            'index_sh_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_sh_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_sh_increase_value'    => array('number', $attr['increase_value']),
+            'index_sh_increase_price'    => array('number', $attr['increase_price']),
+            'index_sh_amount'    => array('number', $attr['amount']),
+            'index_sh_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
 }
 ?>

+ 19 - 1
lib/table/table_index_sh50.class.php

@@ -28,7 +28,25 @@ class Table_index_sh50 extends Table {
         $attr['value']        = 'index_sh50_value';
 		return $attr;
 	}
-
+    /***
+     * @param $attr
+     * @return mixed
+     * 插入历史数据
+     */
+    public function insert($attr){
+        $param = array (
+            'index_sh50_date'    => array('number', $attr['date']),
+            'index_sh50_open_price'    => array('number', $attr['open_price']),
+            'index_sh50_close_price'    => array('number', $attr['close_price']),
+            'index_sh50_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_sh50_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_sh50_increase_value'    => array('number', $attr['increase_value']),
+            'index_sh50_increase_price'    => array('number', $attr['increase_price']),
+            'index_sh50_amount'    => array('number', $attr['amount']),
+            'index_sh50_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
     public function add($attr){
         $param = array (
             'index_sh50_date'    => array('number', $attr['date']),