chenbo hace 4 años
padre
commit
ba1ea25722

+ 1 - 1
lib/index.class.php

@@ -40,6 +40,6 @@ class Index {
         $id = $Table_index->addOrUpdateByCode($attrs);
         return $id;
     }
-    
+
 }
 ?>

+ 47 - 0
lib/input_sina_simple.class.php

@@ -101,6 +101,53 @@ class Input_sina_simple
         return;
     }
 
+    //获取指定条件的股票代码和名称列表
+    static public function getAllIndexCodeAndNameList()
+    {
+        $i = 0;
+        $index[$i]['code']     = '000001';
+        $index[$i]['name']     = '上证指数';
+        $index[$i]['exchange'] = 'sh';
+        $index[$i]['sector']   = 10;
+
+        $i++;
+        $index[$i]['code']     = '399001';
+        $index[$i]['name']     = '深成指数';
+        $index[$i]['exchange'] = 'sz';
+        $index[$i]['sector']   = 20;
+
+        $i++;
+        $index[$i]['code']     = '000016';
+        $index[$i]['name']     = '上证50指数';
+        $index[$i]['exchange'] = 'sh';
+        $index[$i]['sector']   = 10;
+
+        $i++;
+        $index[$i]['code']     = '399300';
+        $index[$i]['name']     = '沪深300';
+        $index[$i]['exchange'] = 'sz';
+        $index[$i]['sector']   = 20;
+
+        $i++;
+        $index[$i]['code']     = '399006';
+        $index[$i]['name']     = '创业板指数';
+        $index[$i]['exchange'] = 'sz';
+        $index[$i]['sector']   = 22;
+
+        $i++;
+        $index[$i]['code']     = '000688';
+        $index[$i]['name']     = '科创50指数';
+        $index[$i]['exchange'] = 'sh';
+        $index[$i]['sector']   = 11;
+
+        foreach ($index as $key => $item) {
+            if (!empty($item['code'])) {                            //判断非法股票代码
+                Index::addOrUpdateByCode($item['code']);
+            }
+        }
+        return;
+    }
+
 }
 
 ?>

+ 13 - 0
task/task_get_all_index_code_name.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 陈波
+ * Date: 2020/11/24
+ * Time: 19:16
+ * 获取所有个股的Code和Name,入库 
+ */
+require('../init.php');
+
+Input_sina_simple::getAllIndexCodeAndNameList();
+
+?>

+ 10 - 0
task/task_get_all_index_code_name.sh

@@ -0,0 +1,10 @@
+#!/bin/sh
+
+cd /home/wwwroot/default/boniu/task
+echo '正在获取所有指数代码和名称...'
+nohup php ./task_get_all_index_code_name.php &
+sleep 1s
+echo "完成!"
+
+sleep 1s
+