User interface HTML string generated using PHP Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)JavaScript/HTML web application - user interface logicOptimizing PHP script fetching entire HTML pagesReview structure of PHP/HTMLScraping HTML using PHPHTML Form validation with PHPphp inside html indent stylephp/html template for checkoutEmbedding an HTML (String) Generated from a Tree Structure JSONPHP New User CreationMethods To Generate an HTML String using an Array in PHP
When is phishing education going too far?
What do you call the holes in a flute?
New Order #5: where Fibonacci and Beatty meet at Wythoff
How to stop my camera from exagerrating differences in skin colour?
How to market an anarchic city as a tourism spot to people living in civilized areas?
Why is there no army of Iron-Mans in the MCU?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Can a zero nonce be safely used with AES-GCM if the key is random and never used again?
How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time
Stop battery usage [Ubuntu 18]
What is the order of Mitzvot in Rambam's Sefer Hamitzvot?
Is it possible to ask for a hotel room without minibar/extra services?
Replacing HDD with SSD; what about non-APFS/APFS?
Unexpected result with right shift after bitwise negation
Area of a 2D convex hull
How can I make names more distinctive without making them longer?
What's the point in a preamp?
How to rotate it perfectly?
Unable to start mainnet node docker container
Did the new image of black hole confirm the general theory of relativity?
Should you tell Jews they are breaking a commandment?
Cold is to Refrigerator as warm is to?
How does modal jazz use chord progressions?
Antler Helmet: Can it work?
User interface HTML string generated using PHP
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)JavaScript/HTML web application - user interface logicOptimizing PHP script fetching entire HTML pagesReview structure of PHP/HTMLScraping HTML using PHPHTML Form validation with PHPphp inside html indent stylephp/html template for checkoutEmbedding an HTML (String) Generated from a Tree Structure JSONPHP New User CreationMethods To Generate an HTML String using an Array in PHP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
This script extends the main class and generates an HTML string for user interface. You can also view the entire codes in this link.
It works okay, however would you be so kind and review it (maybe for performance) and maybe list your changes/to be changed to, if possible?
HTMLviewEQ class
date_default_timezone_set("America/New_York");
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
set_time_limit(0);
require_once __DIR__ . "/HTMLviewEQ.php";
class HTMLviewEQ extends EQ implements ConstEQ
/**
*
* @return a large HTML string of base article content including meta, abstract and written analysis
*/
public static function getBaseHTML($array, $page_id, $class_obj)
/**
*@var is the current datatime
*/
$dt = new DateTime('now');
$dt = $dt->format('Y-m-d H:i:s');
/**
*@var is the equity symbol: AAPL, AMD
*/
$symb = $array["quote"]["symbol"];
/**
*@var is the full name of public company
*/
$comp = $array["quote"]["companyName"];
/**
*@var is the name of sector: Technology, Healthcare
*/
$sect = $array["quote"]["sector"];
/**
*@var is the name of exchange market: New York Stock Exchange, CBOE, NASDAQ
*/
$mark = $array["quote"]["primaryExchange"];
/**
*@var is the first date in chart array, which is the oldest date
*/
$fd = $array["chart"][0]["date"];
/**
*@var is the last date in chart array, which is the newest date
*/
$ld = array_reverse($array["chart"])[0]["date"];
/**
*@var is the article URL
*/
$url = ConstEQ::PROTOCOL .
ConstEQ::DOMAIN .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_1 .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_2 .
ConstEQ::SLASH . $page_id;
/**
*@var is a short meta for page about
*/
$page_about = $comp . ": Seven price sets are approximated for " . $symb . " lowest supports, " . $symb . " highest resistances and " . $symb . " equilibriums. Each price set is a forecast of daily equity price range of " . $symb . " and has a percentage indicator which shows " . $symb . " upward or downward trends in that session.";
/**
*@var is a short meta for page description
*/
$page_description = $symb . " - " . $comp . ": Average equilibrium share price forecasts are pretty important for " . $symb . " short/long trading and investing, " . $symb . " institutional trading, " . $symb . " portfolio management, " . $symb . " risk assessment, " . $symb . " algorithmic and automated trading, " . $symb . " buy/sell/hold decision makings, " . $symb . " day/swing trading, " . $symb . " put and call option forecasting, " . $symb . " volume estimating, " . $symb . " volatility approximating, " . $symb . " resistance and support evaluating, " . $symb . " stop loss computations, " . $symb . " sentiment analysis and " . $symb . " other quantitative analytics.";
$wrap_symb = '<b class="br-2 b119 r1' . rand(20, 99) . '">' . $symb . '</b>';
/**
*@var is a summary/highlight of article
*/
$article_highlight = $comp . ": Seven price sets are being approximated for " . $wrap_symb . " lowest supports, " . $wrap_symb . " average equilibriums and " . $wrap_symb . " highest resistances. Each set has a "percentage", which indicates that if " . $wrap_symb . " has been outperforming or downperforming during that day.";
/**
*@var is an abstract for the article
*/
$article_abstract = $wrap_symb . " - " . $comp . ": Equilibrium price is important for " . $wrap_symb . " institutional trading/investing, " . $wrap_symb . " retail trading/investing and other types of short/long positions. They provide supplementary perspectives to traders for " . $wrap_symb . " day/swing trading, " . $wrap_symb . " low/high frequency trading, " . $wrap_symb . " put/call option forecasting, " . $wrap_symb . " forward/reverse trading/investing and " . $wrap_symb . " algorithmic trading. Average equilibrium price is necessary for " . $wrap_symb . " Buy/Sell/Hold decision makings and " . $wrap_symb . " rating for analyst coverages and equity due diligence. They are also beneficial for " . $wrap_symb . " trading volume forecasting, " . $wrap_symb . " daily volatility approximating, " . $wrap_symb . " resistance and support evaluating, " . $wrap_symb . " stop loss calculations, among other quantitative advantages. Static charts cannot provide such information to trading and investing entities.";
/**
*@var is a legal warning for informing visitors
*/
$article_warning = "⚖ All " . $symb . " information are connected to delayed 60-seconds data pipelines from version 1.0 API at https://api.iextrading.com/1.0/, in addition to other financial and economical data. All computations are automatic, currently independent of all news, sentiments, external parameters and internal corporate factors. This page is only an alpha prototype and is only updated a few times per hour based on our dynamic indices and latest quote scraped from that API. It may not be accessible at all times, and inadvertent or unknown inaccuracies exist. All information are provided under "AT YOUR OWN FULL RISKS" and "NO LIABILITIES, UNDER NO CIRCUMSTANCES" terms. Trade Safe and Happy Investing!";
/**
*@var is a list of terms used in the articles
*/
$indicators = array(
"Equilibrium" => $wrap_symb . " equilibrium is an average theoretical price, where both buy and sell flows of " . $wrap_symb . " are equal. It is good to be taken into account in near-term trading/investing decision makings.",
"Sessions" => $wrap_symb . " data from " . sizeof($array["chart"]) . " days has been summarized here, each with eight price sets for " . $wrap_symb . ". The first set has the actual " . $wrap_symb . " market prices. The other seven sets are our estimated equilibrium prices for " . $wrap_symb . ". On the left, dynamic lowest supports of " . $wrap_symb . " have been displayed and on the right, you can see the dynamic highest resistances of " . $wrap_symb . ".",
"Volatility" => ""Low" to "extreme" volatilities have been forced to our algorithms for computing " . $wrap_symb . " supports and resistances from set 1 to set 7, respectively.",
"Percentage" => "The underneath "percentage" is an indicator of the difference in between the actual " . $wrap_symb . " and our estimated equilibrium prices for " . $wrap_symb . ".",
"Supports" => "" . $wrap_symb . " dynamic supports have been approximated as a function of time.",
"Resistances" => " " . $wrap_symb . " dynamic resistances have been also approximated as a function of time.",
"Narrow Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very close, it might indicate: (a) there may not have been much trading/investing actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " may have solid block traders/investors; OR (c) " . $wrap_symb . " might have had a low-risk and low-return session; AND (d) other similar analyses can be extracted from.",
"Distant Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very scattered, it might indicate: (a) there might have been much sophisticated trading actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " might have had adept traders in that session; OR (c) " . $wrap_symb . " may have had a high-risk and high-return session; AND (d) other similar analyses can be obtained.",
"Narrow Resistances Range" => "If 7 dynamic resistances of " . $wrap_symb . " are very close, it may suggest outcomes such as: (a) " . $wrap_symb . " holds strong resistances that are challenging for breakouts and may require strong catalysts; OR (b) " . $wrap_symb . " may have had adept reverse traders in that session; OR (c) " . $wrap_symb . " may not have had sufficient upside actions in that session; OR (d) " . $wrap_symb . " might have had a low-risk and low-return or negative session.",
);
/**
*@var is a list of keywords for article
*/
$tags = $symb . " Stock, " . $symb . " Intraday Trading, " . $symb . " Investing, " . $symb . " Option Pricing, " . $symb . " Day Trading, " . $symb . " Swing Trading, " . $symb . " Put and Call Forecast, " . $symb . " Price Target, " . $symb . " Premarket, " . $comp . ", " . $sect . ", " . $mark;
/**
*@var is title 1 for article
*/
$page_title = $symb . " " . $comp . " Trading and Investing Equilibrium Price Analytics: " . money_format('%=4.2n', ST::getMean($array["m"]["p"])) . "
/**
* [
['Mon', 20, 28, 38, 45],
['Tue', 31, 38, 55, 66],
['Wed', 50, 55, 77, 80],
['Thu', 77, 77, 66, 50],
['Fri', 68, 66, 22, 15]
]
* @return an HTML string for a chart using google chart API
*/
public static function getCandlestickChart($arr)
$html = '<div id="chart_div" class="ro"></div>';
$html .= '<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>';
$html .= '<script type="text/javascript">';
$html .= "google.charts.load('current', 'packages':['corechart']);";
$html .= "google.charts.setOnLoadCallback(drawChart);";
$html .= "function drawChart()
var data = google.visualization.arrayToDataTable(" . $arr . ", true);
var options =
title:'Candlestick Chart: Low Support, VWAP, Equilibrium, High Resistance',
legend:'none',
selectionMode:'multiple',
agregationTarget:'category',
height:data.getNumberOfRows()*25,
orientation:'vertical',
theme:
axisTitlePosition:'in',
hAxis:titlePosition:'in',
,
tooltip:
trigger:'selection',
textStyle:
color:'#3A5FCD',
showColorCode:true,
fontSize:12,
bold:true,
isHTML:true
,
chartArea:
left:'1%',
top:50,
right:0,
bottom:75,
backgroundColor:'#333',
,
hAxis:
title:'Equity Prices',
titleTextStyle:
color:'#63B8FF',
fontSize:20,
bold:true
,
textStyle:
color:'#014B96',
fontSize:15,
bold:true
,
format:'currency'
,
vAxis:
textStyle:
color:'#8968CD',
fontSize:10,
bold:true
,
minorGridlines:
color:'#EEEE00',
count:10,
,
candlestick:
risingColor:stroke:'#EEEE00',fill:'#32CD32',
fallingColor:stroke:'#858585',fill:'#FF4500'
,
colors:['#4169E1']
;
var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
chart.draw(data, options);
</script>";
return $html;
/**
*
* @return a large HTML string of past 20 sessions equilibrium estimations with 7 volatilities
*/
public static function getMobileEquilibrium($arr)
$html = ''; // child html
$eq_htmls = ''; // parent html
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
$r = rand(0, 9);
if ($i === (sizeof($p) / 4) - 1)
$html .= '<div class="ro di-2 a120 a220 a320 a420 a520 a620 a720 sq-1 br-5 mv-5 b11' . $r . ' r100 sq-1">';
$html .= '<div class="ro tx-1 s16">' . $arr["c"]["c"][$k]["s"] . '</div>'; // session date
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="a-0" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Actual Low</b>';
$html .= '<b id="a-1" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Actual VWAP</b>';
$html .= '<b id="a-2" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Actual High</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1">' . $arr["c"]["c"][$k]["l"] . '</b>';
$html .= '<b id="b-1' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1">' . $arr["c"]["c"][$k]["w"] . '</b>';
$html .= '<b id="b-2' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1">' . $arr["c"]["c"][$k]["h"] . '</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="e-0" class="s15 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Approximated Supports</b>';
$html .= '<b id="e-1" class="s15 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Estimated Equilibriums </b>';
$html .= '<b id="e-2" class="s15 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Approximated Resistances</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i > 0 && $i < sizeof($p) / 4 - 1)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i === 0)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Lowest Lows</b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Equilibriums </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Highest Highs</b>';
$html .= '</div>';
$html .= '</div>';
else
if ($_SERVER['LOGNAME'] === ConstEQ::LOCALHOST)
HelperEQ::linePrint("OOPS! It might be sizeof($p)/4, Check the algorithm! 💔 " . ConstEQ::NEW_LINE);
continue;
$eq_htmls .= $html;
$html = '';
/**
*@var is a button for open/close equilibrium data
*/
$click_button = '<a href="#" class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3" onclick="J.toggleSwitch(d:this);return false;" title="' . $arr["quote"]["symbol"] . ' latest quote">🎛 Average Daily Equilibrium Forecast: ' . date('l, d F Y ⏱ H:i T', microtime(true)) . '</a>';
return '<div class="ro">' . $click_button . '<div class="di-0"><div class="p-3">' . $eq_htmls . '</div></div></div>';
/**
*
* @return a large HTML string of current quote section
*/
public static function getQuoteHTML($a)
/**
*@method gets majority of quote array parameters
*/
$quote_params = ST::getQuoteParams();
/**
*@var is the HTML for quote section of the article
*/
$html = '<div class="ro">' .
'<a href="#"' .
' class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3"' .
' onclick="J.toggleSwitch(d:this); return false;"' .
' title="' . $a["symbol"] . ' latest quote">' .
' 💹 Quote: ' . date('l, d F Y ⏱ H:i T', microtime(true)) .
'</a>' .
'<div class="di-0">' .
'<div class="p-3">';
foreach ($quote_params as $param)
$html .= '</div>' .
'</div>' .
'</div>';
return $html;
/**
*
* @return an HTML string for a chart using google chart API
*/
public static function getEquilibriumHTML($arr)
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
$candle_chart_arr = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
array_push($candle_chart_arr,
array(
$arr["c"]["c"][$k]["s"], // date
(float) substr($p["l" . $i], 1), // low support estimated
(float) substr($arr["c"]["c"][$k]["w"], 1), // VWAP market price
(float) substr($p["e" . $i], 1), // Equilibrium estimated
(float) substr($p["h" . $i], 1), // high resistance estimated
)
);
return HTMLviewEQ::getCandlestickChart(json_encode($candle_chart_arr, true));
javascript performance beginner php html
$endgroup$
add a comment |
$begingroup$
This script extends the main class and generates an HTML string for user interface. You can also view the entire codes in this link.
It works okay, however would you be so kind and review it (maybe for performance) and maybe list your changes/to be changed to, if possible?
HTMLviewEQ class
date_default_timezone_set("America/New_York");
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
set_time_limit(0);
require_once __DIR__ . "/HTMLviewEQ.php";
class HTMLviewEQ extends EQ implements ConstEQ
/**
*
* @return a large HTML string of base article content including meta, abstract and written analysis
*/
public static function getBaseHTML($array, $page_id, $class_obj)
/**
*@var is the current datatime
*/
$dt = new DateTime('now');
$dt = $dt->format('Y-m-d H:i:s');
/**
*@var is the equity symbol: AAPL, AMD
*/
$symb = $array["quote"]["symbol"];
/**
*@var is the full name of public company
*/
$comp = $array["quote"]["companyName"];
/**
*@var is the name of sector: Technology, Healthcare
*/
$sect = $array["quote"]["sector"];
/**
*@var is the name of exchange market: New York Stock Exchange, CBOE, NASDAQ
*/
$mark = $array["quote"]["primaryExchange"];
/**
*@var is the first date in chart array, which is the oldest date
*/
$fd = $array["chart"][0]["date"];
/**
*@var is the last date in chart array, which is the newest date
*/
$ld = array_reverse($array["chart"])[0]["date"];
/**
*@var is the article URL
*/
$url = ConstEQ::PROTOCOL .
ConstEQ::DOMAIN .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_1 .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_2 .
ConstEQ::SLASH . $page_id;
/**
*@var is a short meta for page about
*/
$page_about = $comp . ": Seven price sets are approximated for " . $symb . " lowest supports, " . $symb . " highest resistances and " . $symb . " equilibriums. Each price set is a forecast of daily equity price range of " . $symb . " and has a percentage indicator which shows " . $symb . " upward or downward trends in that session.";
/**
*@var is a short meta for page description
*/
$page_description = $symb . " - " . $comp . ": Average equilibrium share price forecasts are pretty important for " . $symb . " short/long trading and investing, " . $symb . " institutional trading, " . $symb . " portfolio management, " . $symb . " risk assessment, " . $symb . " algorithmic and automated trading, " . $symb . " buy/sell/hold decision makings, " . $symb . " day/swing trading, " . $symb . " put and call option forecasting, " . $symb . " volume estimating, " . $symb . " volatility approximating, " . $symb . " resistance and support evaluating, " . $symb . " stop loss computations, " . $symb . " sentiment analysis and " . $symb . " other quantitative analytics.";
$wrap_symb = '<b class="br-2 b119 r1' . rand(20, 99) . '">' . $symb . '</b>';
/**
*@var is a summary/highlight of article
*/
$article_highlight = $comp . ": Seven price sets are being approximated for " . $wrap_symb . " lowest supports, " . $wrap_symb . " average equilibriums and " . $wrap_symb . " highest resistances. Each set has a "percentage", which indicates that if " . $wrap_symb . " has been outperforming or downperforming during that day.";
/**
*@var is an abstract for the article
*/
$article_abstract = $wrap_symb . " - " . $comp . ": Equilibrium price is important for " . $wrap_symb . " institutional trading/investing, " . $wrap_symb . " retail trading/investing and other types of short/long positions. They provide supplementary perspectives to traders for " . $wrap_symb . " day/swing trading, " . $wrap_symb . " low/high frequency trading, " . $wrap_symb . " put/call option forecasting, " . $wrap_symb . " forward/reverse trading/investing and " . $wrap_symb . " algorithmic trading. Average equilibrium price is necessary for " . $wrap_symb . " Buy/Sell/Hold decision makings and " . $wrap_symb . " rating for analyst coverages and equity due diligence. They are also beneficial for " . $wrap_symb . " trading volume forecasting, " . $wrap_symb . " daily volatility approximating, " . $wrap_symb . " resistance and support evaluating, " . $wrap_symb . " stop loss calculations, among other quantitative advantages. Static charts cannot provide such information to trading and investing entities.";
/**
*@var is a legal warning for informing visitors
*/
$article_warning = "⚖ All " . $symb . " information are connected to delayed 60-seconds data pipelines from version 1.0 API at https://api.iextrading.com/1.0/, in addition to other financial and economical data. All computations are automatic, currently independent of all news, sentiments, external parameters and internal corporate factors. This page is only an alpha prototype and is only updated a few times per hour based on our dynamic indices and latest quote scraped from that API. It may not be accessible at all times, and inadvertent or unknown inaccuracies exist. All information are provided under "AT YOUR OWN FULL RISKS" and "NO LIABILITIES, UNDER NO CIRCUMSTANCES" terms. Trade Safe and Happy Investing!";
/**
*@var is a list of terms used in the articles
*/
$indicators = array(
"Equilibrium" => $wrap_symb . " equilibrium is an average theoretical price, where both buy and sell flows of " . $wrap_symb . " are equal. It is good to be taken into account in near-term trading/investing decision makings.",
"Sessions" => $wrap_symb . " data from " . sizeof($array["chart"]) . " days has been summarized here, each with eight price sets for " . $wrap_symb . ". The first set has the actual " . $wrap_symb . " market prices. The other seven sets are our estimated equilibrium prices for " . $wrap_symb . ". On the left, dynamic lowest supports of " . $wrap_symb . " have been displayed and on the right, you can see the dynamic highest resistances of " . $wrap_symb . ".",
"Volatility" => ""Low" to "extreme" volatilities have been forced to our algorithms for computing " . $wrap_symb . " supports and resistances from set 1 to set 7, respectively.",
"Percentage" => "The underneath "percentage" is an indicator of the difference in between the actual " . $wrap_symb . " and our estimated equilibrium prices for " . $wrap_symb . ".",
"Supports" => "" . $wrap_symb . " dynamic supports have been approximated as a function of time.",
"Resistances" => " " . $wrap_symb . " dynamic resistances have been also approximated as a function of time.",
"Narrow Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very close, it might indicate: (a) there may not have been much trading/investing actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " may have solid block traders/investors; OR (c) " . $wrap_symb . " might have had a low-risk and low-return session; AND (d) other similar analyses can be extracted from.",
"Distant Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very scattered, it might indicate: (a) there might have been much sophisticated trading actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " might have had adept traders in that session; OR (c) " . $wrap_symb . " may have had a high-risk and high-return session; AND (d) other similar analyses can be obtained.",
"Narrow Resistances Range" => "If 7 dynamic resistances of " . $wrap_symb . " are very close, it may suggest outcomes such as: (a) " . $wrap_symb . " holds strong resistances that are challenging for breakouts and may require strong catalysts; OR (b) " . $wrap_symb . " may have had adept reverse traders in that session; OR (c) " . $wrap_symb . " may not have had sufficient upside actions in that session; OR (d) " . $wrap_symb . " might have had a low-risk and low-return or negative session.",
);
/**
*@var is a list of keywords for article
*/
$tags = $symb . " Stock, " . $symb . " Intraday Trading, " . $symb . " Investing, " . $symb . " Option Pricing, " . $symb . " Day Trading, " . $symb . " Swing Trading, " . $symb . " Put and Call Forecast, " . $symb . " Price Target, " . $symb . " Premarket, " . $comp . ", " . $sect . ", " . $mark;
/**
*@var is title 1 for article
*/
$page_title = $symb . " " . $comp . " Trading and Investing Equilibrium Price Analytics: " . money_format('%=4.2n', ST::getMean($array["m"]["p"])) . "
/**
* [
['Mon', 20, 28, 38, 45],
['Tue', 31, 38, 55, 66],
['Wed', 50, 55, 77, 80],
['Thu', 77, 77, 66, 50],
['Fri', 68, 66, 22, 15]
]
* @return an HTML string for a chart using google chart API
*/
public static function getCandlestickChart($arr)
$html = '<div id="chart_div" class="ro"></div>';
$html .= '<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>';
$html .= '<script type="text/javascript">';
$html .= "google.charts.load('current', 'packages':['corechart']);";
$html .= "google.charts.setOnLoadCallback(drawChart);";
$html .= "function drawChart()
var data = google.visualization.arrayToDataTable(" . $arr . ", true);
var options =
title:'Candlestick Chart: Low Support, VWAP, Equilibrium, High Resistance',
legend:'none',
selectionMode:'multiple',
agregationTarget:'category',
height:data.getNumberOfRows()*25,
orientation:'vertical',
theme:
axisTitlePosition:'in',
hAxis:titlePosition:'in',
,
tooltip:
trigger:'selection',
textStyle:
color:'#3A5FCD',
showColorCode:true,
fontSize:12,
bold:true,
isHTML:true
,
chartArea:
left:'1%',
top:50,
right:0,
bottom:75,
backgroundColor:'#333',
,
hAxis:
title:'Equity Prices',
titleTextStyle:
color:'#63B8FF',
fontSize:20,
bold:true
,
textStyle:
color:'#014B96',
fontSize:15,
bold:true
,
format:'currency'
,
vAxis:
textStyle:
color:'#8968CD',
fontSize:10,
bold:true
,
minorGridlines:
color:'#EEEE00',
count:10,
,
candlestick:
risingColor:stroke:'#EEEE00',fill:'#32CD32',
fallingColor:stroke:'#858585',fill:'#FF4500'
,
colors:['#4169E1']
;
var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
chart.draw(data, options);
</script>";
return $html;
/**
*
* @return a large HTML string of past 20 sessions equilibrium estimations with 7 volatilities
*/
public static function getMobileEquilibrium($arr)
$html = ''; // child html
$eq_htmls = ''; // parent html
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
$r = rand(0, 9);
if ($i === (sizeof($p) / 4) - 1)
$html .= '<div class="ro di-2 a120 a220 a320 a420 a520 a620 a720 sq-1 br-5 mv-5 b11' . $r . ' r100 sq-1">';
$html .= '<div class="ro tx-1 s16">' . $arr["c"]["c"][$k]["s"] . '</div>'; // session date
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="a-0" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Actual Low</b>';
$html .= '<b id="a-1" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Actual VWAP</b>';
$html .= '<b id="a-2" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Actual High</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1">' . $arr["c"]["c"][$k]["l"] . '</b>';
$html .= '<b id="b-1' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1">' . $arr["c"]["c"][$k]["w"] . '</b>';
$html .= '<b id="b-2' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1">' . $arr["c"]["c"][$k]["h"] . '</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="e-0" class="s15 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Approximated Supports</b>';
$html .= '<b id="e-1" class="s15 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Estimated Equilibriums </b>';
$html .= '<b id="e-2" class="s15 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Approximated Resistances</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i > 0 && $i < sizeof($p) / 4 - 1)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i === 0)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Lowest Lows</b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Equilibriums </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Highest Highs</b>';
$html .= '</div>';
$html .= '</div>';
else
if ($_SERVER['LOGNAME'] === ConstEQ::LOCALHOST)
HelperEQ::linePrint("OOPS! It might be sizeof($p)/4, Check the algorithm! 💔 " . ConstEQ::NEW_LINE);
continue;
$eq_htmls .= $html;
$html = '';
/**
*@var is a button for open/close equilibrium data
*/
$click_button = '<a href="#" class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3" onclick="J.toggleSwitch(d:this);return false;" title="' . $arr["quote"]["symbol"] . ' latest quote">🎛 Average Daily Equilibrium Forecast: ' . date('l, d F Y ⏱ H:i T', microtime(true)) . '</a>';
return '<div class="ro">' . $click_button . '<div class="di-0"><div class="p-3">' . $eq_htmls . '</div></div></div>';
/**
*
* @return a large HTML string of current quote section
*/
public static function getQuoteHTML($a)
/**
*@method gets majority of quote array parameters
*/
$quote_params = ST::getQuoteParams();
/**
*@var is the HTML for quote section of the article
*/
$html = '<div class="ro">' .
'<a href="#"' .
' class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3"' .
' onclick="J.toggleSwitch(d:this); return false;"' .
' title="' . $a["symbol"] . ' latest quote">' .
' 💹 Quote: ' . date('l, d F Y ⏱ H:i T', microtime(true)) .
'</a>' .
'<div class="di-0">' .
'<div class="p-3">';
foreach ($quote_params as $param)
$html .= '</div>' .
'</div>' .
'</div>';
return $html;
/**
*
* @return an HTML string for a chart using google chart API
*/
public static function getEquilibriumHTML($arr)
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
$candle_chart_arr = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
array_push($candle_chart_arr,
array(
$arr["c"]["c"][$k]["s"], // date
(float) substr($p["l" . $i], 1), // low support estimated
(float) substr($arr["c"]["c"][$k]["w"], 1), // VWAP market price
(float) substr($p["e" . $i], 1), // Equilibrium estimated
(float) substr($p["h" . $i], 1), // high resistance estimated
)
);
return HTMLviewEQ::getCandlestickChart(json_encode($candle_chart_arr, true));
javascript performance beginner php html
$endgroup$
add a comment |
$begingroup$
This script extends the main class and generates an HTML string for user interface. You can also view the entire codes in this link.
It works okay, however would you be so kind and review it (maybe for performance) and maybe list your changes/to be changed to, if possible?
HTMLviewEQ class
date_default_timezone_set("America/New_York");
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
set_time_limit(0);
require_once __DIR__ . "/HTMLviewEQ.php";
class HTMLviewEQ extends EQ implements ConstEQ
/**
*
* @return a large HTML string of base article content including meta, abstract and written analysis
*/
public static function getBaseHTML($array, $page_id, $class_obj)
/**
*@var is the current datatime
*/
$dt = new DateTime('now');
$dt = $dt->format('Y-m-d H:i:s');
/**
*@var is the equity symbol: AAPL, AMD
*/
$symb = $array["quote"]["symbol"];
/**
*@var is the full name of public company
*/
$comp = $array["quote"]["companyName"];
/**
*@var is the name of sector: Technology, Healthcare
*/
$sect = $array["quote"]["sector"];
/**
*@var is the name of exchange market: New York Stock Exchange, CBOE, NASDAQ
*/
$mark = $array["quote"]["primaryExchange"];
/**
*@var is the first date in chart array, which is the oldest date
*/
$fd = $array["chart"][0]["date"];
/**
*@var is the last date in chart array, which is the newest date
*/
$ld = array_reverse($array["chart"])[0]["date"];
/**
*@var is the article URL
*/
$url = ConstEQ::PROTOCOL .
ConstEQ::DOMAIN .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_1 .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_2 .
ConstEQ::SLASH . $page_id;
/**
*@var is a short meta for page about
*/
$page_about = $comp . ": Seven price sets are approximated for " . $symb . " lowest supports, " . $symb . " highest resistances and " . $symb . " equilibriums. Each price set is a forecast of daily equity price range of " . $symb . " and has a percentage indicator which shows " . $symb . " upward or downward trends in that session.";
/**
*@var is a short meta for page description
*/
$page_description = $symb . " - " . $comp . ": Average equilibrium share price forecasts are pretty important for " . $symb . " short/long trading and investing, " . $symb . " institutional trading, " . $symb . " portfolio management, " . $symb . " risk assessment, " . $symb . " algorithmic and automated trading, " . $symb . " buy/sell/hold decision makings, " . $symb . " day/swing trading, " . $symb . " put and call option forecasting, " . $symb . " volume estimating, " . $symb . " volatility approximating, " . $symb . " resistance and support evaluating, " . $symb . " stop loss computations, " . $symb . " sentiment analysis and " . $symb . " other quantitative analytics.";
$wrap_symb = '<b class="br-2 b119 r1' . rand(20, 99) . '">' . $symb . '</b>';
/**
*@var is a summary/highlight of article
*/
$article_highlight = $comp . ": Seven price sets are being approximated for " . $wrap_symb . " lowest supports, " . $wrap_symb . " average equilibriums and " . $wrap_symb . " highest resistances. Each set has a "percentage", which indicates that if " . $wrap_symb . " has been outperforming or downperforming during that day.";
/**
*@var is an abstract for the article
*/
$article_abstract = $wrap_symb . " - " . $comp . ": Equilibrium price is important for " . $wrap_symb . " institutional trading/investing, " . $wrap_symb . " retail trading/investing and other types of short/long positions. They provide supplementary perspectives to traders for " . $wrap_symb . " day/swing trading, " . $wrap_symb . " low/high frequency trading, " . $wrap_symb . " put/call option forecasting, " . $wrap_symb . " forward/reverse trading/investing and " . $wrap_symb . " algorithmic trading. Average equilibrium price is necessary for " . $wrap_symb . " Buy/Sell/Hold decision makings and " . $wrap_symb . " rating for analyst coverages and equity due diligence. They are also beneficial for " . $wrap_symb . " trading volume forecasting, " . $wrap_symb . " daily volatility approximating, " . $wrap_symb . " resistance and support evaluating, " . $wrap_symb . " stop loss calculations, among other quantitative advantages. Static charts cannot provide such information to trading and investing entities.";
/**
*@var is a legal warning for informing visitors
*/
$article_warning = "⚖ All " . $symb . " information are connected to delayed 60-seconds data pipelines from version 1.0 API at https://api.iextrading.com/1.0/, in addition to other financial and economical data. All computations are automatic, currently independent of all news, sentiments, external parameters and internal corporate factors. This page is only an alpha prototype and is only updated a few times per hour based on our dynamic indices and latest quote scraped from that API. It may not be accessible at all times, and inadvertent or unknown inaccuracies exist. All information are provided under "AT YOUR OWN FULL RISKS" and "NO LIABILITIES, UNDER NO CIRCUMSTANCES" terms. Trade Safe and Happy Investing!";
/**
*@var is a list of terms used in the articles
*/
$indicators = array(
"Equilibrium" => $wrap_symb . " equilibrium is an average theoretical price, where both buy and sell flows of " . $wrap_symb . " are equal. It is good to be taken into account in near-term trading/investing decision makings.",
"Sessions" => $wrap_symb . " data from " . sizeof($array["chart"]) . " days has been summarized here, each with eight price sets for " . $wrap_symb . ". The first set has the actual " . $wrap_symb . " market prices. The other seven sets are our estimated equilibrium prices for " . $wrap_symb . ". On the left, dynamic lowest supports of " . $wrap_symb . " have been displayed and on the right, you can see the dynamic highest resistances of " . $wrap_symb . ".",
"Volatility" => ""Low" to "extreme" volatilities have been forced to our algorithms for computing " . $wrap_symb . " supports and resistances from set 1 to set 7, respectively.",
"Percentage" => "The underneath "percentage" is an indicator of the difference in between the actual " . $wrap_symb . " and our estimated equilibrium prices for " . $wrap_symb . ".",
"Supports" => "" . $wrap_symb . " dynamic supports have been approximated as a function of time.",
"Resistances" => " " . $wrap_symb . " dynamic resistances have been also approximated as a function of time.",
"Narrow Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very close, it might indicate: (a) there may not have been much trading/investing actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " may have solid block traders/investors; OR (c) " . $wrap_symb . " might have had a low-risk and low-return session; AND (d) other similar analyses can be extracted from.",
"Distant Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very scattered, it might indicate: (a) there might have been much sophisticated trading actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " might have had adept traders in that session; OR (c) " . $wrap_symb . " may have had a high-risk and high-return session; AND (d) other similar analyses can be obtained.",
"Narrow Resistances Range" => "If 7 dynamic resistances of " . $wrap_symb . " are very close, it may suggest outcomes such as: (a) " . $wrap_symb . " holds strong resistances that are challenging for breakouts and may require strong catalysts; OR (b) " . $wrap_symb . " may have had adept reverse traders in that session; OR (c) " . $wrap_symb . " may not have had sufficient upside actions in that session; OR (d) " . $wrap_symb . " might have had a low-risk and low-return or negative session.",
);
/**
*@var is a list of keywords for article
*/
$tags = $symb . " Stock, " . $symb . " Intraday Trading, " . $symb . " Investing, " . $symb . " Option Pricing, " . $symb . " Day Trading, " . $symb . " Swing Trading, " . $symb . " Put and Call Forecast, " . $symb . " Price Target, " . $symb . " Premarket, " . $comp . ", " . $sect . ", " . $mark;
/**
*@var is title 1 for article
*/
$page_title = $symb . " " . $comp . " Trading and Investing Equilibrium Price Analytics: " . money_format('%=4.2n', ST::getMean($array["m"]["p"])) . "
/**
* [
['Mon', 20, 28, 38, 45],
['Tue', 31, 38, 55, 66],
['Wed', 50, 55, 77, 80],
['Thu', 77, 77, 66, 50],
['Fri', 68, 66, 22, 15]
]
* @return an HTML string for a chart using google chart API
*/
public static function getCandlestickChart($arr)
$html = '<div id="chart_div" class="ro"></div>';
$html .= '<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>';
$html .= '<script type="text/javascript">';
$html .= "google.charts.load('current', 'packages':['corechart']);";
$html .= "google.charts.setOnLoadCallback(drawChart);";
$html .= "function drawChart()
var data = google.visualization.arrayToDataTable(" . $arr . ", true);
var options =
title:'Candlestick Chart: Low Support, VWAP, Equilibrium, High Resistance',
legend:'none',
selectionMode:'multiple',
agregationTarget:'category',
height:data.getNumberOfRows()*25,
orientation:'vertical',
theme:
axisTitlePosition:'in',
hAxis:titlePosition:'in',
,
tooltip:
trigger:'selection',
textStyle:
color:'#3A5FCD',
showColorCode:true,
fontSize:12,
bold:true,
isHTML:true
,
chartArea:
left:'1%',
top:50,
right:0,
bottom:75,
backgroundColor:'#333',
,
hAxis:
title:'Equity Prices',
titleTextStyle:
color:'#63B8FF',
fontSize:20,
bold:true
,
textStyle:
color:'#014B96',
fontSize:15,
bold:true
,
format:'currency'
,
vAxis:
textStyle:
color:'#8968CD',
fontSize:10,
bold:true
,
minorGridlines:
color:'#EEEE00',
count:10,
,
candlestick:
risingColor:stroke:'#EEEE00',fill:'#32CD32',
fallingColor:stroke:'#858585',fill:'#FF4500'
,
colors:['#4169E1']
;
var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
chart.draw(data, options);
</script>";
return $html;
/**
*
* @return a large HTML string of past 20 sessions equilibrium estimations with 7 volatilities
*/
public static function getMobileEquilibrium($arr)
$html = ''; // child html
$eq_htmls = ''; // parent html
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
$r = rand(0, 9);
if ($i === (sizeof($p) / 4) - 1)
$html .= '<div class="ro di-2 a120 a220 a320 a420 a520 a620 a720 sq-1 br-5 mv-5 b11' . $r . ' r100 sq-1">';
$html .= '<div class="ro tx-1 s16">' . $arr["c"]["c"][$k]["s"] . '</div>'; // session date
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="a-0" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Actual Low</b>';
$html .= '<b id="a-1" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Actual VWAP</b>';
$html .= '<b id="a-2" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Actual High</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1">' . $arr["c"]["c"][$k]["l"] . '</b>';
$html .= '<b id="b-1' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1">' . $arr["c"]["c"][$k]["w"] . '</b>';
$html .= '<b id="b-2' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1">' . $arr["c"]["c"][$k]["h"] . '</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="e-0" class="s15 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Approximated Supports</b>';
$html .= '<b id="e-1" class="s15 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Estimated Equilibriums </b>';
$html .= '<b id="e-2" class="s15 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Approximated Resistances</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i > 0 && $i < sizeof($p) / 4 - 1)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i === 0)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Lowest Lows</b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Equilibriums </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Highest Highs</b>';
$html .= '</div>';
$html .= '</div>';
else
if ($_SERVER['LOGNAME'] === ConstEQ::LOCALHOST)
HelperEQ::linePrint("OOPS! It might be sizeof($p)/4, Check the algorithm! 💔 " . ConstEQ::NEW_LINE);
continue;
$eq_htmls .= $html;
$html = '';
/**
*@var is a button for open/close equilibrium data
*/
$click_button = '<a href="#" class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3" onclick="J.toggleSwitch(d:this);return false;" title="' . $arr["quote"]["symbol"] . ' latest quote">🎛 Average Daily Equilibrium Forecast: ' . date('l, d F Y ⏱ H:i T', microtime(true)) . '</a>';
return '<div class="ro">' . $click_button . '<div class="di-0"><div class="p-3">' . $eq_htmls . '</div></div></div>';
/**
*
* @return a large HTML string of current quote section
*/
public static function getQuoteHTML($a)
/**
*@method gets majority of quote array parameters
*/
$quote_params = ST::getQuoteParams();
/**
*@var is the HTML for quote section of the article
*/
$html = '<div class="ro">' .
'<a href="#"' .
' class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3"' .
' onclick="J.toggleSwitch(d:this); return false;"' .
' title="' . $a["symbol"] . ' latest quote">' .
' 💹 Quote: ' . date('l, d F Y ⏱ H:i T', microtime(true)) .
'</a>' .
'<div class="di-0">' .
'<div class="p-3">';
foreach ($quote_params as $param)
$html .= '</div>' .
'</div>' .
'</div>';
return $html;
/**
*
* @return an HTML string for a chart using google chart API
*/
public static function getEquilibriumHTML($arr)
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
$candle_chart_arr = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
array_push($candle_chart_arr,
array(
$arr["c"]["c"][$k]["s"], // date
(float) substr($p["l" . $i], 1), // low support estimated
(float) substr($arr["c"]["c"][$k]["w"], 1), // VWAP market price
(float) substr($p["e" . $i], 1), // Equilibrium estimated
(float) substr($p["h" . $i], 1), // high resistance estimated
)
);
return HTMLviewEQ::getCandlestickChart(json_encode($candle_chart_arr, true));
javascript performance beginner php html
$endgroup$
This script extends the main class and generates an HTML string for user interface. You can also view the entire codes in this link.
It works okay, however would you be so kind and review it (maybe for performance) and maybe list your changes/to be changed to, if possible?
HTMLviewEQ class
date_default_timezone_set("America/New_York");
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
set_time_limit(0);
require_once __DIR__ . "/HTMLviewEQ.php";
class HTMLviewEQ extends EQ implements ConstEQ
/**
*
* @return a large HTML string of base article content including meta, abstract and written analysis
*/
public static function getBaseHTML($array, $page_id, $class_obj)
/**
*@var is the current datatime
*/
$dt = new DateTime('now');
$dt = $dt->format('Y-m-d H:i:s');
/**
*@var is the equity symbol: AAPL, AMD
*/
$symb = $array["quote"]["symbol"];
/**
*@var is the full name of public company
*/
$comp = $array["quote"]["companyName"];
/**
*@var is the name of sector: Technology, Healthcare
*/
$sect = $array["quote"]["sector"];
/**
*@var is the name of exchange market: New York Stock Exchange, CBOE, NASDAQ
*/
$mark = $array["quote"]["primaryExchange"];
/**
*@var is the first date in chart array, which is the oldest date
*/
$fd = $array["chart"][0]["date"];
/**
*@var is the last date in chart array, which is the newest date
*/
$ld = array_reverse($array["chart"])[0]["date"];
/**
*@var is the article URL
*/
$url = ConstEQ::PROTOCOL .
ConstEQ::DOMAIN .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_1 .
ConstEQ::SLASH .
ConstEQ::DIR_URL_KEYWORD_2 .
ConstEQ::SLASH . $page_id;
/**
*@var is a short meta for page about
*/
$page_about = $comp . ": Seven price sets are approximated for " . $symb . " lowest supports, " . $symb . " highest resistances and " . $symb . " equilibriums. Each price set is a forecast of daily equity price range of " . $symb . " and has a percentage indicator which shows " . $symb . " upward or downward trends in that session.";
/**
*@var is a short meta for page description
*/
$page_description = $symb . " - " . $comp . ": Average equilibrium share price forecasts are pretty important for " . $symb . " short/long trading and investing, " . $symb . " institutional trading, " . $symb . " portfolio management, " . $symb . " risk assessment, " . $symb . " algorithmic and automated trading, " . $symb . " buy/sell/hold decision makings, " . $symb . " day/swing trading, " . $symb . " put and call option forecasting, " . $symb . " volume estimating, " . $symb . " volatility approximating, " . $symb . " resistance and support evaluating, " . $symb . " stop loss computations, " . $symb . " sentiment analysis and " . $symb . " other quantitative analytics.";
$wrap_symb = '<b class="br-2 b119 r1' . rand(20, 99) . '">' . $symb . '</b>';
/**
*@var is a summary/highlight of article
*/
$article_highlight = $comp . ": Seven price sets are being approximated for " . $wrap_symb . " lowest supports, " . $wrap_symb . " average equilibriums and " . $wrap_symb . " highest resistances. Each set has a "percentage", which indicates that if " . $wrap_symb . " has been outperforming or downperforming during that day.";
/**
*@var is an abstract for the article
*/
$article_abstract = $wrap_symb . " - " . $comp . ": Equilibrium price is important for " . $wrap_symb . " institutional trading/investing, " . $wrap_symb . " retail trading/investing and other types of short/long positions. They provide supplementary perspectives to traders for " . $wrap_symb . " day/swing trading, " . $wrap_symb . " low/high frequency trading, " . $wrap_symb . " put/call option forecasting, " . $wrap_symb . " forward/reverse trading/investing and " . $wrap_symb . " algorithmic trading. Average equilibrium price is necessary for " . $wrap_symb . " Buy/Sell/Hold decision makings and " . $wrap_symb . " rating for analyst coverages and equity due diligence. They are also beneficial for " . $wrap_symb . " trading volume forecasting, " . $wrap_symb . " daily volatility approximating, " . $wrap_symb . " resistance and support evaluating, " . $wrap_symb . " stop loss calculations, among other quantitative advantages. Static charts cannot provide such information to trading and investing entities.";
/**
*@var is a legal warning for informing visitors
*/
$article_warning = "⚖ All " . $symb . " information are connected to delayed 60-seconds data pipelines from version 1.0 API at https://api.iextrading.com/1.0/, in addition to other financial and economical data. All computations are automatic, currently independent of all news, sentiments, external parameters and internal corporate factors. This page is only an alpha prototype and is only updated a few times per hour based on our dynamic indices and latest quote scraped from that API. It may not be accessible at all times, and inadvertent or unknown inaccuracies exist. All information are provided under "AT YOUR OWN FULL RISKS" and "NO LIABILITIES, UNDER NO CIRCUMSTANCES" terms. Trade Safe and Happy Investing!";
/**
*@var is a list of terms used in the articles
*/
$indicators = array(
"Equilibrium" => $wrap_symb . " equilibrium is an average theoretical price, where both buy and sell flows of " . $wrap_symb . " are equal. It is good to be taken into account in near-term trading/investing decision makings.",
"Sessions" => $wrap_symb . " data from " . sizeof($array["chart"]) . " days has been summarized here, each with eight price sets for " . $wrap_symb . ". The first set has the actual " . $wrap_symb . " market prices. The other seven sets are our estimated equilibrium prices for " . $wrap_symb . ". On the left, dynamic lowest supports of " . $wrap_symb . " have been displayed and on the right, you can see the dynamic highest resistances of " . $wrap_symb . ".",
"Volatility" => ""Low" to "extreme" volatilities have been forced to our algorithms for computing " . $wrap_symb . " supports and resistances from set 1 to set 7, respectively.",
"Percentage" => "The underneath "percentage" is an indicator of the difference in between the actual " . $wrap_symb . " and our estimated equilibrium prices for " . $wrap_symb . ".",
"Supports" => "" . $wrap_symb . " dynamic supports have been approximated as a function of time.",
"Resistances" => " " . $wrap_symb . " dynamic resistances have been also approximated as a function of time.",
"Narrow Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very close, it might indicate: (a) there may not have been much trading/investing actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " may have solid block traders/investors; OR (c) " . $wrap_symb . " might have had a low-risk and low-return session; AND (d) other similar analyses can be extracted from.",
"Distant Supports Range" => "If 7 dynamic supports of " . $wrap_symb . " are very scattered, it might indicate: (a) there might have been much sophisticated trading actions on " . $wrap_symb . "; OR (b) " . $wrap_symb . " might have had adept traders in that session; OR (c) " . $wrap_symb . " may have had a high-risk and high-return session; AND (d) other similar analyses can be obtained.",
"Narrow Resistances Range" => "If 7 dynamic resistances of " . $wrap_symb . " are very close, it may suggest outcomes such as: (a) " . $wrap_symb . " holds strong resistances that are challenging for breakouts and may require strong catalysts; OR (b) " . $wrap_symb . " may have had adept reverse traders in that session; OR (c) " . $wrap_symb . " may not have had sufficient upside actions in that session; OR (d) " . $wrap_symb . " might have had a low-risk and low-return or negative session.",
);
/**
*@var is a list of keywords for article
*/
$tags = $symb . " Stock, " . $symb . " Intraday Trading, " . $symb . " Investing, " . $symb . " Option Pricing, " . $symb . " Day Trading, " . $symb . " Swing Trading, " . $symb . " Put and Call Forecast, " . $symb . " Price Target, " . $symb . " Premarket, " . $comp . ", " . $sect . ", " . $mark;
/**
*@var is title 1 for article
*/
$page_title = $symb . " " . $comp . " Trading and Investing Equilibrium Price Analytics: " . money_format('%=4.2n', ST::getMean($array["m"]["p"])) . "
/**
* [
['Mon', 20, 28, 38, 45],
['Tue', 31, 38, 55, 66],
['Wed', 50, 55, 77, 80],
['Thu', 77, 77, 66, 50],
['Fri', 68, 66, 22, 15]
]
* @return an HTML string for a chart using google chart API
*/
public static function getCandlestickChart($arr)
$html = '<div id="chart_div" class="ro"></div>';
$html .= '<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>';
$html .= '<script type="text/javascript">';
$html .= "google.charts.load('current', 'packages':['corechart']);";
$html .= "google.charts.setOnLoadCallback(drawChart);";
$html .= "function drawChart()
var data = google.visualization.arrayToDataTable(" . $arr . ", true);
var options =
title:'Candlestick Chart: Low Support, VWAP, Equilibrium, High Resistance',
legend:'none',
selectionMode:'multiple',
agregationTarget:'category',
height:data.getNumberOfRows()*25,
orientation:'vertical',
theme:
axisTitlePosition:'in',
hAxis:titlePosition:'in',
,
tooltip:
trigger:'selection',
textStyle:
color:'#3A5FCD',
showColorCode:true,
fontSize:12,
bold:true,
isHTML:true
,
chartArea:
left:'1%',
top:50,
right:0,
bottom:75,
backgroundColor:'#333',
,
hAxis:
title:'Equity Prices',
titleTextStyle:
color:'#63B8FF',
fontSize:20,
bold:true
,
textStyle:
color:'#014B96',
fontSize:15,
bold:true
,
format:'currency'
,
vAxis:
textStyle:
color:'#8968CD',
fontSize:10,
bold:true
,
minorGridlines:
color:'#EEEE00',
count:10,
,
candlestick:
risingColor:stroke:'#EEEE00',fill:'#32CD32',
fallingColor:stroke:'#858585',fill:'#FF4500'
,
colors:['#4169E1']
;
var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
chart.draw(data, options);
</script>";
return $html;
/**
*
* @return a large HTML string of past 20 sessions equilibrium estimations with 7 volatilities
*/
public static function getMobileEquilibrium($arr)
$html = ''; // child html
$eq_htmls = ''; // parent html
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
$r = rand(0, 9);
if ($i === (sizeof($p) / 4) - 1)
$html .= '<div class="ro di-2 a120 a220 a320 a420 a520 a620 a720 sq-1 br-5 mv-5 b11' . $r . ' r100 sq-1">';
$html .= '<div class="ro tx-1 s16">' . $arr["c"]["c"][$k]["s"] . '</div>'; // session date
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="a-0" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Actual Low</b>';
$html .= '<b id="a-1" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Actual VWAP</b>';
$html .= '<b id="a-2" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Actual High</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1">' . $arr["c"]["c"][$k]["l"] . '</b>';
$html .= '<b id="b-1' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1">' . $arr["c"]["c"][$k]["w"] . '</b>';
$html .= '<b id="b-2' . $i . '" class="s18 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1">' . $arr["c"]["c"][$k]["h"] . '</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="e-0" class="s15 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Approximated Supports</b>';
$html .= '<b id="e-1" class="s15 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Estimated Equilibriums </b>';
$html .= '<b id="e-2" class="s15 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Approximated Resistances</b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i > 0 && $i < sizeof($p) / 4 - 1)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
elseif ($i === 0)
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-1 tx-0 di-1"> ' . $p["l" . $i] . ' </b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-1 tx-1 di-1"> ' . $p["e" . $i] . ' </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-1 tx-2 di-1"> ' . $p["h" . $i] . ' </b>';
$html .= '</div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720 g-3 fh-2 cu-cm"></div>';
$html .= '<div style="padding-left:' . round(44 + $p["p" . $i]) . '%;" class="ro di-1"><div class="tg-up t-19">' . round(50 + $p["p" . $i], 3) . '%</div></div>';
$html .= '<div class="ro a120 a220 a320 a420 a520 a620 a720">';
$html .= '<b id="b-0' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r18' . $r . ' mv-2 tx-0 di-1"> Lowest Lows</b>';
$html .= '<b id="b-1' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r10' . $r . ' mv-2 tx-1 di-1"> Equilibriums </b>';
$html .= '<b id="b-2' . $i . '" class="s16 a118 a218 a318 a418 a518 a618 a718 r14' . $r . ' mv-2 tx-2 di-1"> Highest Highs</b>';
$html .= '</div>';
$html .= '</div>';
else
if ($_SERVER['LOGNAME'] === ConstEQ::LOCALHOST)
HelperEQ::linePrint("OOPS! It might be sizeof($p)/4, Check the algorithm! 💔 " . ConstEQ::NEW_LINE);
continue;
$eq_htmls .= $html;
$html = '';
/**
*@var is a button for open/close equilibrium data
*/
$click_button = '<a href="#" class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3" onclick="J.toggleSwitch(d:this);return false;" title="' . $arr["quote"]["symbol"] . ' latest quote">🎛 Average Daily Equilibrium Forecast: ' . date('l, d F Y ⏱ H:i T', microtime(true)) . '</a>';
return '<div class="ro">' . $click_button . '<div class="di-0"><div class="p-3">' . $eq_htmls . '</div></div></div>';
/**
*
* @return a large HTML string of current quote section
*/
public static function getQuoteHTML($a)
/**
*@method gets majority of quote array parameters
*/
$quote_params = ST::getQuoteParams();
/**
*@var is the HTML for quote section of the article
*/
$html = '<div class="ro">' .
'<a href="#"' .
' class="s18 ro tx-1 b119 r100 t-21 p-2 br-5 mv-3"' .
' onclick="J.toggleSwitch(d:this); return false;"' .
' title="' . $a["symbol"] . ' latest quote">' .
' 💹 Quote: ' . date('l, d F Y ⏱ H:i T', microtime(true)) .
'</a>' .
'<div class="di-0">' .
'<div class="p-3">';
foreach ($quote_params as $param)
$html .= '</div>' .
'</div>' .
'</div>';
return $html;
/**
*
* @return an HTML string for a chart using google chart API
*/
public static function getEquilibriumHTML($arr)
if (is_array(array_column($arr, "m")[0]))
$ps = array_column($arr, "m")[0];
else
$ps = array();
$candle_chart_arr = array();
foreach ($ps as $k => $p)
for ($i = (sizeof($p) / 4) - 1; $i >= 0; $i--)
array_push($candle_chart_arr,
array(
$arr["c"]["c"][$k]["s"], // date
(float) substr($p["l" . $i], 1), // low support estimated
(float) substr($arr["c"]["c"][$k]["w"], 1), // VWAP market price
(float) substr($p["e" . $i], 1), // Equilibrium estimated
(float) substr($p["h" . $i], 1), // high resistance estimated
)
);
return HTMLviewEQ::getCandlestickChart(json_encode($candle_chart_arr, true));
javascript performance beginner php html
javascript performance beginner php html
asked 2 mins ago
EmmaEmma
2041215
2041215
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217467%2fuser-interface-html-string-generated-using-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217467%2fuser-interface-html-string-generated-using-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown