diff --git a/app/Models/DataCxib.php b/app/Models/DataAeef.php similarity index 97% rename from app/Models/DataCxib.php rename to app/Models/DataAeef.php index d4c9f24..c10595b 100644 --- a/app/Models/DataCxib.php +++ b/app/Models/DataAeef.php @@ -12,17 +12,17 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class DataCxib extends Model +class DataAeef extends Model { protected $primaryKey = 'id'; - protected $table = 'data_cxib'; + protected $table = 'data_aeef'; protected $guarded = []; public $timestamps = false; public $attributes = [ 'pid' => 0, - 'Symbol' => 'CXIB', - 'Name' => 'CXIB', + 'Symbol' => 'AEEF', + 'Name' => 'AEEF', 'Price2' => 0, 'Price3' => 0, 'Open_Int' => 0, diff --git a/app/Models/DataEodc.php b/app/Models/DataEodc.php deleted file mode 100644 index 91b6a88..0000000 --- a/app/Models/DataEodc.php +++ /dev/null @@ -1,124 +0,0 @@ - 0, - 'Symbol' => 'EODC', - 'Name' => 'EODC', - 'Price2' => 0, - 'Price3' => 0, - 'Open_Int' => 0, - 'is_1min' => 0, - 'is_5min' => 0, - 'is_15min' => 0, - 'is_30min' => 0, - 'is_1h' => 0, - 'is_2h' => 0, - 'is_4h' => 0, - 'is_6h' => 0, - 'is_12h' => 0, - 'is_day' => 0, - 'is_week' => 0, - 'is_month' => 0, - ]; - - public static function getKlineData($symbol, $period, $size) - { - $builder = self::query(); - $wheres = [ - '1min' => 'is_1min', - '5min' => 'is_5min', - '15min' => 'is_15min', - '30min' => 'is_30min', - '60min' => 'is_1h', - '4hour' => 'is_4hour', - '1day' => 'is_day', - '1week' => 'is_week', - '1mon' => 'is_month', - ]; - $where = $wheres[$period] ?? 'is_1min'; - $builder->where($where, 1); - - $data = $builder->where('Date', '<', time())->limit($size)->orderByDesc('Date')->get(); - if (blank($data)) return []; - $data = $data->sortBy('Date')->values()->map(function ($kline) { - $item = [ - "id" => $kline['Date'], - "amount" => $kline['Amount'], - "count" => $kline['Amount'], - "open" => $kline['Open'], - "close" => $kline['Close'], - "low" => $kline['Low'], - "high" => $kline['High'], - "vol" => $kline['Volume'] - ]; - $item['price'] = $item['close']; - return $item; - })->toArray(); - // 重设数组最后一组数据的值 - $time = time(); - $data = self::getlastData($data, $period, $time); - return $data; - } - /** - * @description: 获取最新5分钟线 十五分钟线 30分钟线 1小时线 4小时线 1天线 1周线 一月线 - * @param {*} - * @return {*} - */ - public static function getlastData($data, $period, $time) - { - $periodMap = [ - '1min' => ['column' => 'is_1min', 'seconds' => 60], - '5min' => ['column' => 'is_5min', 'seconds' => 300], - '15min' => ['column' => 'is_15min', 'seconds' => 900], - '30min' => ['column' => 'is_30min', 'seconds' => 1800], - '60min' => ['column' => 'is_1h', 'seconds' => 3600], - '4hour' => ['column' => 'is_4hour', 'seconds' => 14400], - '1day' => ['column' => 'is_day', 'seconds' => 86400], - '1week' => ['column' => 'is_week', 'seconds' => 604800], - '1mon' => ['column' => 'is_month', 'seconds' => 2592000], - ]; - $tmp = $data[array_key_last($data)]; - if ($period == '1mon') { - $res = self::query() - ->whereBetween('Date', [\Carbon\Carbon::now()->firstOfMonth()->timestamp, $time]) - ->where('is_1min', 1) - ->get(); - } else { - $res = self::query() - ->whereBetween('Date', [$time - $time % $periodMap[$period]['seconds'], $time]) - ->where('is_1min', 1) - ->get(); - } - $data[array_key_last($data)] = [ - "id" => $tmp['id'], - "amount" => $res->sum('Amount'), - "count" => $res->sum('Amount'), - "open" => $res->first()->Open, - "close" => $res->last()->Close, //最新价 - "low" => $res->min('Low'), - "high" => $res->max('High'), - "vol" => $res->sum('Volume'), - "price" => $res->last()->Close - ]; - return $data; - } -} diff --git a/app/Models/DataGlpe.php b/app/Models/DataGlpe.php deleted file mode 100644 index 808435e..0000000 --- a/app/Models/DataGlpe.php +++ /dev/null @@ -1,124 +0,0 @@ - 0, - 'Symbol' => 'GLPE', - 'Name' => 'GLPE', - 'Price2' => 0, - 'Price3' => 0, - 'Open_Int' => 0, - 'is_1min' => 0, - 'is_5min' => 0, - 'is_15min' => 0, - 'is_30min' => 0, - 'is_1h' => 0, - 'is_2h' => 0, - 'is_4h' => 0, - 'is_6h' => 0, - 'is_12h' => 0, - 'is_day' => 0, - 'is_week' => 0, - 'is_month' => 0, - ]; - - public static function getKlineData($symbol, $period, $size) - { - $builder = self::query(); - $wheres = [ - '1min' => 'is_1min', - '5min' => 'is_5min', - '15min' => 'is_15min', - '30min' => 'is_30min', - '60min' => 'is_1h', - '4hour' => 'is_4hour', - '1day' => 'is_day', - '1week' => 'is_week', - '1mon' => 'is_month', - ]; - $where = $wheres[$period] ?? 'is_1min'; - $builder->where($where, 1); - - $data = $builder->where('Date', '<', time())->limit($size)->orderByDesc('Date')->get(); - if (blank($data)) return []; - $data = $data->sortBy('Date')->values()->map(function ($kline) { - $item = [ - "id" => $kline['Date'], - "amount" => $kline['Amount'], - "count" => $kline['Amount'], - "open" => $kline['Open'], - "close" => $kline['Close'], - "low" => $kline['Low'], - "high" => $kline['High'], - "vol" => $kline['Volume'] - ]; - $item['price'] = $item['close']; - return $item; - })->toArray(); - // 重设数组最后一组数据的值 - $time = time(); - $data = self::getlastData($data, $period, $time); - return $data; - } - /** - * @description: 获取最新5分钟线 十五分钟线 30分钟线 1小时线 4小时线 1天线 1周线 一月线 - * @param {*} - * @return {*} - */ - public static function getlastData($data, $period, $time) - { - $periodMap = [ - '1min' => ['column' => 'is_1min', 'seconds' => 60], - '5min' => ['column' => 'is_5min', 'seconds' => 300], - '15min' => ['column' => 'is_15min', 'seconds' => 900], - '30min' => ['column' => 'is_30min', 'seconds' => 1800], - '60min' => ['column' => 'is_1h', 'seconds' => 3600], - '4hour' => ['column' => 'is_4hour', 'seconds' => 14400], - '1day' => ['column' => 'is_day', 'seconds' => 86400], - '1week' => ['column' => 'is_week', 'seconds' => 604800], - '1mon' => ['column' => 'is_month', 'seconds' => 2592000], - ]; - $tmp = $data[array_key_last($data)]; - if ($period == '1mon') { - $res = self::query() - ->whereBetween('Date', [\Carbon\Carbon::now()->firstOfMonth()->timestamp, $time]) - ->where('is_1min', 1) - ->get(); - } else { - $res = self::query() - ->whereBetween('Date', [$time - $time % $periodMap[$period]['seconds'], $time]) - ->where('is_1min', 1) - ->get(); - } - $data[array_key_last($data)] = [ - "id" => $tmp['id'], - "amount" => $res->sum('Amount'), - "count" => $res->sum('Amount'), - "open" => $res->first()->Open, - "close" => $res->last()->Close, //最新价 - "low" => $res->min('Low'), - "high" => $res->max('High'), - "vol" => $res->sum('Volume'), - "price" => $res->last()->Close - ]; - return $data; - } -} diff --git a/app/Models/DataBtu.php b/app/Models/DataKye.php similarity index 100% rename from app/Models/DataBtu.php rename to app/Models/DataKye.php diff --git a/app/Models/DataTzw.php b/app/Models/DataMpdb.php similarity index 100% rename from app/Models/DataTzw.php rename to app/Models/DataMpdb.php diff --git a/app/Models/DataMpgb.php b/app/Models/DataMpob.php similarity index 100% rename from app/Models/DataMpgb.php rename to app/Models/DataMpob.php diff --git a/app/Models/DataUin.php b/app/Models/DataRute.php similarity index 100% rename from app/Models/DataUin.php rename to app/Models/DataRute.php diff --git a/app/Models/DataTobr.php b/app/Models/DataRvm.php similarity index 100% rename from app/Models/DataTobr.php rename to app/Models/DataRvm.php diff --git a/app/Models/DataMgc.php b/app/Models/DataShip.php similarity index 100% rename from app/Models/DataMgc.php rename to app/Models/DataShip.php diff --git a/app/Models/DataUnq.php b/app/Models/DataTomb.php similarity index 100% rename from app/Models/DataUnq.php rename to app/Models/DataTomb.php diff --git a/app/Models/DataYert.php b/app/Models/DataYert.php deleted file mode 100644 index e961640..0000000 --- a/app/Models/DataYert.php +++ /dev/null @@ -1,124 +0,0 @@ - 0, - 'Symbol' => 'YERT', - 'Name' => 'YERT', - 'Price2' => 0, - 'Price3' => 0, - 'Open_Int' => 0, - 'is_1min' => 0, - 'is_5min' => 0, - 'is_15min' => 0, - 'is_30min' => 0, - 'is_1h' => 0, - 'is_2h' => 0, - 'is_4h' => 0, - 'is_6h' => 0, - 'is_12h' => 0, - 'is_day' => 0, - 'is_week' => 0, - 'is_month' => 0, - ]; - - public static function getKlineData($symbol, $period, $size) - { - $builder = self::query(); - $wheres = [ - '1min' => 'is_1min', - '5min' => 'is_5min', - '15min' => 'is_15min', - '30min' => 'is_30min', - '60min' => 'is_1h', - '4hour' => 'is_4hour', - '1day' => 'is_day', - '1week' => 'is_week', - '1mon' => 'is_month', - ]; - $where = $wheres[$period] ?? 'is_1min'; - $builder->where($where, 1); - - $data = $builder->where('Date', '<', time())->limit($size)->orderByDesc('Date')->get(); - if (blank($data)) return []; - $data = $data->sortBy('Date')->values()->map(function ($kline) { - $item = [ - "id" => $kline['Date'], - "amount" => $kline['Amount'], - "count" => $kline['Amount'], - "open" => $kline['Open'], - "close" => $kline['Close'], - "low" => $kline['Low'], - "high" => $kline['High'], - "vol" => $kline['Volume'] - ]; - $item['price'] = $item['close']; - return $item; - })->toArray(); - // 重设数组最后一组数据的值 - $time = time(); - $data = self::getlastData($data, $period, $time); - return $data; - } - /** - * @description: 获取最新5分钟线 十五分钟线 30分钟线 1小时线 4小时线 1天线 1周线 一月线 - * @param {*} - * @return {*} - */ - public static function getlastData($data, $period, $time) - { - $periodMap = [ - '1min' => ['column' => 'is_1min', 'seconds' => 60], - '5min' => ['column' => 'is_5min', 'seconds' => 300], - '15min' => ['column' => 'is_15min', 'seconds' => 900], - '30min' => ['column' => 'is_30min', 'seconds' => 1800], - '60min' => ['column' => 'is_1h', 'seconds' => 3600], - '4hour' => ['column' => 'is_4hour', 'seconds' => 14400], - '1day' => ['column' => 'is_day', 'seconds' => 86400], - '1week' => ['column' => 'is_week', 'seconds' => 604800], - '1mon' => ['column' => 'is_month', 'seconds' => 2592000], - ]; - $tmp = $data[array_key_last($data)]; - if ($period == '1mon') { - $res = self::query() - ->whereBetween('Date', [\Carbon\Carbon::now()->firstOfMonth()->timestamp, $time]) - ->where('is_1min', 1) - ->get(); - } else { - $res = self::query() - ->whereBetween('Date', [$time - $time % $periodMap[$period]['seconds'], $time]) - ->where('is_1min', 1) - ->get(); - } - $data[array_key_last($data)] = [ - "id" => $tmp['id'], - "amount" => $res->sum('Amount'), - "count" => $res->sum('Amount'), - "open" => $res->first()->Open, - "close" => $res->last()->Close, //最新价 - "low" => $res->min('Low'), - "high" => $res->max('High'), - "vol" => $res->sum('Volume'), - "price" => $res->last()->Close - ]; - return $data; - } -}