<?php
include_once "inc/getBasic.inc.php";
include_once "inc/getData.inc.php";
include_once "inc/postJson.inc.php";
$_REQUEST['ts_code']=$_REQUEST['ts_code']?$_REQUEST['ts_code']:'000001';
$_REQUEST['t_start']=$_REQUEST['t_start']?$_REQUEST['t_start']:'2015-01-01';
$_REQUEST['t_end']=$_REQUEST['t_end']?$_REQUEST['t_end']:date('Y-m-d');
$ts_name = tscodeToName(ts_code_conv($_REQUEST['ts_code']));
$title="股价VS融资融券余额:".$ts_name.'('.$_REQUEST['ts_code'].')';


$item = ($_REQUEST['item']=='')?'pe_ttm':$_REQUEST['item'];
$unit = '';   # Without a unit on PE
$data = getStockHist(ts_code_conv($_REQUEST['ts_code']),$_REQUEST['t_start'],$_REQUEST['t_end']);
//$data2 =
$margin=getMarginByCode();

$data2=marginByCodeReform($margin);
#var_dump($data2['data']);
$subtext_ext = "Max: ".$data2['data_max'];
$subtext_ext .= ", Min: ".$data2['data_min'];
$subtext_ext .= ", Average: ".$data2['data_avg'];
$subtext_ext .= ", Recent: ".$data2['data_last'];
$legend=array('不复权股价','融资融券余额(亿元)');
include_once "html/head.php";
?>

<form name="main" id="main" method="get"> <div style="width:100%;text-align:center">
股票代码: <input type='text' name='ts_code' id='ts_code' width="30px" value='<?=$_REQUEST['ts_code']?>' >
开始时间: <input type='date' name='t_start' id='t_start' width='30px' value='<?=$_REQUEST['t_start']?>' >
结束时间: <input type='date' name='t_end' id='t_end' width='30px' value='<?=$_REQUEST['t_end']?>' >
<input type='submit' value="给我查!">
<div >&nbsp;</div>

</div> </form>
<div >&nbsp;</div>
<div id="container" style="margin:0 auto;height: 400px;width: 1000px"></div>
<script type="text/javascript">
    var data1 = <?php echo json_encode($data['data']); ?>;
    var data2 =<?php echo json_encode($data2['data']); ?>;
    var legend = <?php echo json_encode($legend);?>;
    var unit ='<?php echo $unit; ?>';
    var headtxt = '<?php echo $ts_name.'('.$_REQUEST['ts_code'].')'; ?>';
    var subtxt = '<?php echo $subtext_ext; ?>';
</script>
<script type="text/javascript" src="js/chartmargin.js?version=3.15"></script>
<?php include_once "html/footer.php"; ?>

