123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 |
- <?php
- namespace backend\controllers;
- use Yii;
- use yii\web\Controller;
- use yii\filters\VerbFilter;
- use yii\filters\AccessControl;
- use common\models\LoginForm;
- /**
- * Site controller
- */
- class KdataController extends Controller
- {
- // /**
- // * @inheritdoc
- // */
- // public function behaviors()
- // {
- // return [
- // 'access' => [
- // 'class' => AccessControl::className(),
- // 'rules' => [
- // [
- // 'actions' => ['login', 'error', 'index','testcreatequeue'],
- // 'allow' => true,
- // ],
- // [
- // 'actions' => ['logout'],
- // 'allow' => true,
- // 'roles' => ['@'],
- // ],
- // ],
- // ],
- // 'verbs' => [
- // 'class' => VerbFilter::className(),
- // 'actions' => [
- // 'logout' => ['post'],
- // ],
- // ],
- // ];
- // }
- /**
- * @inheritdoc
- */
- public function actions()
- {
- return [
- 'error' => [
- 'class' => 'yii\web\ErrorAction',
- ],
- ];
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionIndex()
- {
- \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= "{\"id\":[0,1,2,3,4,5],\"time\":[1524787200,1524441600,1524182400,1524182400,1523491200,1522195200],\"color\":[\"red\",\"blue\",\"green\",\"red\",\"blue\",\"green\"],\"text\":[\"Today\",\"4 days back\",\"7 days back + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\",\"7 days back once again\",\"15 days back\",\"30 days back\"],\"label\":[\"A\",\"B\",\"CORE\",\"D\",\"EURO\",\"F\"],\"labelFontColor\":[\"white\",\"white\",\"red\",\"#FFFFFF\",\"white\",\"#000\"],\"minSize\":[14,28,7,40,7,14]}";
- echo ($data);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionConfig()
- {
- \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= "{\"supports_search\":false,\"supports_group_request\":true,
- \"supports_marks\":false,\"supports_timescale_marks\":false,\"supports_time\":false,
- \"exchanges\":[{\"value\":\"\",\"name\":\"All Exchanges\",\"desc\":\"\"},{\"value\":\"NasdaqNM\",\"name\":\"NasdaqNM\",\"desc\":\"NasdaqNM\"},{\"value\":\"NYSE\",\"name\":\"NYSE\",\"desc\":\"NYSE\"},{\"value\":\"NCM\",\"name\":\"NCM\",\"desc\":\"NCM\"},{\"value\":\"NGM\",\"name\":\"NGM\",\"desc\":\"NGM\"}],\"symbols_types\":[{\"name\":\"All types\",\"value\":\"\"},{\"name\":\"Stock\",\"value\":\"stock\"},{\"name\":\"Index\",\"value\":\"index\"}],\"supported_resolutions\":[\"D\",\"2D\",\"3D\",\"W\",\"3W\",\"M\",\"6M\"]}";
- // $data="
- //{
- // \"supports_search\": false,
- // \"supports_group_request\": true,
- // \"supports_marks\": false,
- // \"supports_timescale_marks\": false,
- // \"supports_time\": false,
- // \"exchanges\": [
- // {
- // \"value\": \"中国第一股票\",
- // \"name\": \"All Exchanges\",
- // \"desc\": \"中国第一股票\"
- // }
- // ],
- // \"symbols_types\": [
- // {
- // \"name\": \"All types\",
- // \"value\": \"\"
- // }
- // ],
- // \"supported_resolutions\": [
- // \"D\",
- // \"2D\",
- // \"6M\"
- // ]
- //}";
- $data="
- {
- \"supports_search\": true,
- \"supports_group_request\": true,
- \"supports_marks\": false,
- \"supports_timescale_marks\": false,
- \"supports_time\": true,
- \"exchanges\": [
- {
- \"value\": \"BTCUSDT\",
- \"name\": \"BTCUSDT\",
- \"desc\": \"BTCUSDT\"
- } ,
- {
- \"value\": \"BTCUSDT1\",
- \"name\": \"BTCUSDT1\",
- \"desc\": \"BTCUSDT1\"
- }
- ],
- \"symbols_types\": [
- {
- \"name\": \"stock\",
- \"value\": \"BTCUSDT\"
- } ,
- {
- \"name\": \"All types\",
- \"value\": \"\"
- }
- ],
-
- \"has_no_volume\": true,
- \"supported_resolutions\":[
-
-
- \"1\",
- \"3\",
- \"5\",
- \"15\",
- \"30\",
- \"60\",
- \"120\",
- \"240\",
- \"360\",
- \"720\",
- \"D\",
- \"3D\",
- \"5D\",
- \"7D\",
- \"15D\",
- \"M\"
- ]
- }";
- echo ($data);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionMarks()
- {
- \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= "{\"id\":[0,1,2,3,4,5],\"time\":[1524787200,1524441600,1524182400,1524182400,1523491200,1522195200],\"color\":[\"red\",\"blue\",\"green\",\"red\",\"blue\",\"green\"],\"text\":[\"Today\",\"4 days back\",\"7 days back + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\",\"7 days back once again\",\"15 days back\",\"30 days back\"],\"label\":[\"A\",\"B\",\"CORE\",\"D\",\"EURO\",\"F\"],\"labelFontColor\":[\"white\",\"white\",\"red\",\"#FFFFFF\",\"white\",\"#000\"],\"minSize\":[14,28,7,40,7,14]}";
- echo ($data);
- }
- /**
- * 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);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionSymbol_info()
- {
- \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\",
- \"BTCUSDT1\"
- ],
- \"description\": [
- \"BTCUSDT\" ,
- \"BTCUSDT1\"
- ],
- \"exchange-listed\": \"中国第一股\",
- \"exchange-traded\": \"快速交易\",
- \"minmov\": 1,
- \"minmov2\": 0,
- \"pricescale\": [
- 1
- ],
- \"has-intraday\": true,
-
- \"has_no_volume\": true,
-
- \"has_weekly_and_monthly\": true,
-
- \"has_seconds\": true,
- \"has_daily\": true,
-
-
- \"intraday_multipliers\": [
- 1
- ],
- \"volume_precision\": [
- 3
- ],
-
-
-
-
-
-
-
- \"supported_resolutions\": [
-
- \"1\",
- \"3\",
- \"5\",
- \"15\",
- \"30\",
- \"60\",
- \"120\",
- \"240\",
- \"360\",
- \"720\",
- \"D\",
- \"3D\",
- \"5D\",
- \"7D\",
- \"15D\",
- \"M\"
- ],
-
-
-
-
-
-
-
- \"type\": [
- \"stock\"
- ],
- \"ticker\": [
- \"BTCUSDT\",
- \"BTCUSDT1\"
- ],
- \"timezone\": \"America/New_York\",
- \"session-regular\": \"0900-1600\"
- }";
- echo ($data);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionSymbols()
- {
- \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= "{\"name\":\"AAPL\",\"exchange-traded\":\"NasdaqNM\",\"exchange-listed\":\"NasdaqNM\",\"timezone\":\"America/New_York\",\"minmov\":1,\"minmov2\":0,\"pointvalue\":1,\"session\":\"0930-1630\",\"has_intraday\":false,\"has_no_volume\":false,\"description\":\"Apple Inc.\",\"type\":\"stock\",\"supported_resolutions\":[\"D\",\"2D\",\"3D\",\"W\",\"3W\",\"M\",\"6M\"],\"pricescale\":100,\"ticker\":\"AAPL\"}";
- // $data= "{
- // \"symbol\": [
- // \"BTCUSDT\"
- // ],
- // \"description\": [
- // \"BTCUSDT\"
- // ],
- // \"exchange-listed\": \"中国第一股\",
- // \"exchange-traded\": \"快速交易\",
- // \"minmov\": 1,
- // \"minmov2\": 0,
- // \"pricescale\": [
- // 1
- // ],
- // \"has-intraday\": true,
- // \"has_no_volume\": [
- // true
- // ],
- // \"has_weekly_and_monthly\": true,
- //
- // \"has_seconds\": true,
- // \"has_daily\": true,
- //
- //
- // \"intraday_multipliers\": [
- // 1
- // ],
- // \"supported_resolutions\": [
- // \"60\",
- // \"2D\",
- // \"3D\",
- // \"W\",
- // \"3W\",
- // \"M\",
- // \"6M\"
- // ],
- //
- //
- //
- //
- //
- //
- //
- // \"type\": [
- // \"stock\"
- // ],
- // \"ticker\": [
- // \"BTCUSDT\"
- // ],
- // \"timezone\": \"UTC\",
- // \"session-regular\": \"0900-1600\"
- //}";
- $data="{
- \"name\": \"BTCUSDT\",
- \"exchange-traded\": \"BTCUSDT\",
- \"exchange-listed\": \"BTCUSDT\",
- \"timezone\": \"America/New_York\",
- \"minmov\": 1,
- \"minmov2\": 0,
- \"pointvalue\": 1,
- \"session\": \"0930-1630\",
- \"has_intraday\": true,
- \"has_no_volume\": true,
-
- \"has_seconds\": true,
-
-
- \"description\": \"BTCUSDT\",
- \"type\": \"stock\",
- \"supported_resolutions\": [
- \"1\",
- \"3\",
- \"5\",
- \"15\",
- \"30\",
- \"60\",
- \"120\",
- \"240\",
- \"360\",
- \"720\",
- \"D\",
- \"3D\",
- \"5D\",
- \"7D\",
- \"15D\",
- \"M\"
- ],
- \"pricescale\": 100,
- \"ticker\": \"BTCUSDT\"
- }";
- echo ($data);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionTime()
- {
- \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= "1524713662";
- echo ($data);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionTimescale_marks()
- {
- \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= "{\"name\":\"AAPL\",\"exchange-traded\":\"NasdaqNM\",\"exchange-listed\":\"NasdaqNM\",\"timezone\":\"America/New_York\",\"minmov\":1,\"minmov2\":0,\"pointvalue\":1,\"session\":\"0930-1630\",\"has_intraday\":false,\"has_no_volume\":false,\"description\":\"Apple Inc.\",\"type\":\"stock\",\"supported_resolutions\":[\"D\",\"2D\",\"3D\",\"W\",\"3W\",\"M\",\"6M\"],\"pricescale\":100,\"ticker\":\"AAPL\"}";
- $data= "{
- \"symbol\": [
- \"BTCUSDT\"
- ],
- \"description\": [
- \"BTCUSDT\"
- ],
- \"exchange-listed\": \"中国第一股\",
- \"exchange-traded\": \"快速交易\",
- \"minmov\": 1,
- \"minmov2\": 0,
- \"pricescale\": [
- 1
- ],
- \"has_intraday\": true,
- \"has_weekly_and_monthly\": true,
-
- \"type\": [
- \"stock\"
- ],
- \"ticker\": [
- \"BTCUSDT\"
- ],
- \"timezone\": \"UTC\",
- \"session-regular\": \"0900-1600\"
- }";
- echo ($data);
- }
- /**
- * Displays homepage.
- *
- * @return string
- */
- public function actionHistory()
- {
- 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');
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- // $params = Yii::$app->getRequest()->params;
- $params=Yii::$app->request->get();//获取参数
- $rmap = array(
- '1'=>'m1',
- '3'=>'m3',
- '5'=>'m5',
- '15'=>'m15',
- '30'=>'m30',
- '60'=>'h1',
- '120'=>'h2',
- '240'=>'h4',
- '360'=>'h6',
- '720'=>'h12',
- 'D'=>'d1',
- '3D'=>'d3',
- '5D'=>'d5',
- '7D'=>'d7',
- '15D'=>'d15',
- 'M'=>'mo'
- );
- $level = $rmap[$params['resolution']];
- $url='http://59.110.169.112:89/kdata/';
- $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){
- ////
- //// 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= "{\"t\":[1492041600,1492387200,1492473600,1492560000,1492646400,1492732800,1492992000,1493078400],\"o\":[141.91,141.48,141.41,141.88,141.22,142.44,143.5,143.91],\"h\":[142.38,141.88,142.04,142,142.92,142.68,143.95,144.9],\"l\":[141.05,140.87,141.11,140.45,141.16,141.85,143.18,143.87],\"c\":[141.05,141.83,141.2,140.68,142.44,142.27,143.64,144.54],\"v\":[17822880,16582094,14697544,17328375,23319562,17320928,17116599,18216472],\"s\":\"ok\"}";
- ////
- // $url='http://59.110.169.112:89/kdata/';
- // $data = file_put_contents($url."history?symbol={$params['symbol']}&period={$params['resolution']}&from={$params['from']}&to={$params['to']}");
- //
- //
- //
- //
- //
- //
- //// }else{
- //
- //// $data="{\"s\":\"no_data\",\"nextTime\":1522108800}";
- //
- //// }
- echo ($data);
- }
- }
|