lin 6 years ago
parent
commit
e45987354a
1 changed files with 73 additions and 43 deletions
  1. 73 43
      backend/controllers/KdataController.php

+ 73 - 43
backend/controllers/KdataController.php

@@ -123,52 +123,35 @@ class KdataController extends Controller
 
         $data="
  {
-    \"supports_search\": false,
+    \"supports_search\": true,
     \"supports_group_request\": true,
     \"supports_marks\": false,
     \"supports_timescale_marks\": false,
     \"supports_time\": true,
     \"exchanges\": [
         {
-            \"value\": \"\",
-            \"name\": \"All Exchanges\",
-            \"desc\": \"\"
-        },
+            \"value\": \"BTCUSDT\",
+            \"name\": \"BTCUSDT\", 
+            \"desc\": \"BTCUSDT\"
+        } ,
         {
-            \"value\": \"NasdaqNM\",
-            \"name\": \"NasdaqNM\",
-            \"desc\": \"NasdaqNM\"
-        },
-        {
-            \"value\": \"NYSE\",
-            \"name\": \"NYSE\",
-            \"desc\": \"NYSE\"
-        },
-        {
-            \"value\": \"NCM\",
-            \"name\": \"NCM\",
-            \"desc\": \"NCM\"
-        },
-        {
-            \"value\": \"NGM\",
-            \"name\": \"NGM\",
-            \"desc\": \"NGM\"
-        }
+            \"value\": \"BTCUSDT1\",
+            \"name\": \"BTCUSDT1\", 
+            \"desc\": \"BTCUSDT1\"
+        } 
     ],
     \"symbols_types\": [
+        {
+            \"name\": \"stock\",
+            \"value\": \"BTCUSDT\"
+        } ,
         {
             \"name\": \"All types\",
             \"value\": \"\"
-        },
-        {
-            \"name\": \"Stock\",
-            \"value\": \"stock\"
-        },
-        {
-            \"name\": \"Index\",
-            \"value\": \"index\"
-        }
+        } 
     ],
+    
+    \"has_no_volume\": true,
     \"supported_resolutions\":[
     
          
@@ -216,6 +199,39 @@ class KdataController extends Controller
 
 
 
+    /**
+     * Displays homepage.
+     *
+     * @return string
+     */
+    public function actionSearch()
+    {
+
+        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
+        header("Access-Control-Allow-Origin: *");
+        header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
+        header('Access-Control-Allow-Headers:x-requested-with,content-type');
+        $data= "[
+    {
+        \"symbol\": \"BTCUSDT\",
+        \"full_name\": \"BTCUSDT\",
+        \"description\": \"BTCUSDT Inc.\",
+        \"exchange\": \"BTCUSDT\",
+        \"type\": \"stock\"
+    },
+    {
+        \"symbol\": \"BTCUSDT1\",
+        \"full_name\": \"BTCUSDT1\",
+        \"description\": \"BTCUSDT1 Inc.\",
+        \"exchange\": \"BTCUSDT1\",
+        \"type\": \"stock\"
+    }
+]";
+
+          echo ($data);
+    }
+
+
 
 
     /**
@@ -233,10 +249,12 @@ class KdataController extends Controller
         header('Access-Control-Allow-Headers:x-requested-with,content-type');
         $data= "{
     \"symbol\": [
-        \"BTCUSDT\"              
+        \"BTCUSDT\",
+        \"BTCUSDT1\"             
     ],
     \"description\": [
-        \"BTCUSDT\"              
+        \"BTCUSDT\"  ,
+        \"BTCUSDT1\"             
     ],
     \"exchange-listed\": \"中国第一股\",
     \"exchange-traded\": \"快速交易\",
@@ -245,10 +263,10 @@ class KdataController extends Controller
     \"pricescale\": [
         1                        
     ], 
-    \"has-intraday\": true,
-    \"has_no_volume\": [
-        true  
-    ], 
+    \"has-intraday\": true, 
+    
+    \"has_no_volume\": true,
+    
     \"has_weekly_and_monthly\": true,
     
     \"has_seconds\": true,
@@ -258,6 +276,16 @@ class KdataController extends Controller
     \"intraday_multipliers\": [
         1                       
     ],
+    \"volume_precision\": [
+        3                       
+    ],
+    
+    
+    
+    
+    
+    
+    
     \"supported_resolutions\": [
     
          \"1\",
@@ -288,9 +316,10 @@ class KdataController extends Controller
         \"stock\"                 
     ],
     \"ticker\": [
-        \"BTCUSDT\"             
+        \"BTCUSDT\", 
+        \"BTCUSDT1\"                
     ],
-    \"timezone\": \"UTC\",
+    \"timezone\": \"America/New_York\",
     \"session-regular\": \"0900-1600\"
 }";
         echo ($data);
@@ -381,7 +410,7 @@ class KdataController extends Controller
     \"pointvalue\": 1,
     \"session\": \"0930-1630\",
     \"has_intraday\": true,
-    \"has_no_volume\": false,
+    \"has_no_volume\": true,
     
     \"has_seconds\": true,
     
@@ -413,6 +442,7 @@ class KdataController extends Controller
 
 
 
+
         echo ($data);
     }
 
@@ -516,7 +546,7 @@ class KdataController extends Controller
 
         $level = $rmap[$params['resolution']];
         $url='http://59.110.169.112:89/kdata/';
-      $data = file_get_contents($url."history?symbol=BTCUSDT&period={$level}&from={$params['from']}&to={$params['to']}");
+      $data = file_get_contents($url."history?symbol={$params['symbol']}&period={$level}&from={$params['from']}&to={$params['to']}");
         //   $data = file_get_contents($url."history?symbol=BTCUSDT&period=m1&from=1493796539&to=1493796540");
 //        $a=rand(1,9);
 //        if($a > 6){