<html>
<head>
<style>
.freezeX{ /* is the first css */
left: 0; /* value changed when scrollX */
position: relative;
}
.row{
display: flex;
}
.row div{
border-right: 1px solid gray;
border-bottom: 1px solid gray;
flex: 0 0 100px;
word-wrap: break-word;
background-color: white;
}
.row:first-child div{
border-top: 1px solid gray;
}
.row div:first-child{
border-left: 1px solid gray;
}
.row:nth-child(even) div{
background-color: whitesmoke;
}
.row.selected div{
background-color: lightcyan;
}
.row .number {
text-align: right;
}
.row .function {
background-color: silver;
text-align: right;
}
</style>
</head>
<div class="table"></div>
<div class="words"></div>
<script>
(function() {
var script = document.createElement("script");
//script.type = "text/javascript";
script.onload = function() {
script.onload = null;
initializeTableContent();
initializeWordsContent();
freezeNameColumn();
}
document.querySelector('head').appendChild( script );
script.src = "http://hq.sinajs.cn/list=sh601668,sh601088,sh600028,sz000039,sh601939,sh601628,sh601318";
function initializeTableContent(){
var pe_ratio = function(data){ return (data[2]/data[6]).toFixed(1); };
var avg_pe_ratio = function(data){ return (data[2]/data[5]).toFixed(1); };
var div_yield = function(data){ return (data[7]/data[2]*100).toFixed(1); };
var net_price_rate = function(data){ return (data[8]/data[2]).toFixed(1); };
var price_margin_25 = function(data){ return (25*data[5]-data[2]).toFixed(1); };
var price_margin_20 = function(data){ return (20*data[6]-data[2]).toFixed(1); };
var safety_price = function(data){ return Math.min((20*data[6]).toFixed(1), (25*data[5]).toFixed(1)); };
var latest_price = function(data){ return window['hq_str_'+data[1]].split(',')[3]; };
var price_diff = function(data){ return (safety_price(data) - latest_price(data)).toFixed(1); };
var price_diff_ratio = function(data){ return (price_diff(data)/safety_price(data)*100).toFixed(1); };
var table_content = [
[ '名称', '代码', '价格 2015.12.31', '价格变动自2014.12 (%)', '每年股利支付自', '每股市场收益 2009-2015 (7年平均收益)', '每股收益 2015', '每股股利 2015', '每股净资产价值 2015', '2015 市场与收益', '2009-2015市场与收益(7年平均)', '2015股利率', '净有形资产比市价比率', '25倍(7年平均收益)-价格', '20倍(2015年收益)-价格', '安全边际价格', '最近价格', '价差', '价差比率' ],
[ '中国建筑', 'sh601668', 6.34, '', 2009, .5, .84, .2, 5.3, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
[ '中国神华', 'sh601088', 14.97, '', 2007, 1.8, .81, .32, 12.9, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
[ '中国石化', 'sh600028', 4.96, '', 2001, .6, .27, .15, 4.9, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
[ '中集集团', 'sz000039', 21, '', 2007, .8, .72, .22, 7.9, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
[ '建设银行', 'sh601939', 4.78, '', 2007, .7, .91, .274, 5.6, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
[ '中国人寿', 'sh601628', 28.31, '', 2006, .9, 1.22, .42, 11.1, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
[ '中国平安', 'sh601318', 36, '', 2006, 2.9, 2.98, .53, 16.6, pe_ratio, avg_pe_ratio, div_yield, net_price_rate, price_margin_25, price_margin_20, safety_price, latest_price, price_diff, price_diff_ratio ],
];
var table = document.querySelector('.table');
table_content.forEach(
function(row_content, index){
var newRow = document.createElement('div');
newRow.className = 'row';
if(index > 0){
addOnClickEvent(newRow);
}
row_content.forEach(
function(cell_content){
var cell = document.createElement('div');
cell.className = typeof cell_content;
if(cell.className == 'function'){
cell.innerHTML = cell_content(row_content);
} else {
cell.innerHTML = cell_content;
}
newRow.appendChild(cell);
}
);
table.appendChild(newRow);
}
);
function addOnClickEvent(element){
element.onclick = function(){
var rowElements = document.querySelectorAll('.table .row');
Array.prototype.forEach.call(rowElements,
function(rowElement){
if(rowElement.classList.contains('selected')){
rowElement.classList.remove('selected');
}
}
);
element.classList.add('selected');
};
}
}
function initializeWordsContent(){
var wrods_content = [
'每一个公司应该是大的、突出的、谨慎投资的。',
'每个公司应该具有一个长期的连续的红利支付记录。',
'联系到过去7年的平均收益,投资者应表明他愿意为一个证券所支付的价格的界限。(平均收益的25倍,并且不多于最近12月的20倍)',
'应该有适当的但不是长度的多样化,就也许意味着有最少10种和最多大约30种不同的证券。',
'',
'发现廉价的普通股有两种方法:',
'1。',
'2。把更多的注意力放在实际资产价值上,特别强调流动资产或流动资本。',
'',
'影响资本化率的因素',
'管理:',
'公平地说,一个杰出的公司会有显著的良好的管理,它显示在以往的记录中,还会显示在下一个5年的预测中,并更多的作为影响长期前景的因素出现。在另一个时间,它会带着乐观的考虑估计它的趋势,并易导致价值的高估。',
'财力和资本结构',
'大量公积金,银行贷款。债券 (偶尔地,资本过大的结构--普通股相对债券和优先股太少--也许在顺利的状态下给普通股造成巨大的“投机”利润,这就是所谓的“杠杆作用”因素)。',
'',
'股利记录',
'',
'当期股利率(p176)',
'幸运的是,大部分公司有所谓的标准股利政策。它意味着它们平均收益约2/3用于分配,除非近期高利润和通货膨胀要求更多的资本,使这个比率相对趋于降低。',
'',
];
var words = document.querySelector('.words');
wrods_content.forEach(
function(word_content){
var word = document.createElement('p');
word.innerHTML = word_content;
words.appendChild(word);
}
);
}
function freezeNameColumn(){
var rowElements = document.querySelectorAll('.table .row');
Array.prototype.forEach.call(rowElements,
function(rowElement){
var cellElements = rowElement.querySelectorAll('div');
cellElements[0].classList.add('freezeX');
}
);
var freezeXStyle = document.styleSheets[0].rules[0].style;
window.addEventListener('scroll', function(e){
freezeXStyle.left = window.scrollX;
console.log(window.scrollX);
});
}
})();
</script>
</html>
Stock Value 3
最新推荐文章于 2021-09-11 17:11:22 发布