تم الحفظ.

'; } $key = esc_attr(get_option('sa_finnhub_api_key','')); ?>

Stock Analyzer Settings

Finnhub API Key

سجّل في finnhub.io للحصول على مفتاح مجاني.

admin_url('admin-ajax.php') ]); }); // ------------------ Shortcode ------------------ add_shortcode('stock_analyzer', function($atts){ ob_start(); ?>
null,'sma50'=>null,'rsi14'=>null]; if(isset($candles['s']) && $candles['s'] === 'ok'){ $closes = $candles['c']; $indicators['sma20'] = sa_array_sma($closes,20); $indicators['sma50'] = sa_array_sma($closes,50); $indicators['rsi14'] = sa_array_rsi($closes,14); } // 4) news (last 7 days) $fromn = date('Y-m-d', strtotime('-7 days')); $ton = date('Y-m-d'); $news = sa_finnhub_get("https://finnhub.io/api/v1/company-news?symbol={$symbol}&from={$fromn}&to={$ton}&token={$key}"); wp_send_json_success([ 'profile'=>$profile, 'quote'=>$quote, 'indicators'=>$indicators, 'news'=>$news ]); } // Predict endpoint (simple heuristic) add_action('wp_ajax_nopriv_sa_predict', 'sa_predict'); add_action('wp_ajax_sa_predict', 'sa_predict'); function sa_predict(){ $symbol = sanitize_text_field($_GET['symbol'] ?? ''); $key = get_option('sa_finnhub_api_key',''); if(!$symbol || !$key) wp_send_json_error('missing',400); // reuse get_data (call internal) $_GET['resolution']='D'; ob_start(); sa_get_data(); $resp = ob_get_clean(); $obj = json_decode($resp, true); if(!$obj || !$obj['success']) wp_send_json_error('failed to fetch data',500); $quote = $obj['data']['quote']; $ind = $obj['data']['indicators']; $score = 0; // heuristics: if($ind['sma50'] && $quote['c'] > $ind['sma50']) $score += 1; if($ind['sma20'] && $quote['c'] > $ind['sma20']) $score += 1; if($ind['rsi'] = $ind['rsi14']) { if($ind['rsi'] < 30) $score += 1; if($ind['rsi'] > 70) $score -= 1; } // predicted relative change = score * 2% (example) $pred_change = $score * 0.02; $pred_price = $quote['c'] * (1 + $pred_change); wp_send_json_success([ 'score'=>$score, 'pred_change_pct'=>round($pred_change*100,2), 'pred_price'=>round($pred_price,2) ]); } // ------------------ helper functions ------------------ function sa_finnhub_get($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $out = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if($code === 200){ $json = json_decode($out, true); return $json; } return null; } function sa_array_sma($arr, $period){ $n = count($arr); if($n < $period) return null; $sum = 0; for($i=$n-$period;$i<$n;$i++) $sum += $arr[$i]; return $sum / $period; } function sa_array_rsi($arr, $period=14){ $n = count($arr); if($n <= $period) return null; $gains=0; $losses=0; for($i=$n-$period+1;$i<$n;$i++){ $diff = $arr[$i] - $arr[$i-1]; if($diff>0) $gains += $diff; else $losses -= $diff; } $avgGain = $gains/$period; $avgLoss = $losses/$period; if($avgLoss == 0) return 100; $rs = $avgGain / $avgLoss; return 100 - (100 / (1 + $rs)); }

تواصل معنا

اتصل بفريق تحليل الأسهم لمساعدتك

Person checking stock market graphs on laptop and smartphone, focusing on financial data.

الهاتف

+966 50 464 3469

البريد الإلكتروني

8oclock.store@gmail.com

العنوان

2360 Hood Avenue, San Diego, CA, 92123

نحن هنا لمساعدتك

لا تتردد في التواصل معنا للحصول على أي استفسارات أو دعم يتعلق بتحليل الأسهم والأسواق المالية.

وسائل التواصل الاجتماعي

First Name
Email
Message
The form has been submitted successfully!
There has been some error while submitting the form. Please verify all form fields again.

الهاتف

+966 50 464 3469

البريد الإلكتروني

8oclock.store@gmail.com

العنوان

2360 Hood Avenue, San Diego, CA, 92123

نحن هنا لمساعدتك

لا تتردد في التواصل معنا للحصول على أي استفسارات أو دعم يتعلق بتحليل الأسهم والأسواق المالية.

وسائل التواصل الاجتماعي

[sureforms id=”610″]

ابدأ استثماراتك اليوم مع تحليل الأسهم

Scroll to Top