/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $issues = Issue::all();
     $checkIssueList = array();
     foreach ($issues as $issue) {
         $stockPricelInfos = $issue->stockPricelInfos()->where('average_75days', '!=', 0)->orderBy('acquire_at', 'DESC')->take($this->numberOfVectors)->get();
         if (count($stockPricelInfos) < 2) {
             continue;
         }
         $vectors = array();
         $i = 0;
         foreach ($stockPricelInfos as $stockPricelInfo) {
             $vectors[] = ['x' => count($stockPricelInfos) - $i, 'y' => $stockPricelInfo->average_75days];
             $i++;
         }
         $cls = new CalcLeastSquare($vectors);
         $stockPricelInfos[0]->gradient_75days = $cls->getGradient();
         $stockPricelInfos[0]->save();
         if ($stockPricelInfos[1]->gradient_75days < 0 && $stockPricelInfos[0]->gradient_75days >= 0) {
             $issue->price_up_to_date = $stockPricelInfos[0]->opening_price;
             $checkIssueList[] = $issue;
         }
     }
     if (!count($checkIssueList)) {
         return;
     }
     $mailBody = "";
     foreach ($checkIssueList as $issue) {
         $mailBody .= $issue->code . " " . $issue->name . " ¥" . number_format($issue->unit * $issue->price_up_to_date) . ' http://stocks.finance.yahoo.co.jp/stocks/chart/?code=' . $issue->code . "&ct=z&t=1y&q=c&l=off&z=m&p=s,m75,m25&a=v\n";
     }
     mb_send_mail($this->mailTo, '75日トレンド転換面柄', $mailBody);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $issues = Issue::all();
     return view('issue.index', compact('issues'));
 }
Ejemplo n.º 3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('layouts.issues.issues')->withIssues(Issue::all());
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $today = date('Y-m-d');
     $yesterday = date('Y-m-d', strtotime((date('N') == 1 ? '-3' : '-1') . ' day'));
     $issues = Issue::all();
     foreach ($issues as $issue) {
         $stockPriceInfoToday = new StockPriceInfo();
         $stockPriceInfoToday->acquire_at = $today;
         $stockPriceInfoYesterday = StockPriceInfo::where('issue_id', $issue->id)->where('acquire_at', $yesterday)->first();
         if (!$stockPriceInfoYesterday) {
             $stockPriceInfoYesterday = new StockPriceInfo();
             $stockPriceInfoYesterday->acquire_at = $yesterday;
         }
         $html = $this->getHtmlContent($this->getUrl($issue->code));
         $ret = preg_match_all('#<dl.*?</dl>#ms', $html, $matches);
         foreach ($matches[0] as $element) {
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">単元株数#ms', $element, $matchesTemp)) {
                 $issue->unit = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">前日終値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoYesterday->closing_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">始値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->opening_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">高値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->high_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">安値#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->low_price = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">出来高#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->traded_volume = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">発行済株式数#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->number_of_stocks = intval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>([^<]+)</strong>.*<dt class="title">配当利回り#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->dividend_yield = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<a[^>]+?>([^<]+)</a>.*1株配当#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->dividend_per_stock = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>.*?([^<()]+)</strong>.*<dt class="title">PER#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->per = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<strong>.*?([^<()]+)</strong>.*<dt class="title">PBR#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->pbr = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<a[^>]+?>.*?([^<()]+)</a>.*EPS#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->eps = floatval(str_replace(',', '', $matchesTemp[1]));
             }
             if (preg_match('#<a[^>]+?>.*?([^<()]+)</a>.*BPS#ms', $element, $matchesTemp)) {
                 $stockPriceInfoToday->bps = floatval(str_replace(',', '', $matchesTemp[1]));
             }
         }
         if ($issue->getOriginal() != $issue->getAttributes()) {
             $issue->save();
         }
         $issue->stockPricelInfos()->save($stockPriceInfoToday);
         $issue->stockPricelInfos()->save($stockPriceInfoYesterday);
     }
 }
Ejemplo n.º 5
0
 public function generate()
 {
     ini_set("max_execution_time", 0);
     if (Auth::user()->role == "Project Manager") {
         $activities = Activity::whereIn('action', array('Created', 'Deleted', 'Updated'))->where(function ($query) {
             return $query->where('action', '!=', 'Created')->orWhere('type', '!=', 'Deliverable');
         })->where('user_id', Auth::user()->id)->get();
         $projects = Project::where('user_id', Auth::user()->id)->get();
         $projectids = array_pluck($projects, 'id');
         $milestones = Milestone::whereIn('project_id', $projectids)->get();
         $accomplishments = Accomplishment::whereIn('project_id', $projectids)->get();
         $issues = Issue::whereIn('project_id', $projectids)->get();
         $risks = Risk::whereIn('project_id', $projectids)->get();
         $expenses = Expense::whereIn('project_id', $projectids)->get();
         $actions = Action::whereIn('project_id', $projectids)->get();
         $deliverables = Deliverable::whereIn('project_id', $projectids)->get();
         $business_project_team_members = BusinessProjectTeamMember::whereIn('project_id', $projectids)->get();
         $technical_project_team_members = TechnicalProjectTeamMember::whereIn('project_id', $projectids)->get();
         $support_team_members = SupportTeamMember::whereIn('project_id', $projectids)->get();
         return view('audit.generate', compact('activities', 'projects', 'milestones', 'accomplishments', 'issues', 'risks', 'expenses', 'actions', 'deliverables', 'business_project_team_members', 'technical_project_team_members', 'support_team_members'));
     } elseif (Auth::user()->role == "System Administrator") {
         $activities = Activity::whereIn('action', array('Created', 'Deleted', 'Updated'))->where(function ($query) {
             return $query->where('action', '!=', 'Created')->orWhere('type', '!=', 'Deliverable');
         })->get();
         $projects = Project::all();
         $milestones = Milestone::all();
         $accomplishments = Accomplishment::all();
         $issues = Issue::all();
         $risks = Risk::all();
         $users = User::all();
         $expenses = Expense::all();
         $actions = Action::all();
         $deliverables = Deliverable::all();
         $business_project_team_members = BusinessProjectTeamMember::all();
         $technical_project_team_members = TechnicalProjectTeamMember::all();
         $support_team_members = SupportTeamMember::all();
         return view('audit.generate', compact('activities', 'projects', 'milestones', 'accomplishments', 'issues', 'risks', 'users', 'expenses', 'actions', 'deliverables', 'business_project_team_members', 'technical_project_team_members', 'support_team_members'));
     } else {
         flash()->error('You are not authorized to proceed.');
         return redirect()->action('ProjectsController@index');
     }
 }