160 lines
6.9 KiB
Plaintext
160 lines
6.9 KiB
Plaintext
@model TradeAutoRule
|
|
|
|
@{
|
|
ViewBag.Title = "自动对冲规则";
|
|
Layout = "~/Views/Shared/_InfoLayout.cshtml";
|
|
}
|
|
|
|
@section JS{
|
|
<script src="@HtmlUtil.BasicDataJs("标的Live")"></script>
|
|
<script>
|
|
function saveAutoRule() {
|
|
var data = { MaxDelta: 0, MinDelta: 0, DeltaPercent: 0, PnlAdjust: 0 };
|
|
for (var key in data) {
|
|
var $e = $("#autoRule" + key);
|
|
var val = parseFloat($e.val() || '0');
|
|
if (isNaN(val)) {
|
|
main.alert($e.closest('td').prev().text() + " 请填写数字");
|
|
return;
|
|
}
|
|
data[key] = val;
|
|
}
|
|
|
|
if (data.MaxDelta < 0) {
|
|
main.alert("'上限Delta'请填写正数");
|
|
return;
|
|
}
|
|
|
|
if (data.MinDelta > 0) {
|
|
main.alert("'下限Delta'请填写负数");
|
|
return;
|
|
}
|
|
|
|
if (data.DeltaPercent < 0 || data.DeltaPercent > 200) {
|
|
main.alert("'对冲比率'请填写0到200(包括)之间的数字");
|
|
}
|
|
|
|
data.UnderlyingCode = $('#autoRuleUnderlyingCode').val();
|
|
data.PnlAdjustType = $('#autoRulePnlAdjustType').val();
|
|
data.Enable = $('#autoRuleEnable').prop("checked");
|
|
data.AutoExecute = $('#autoRuleAutoExecute').prop("checked");
|
|
|
|
main.post("/trade_autorule/AjaxSave", data).done(function (res) {
|
|
if (typeof window.parent.setRules === 'function')
|
|
window.parent.setRules(res.obj, !data.Enable);
|
|
});
|
|
}
|
|
|
|
$(function () {
|
|
var suggestions = [];
|
|
_.each(ylotc.underlyings, function (item) {
|
|
suggestions.push({ value: item.Code, data: item.Code });
|
|
});
|
|
$('#autoRuleUnderlyingCode').autocomplete({
|
|
lookup: suggestions,
|
|
onSelect: function (suggestion) {
|
|
var code = suggestion.value;
|
|
if ($('#autoRuleUnderlyingCode').data('suggestion') === code) {
|
|
return;
|
|
}
|
|
$('#autoRuleUnderlyingCode').data('suggestion',code);
|
|
$.post("/trade_autorule/AjaxGetDetail", { code: code }).done(function (resp) {
|
|
if (!resp.id) {
|
|
resp = { "MaxDelta": 25, "MinDelta": -25, "Enable": true, "AutoExecute": false,"DeltaPercent": 100, "PnlAdjust": 0, "PnlAdjustType": "固定" };
|
|
}
|
|
$('#autoRuleMaxDelta').val(resp.MaxDelta);
|
|
$('#autoRuleMinDelta').val(resp.MinDelta);
|
|
$('#autoRuleDeltaPercent').val(resp.DeltaPercent);
|
|
$('#autoRulePnlAdjust').val(resp.PnlAdjust);
|
|
$('#autoRulePnlAdjustType').val(resp.PnlAdjustType);
|
|
$('#autoRuleEnable').prop('checked', resp.Enable);
|
|
$('#autoRuleAutoExecute').prop('checked', resp.AutoExecute);
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
|
|
@section CSS{
|
|
<style>
|
|
.container{max-width:100%;}
|
|
.table-autorule > tbody > tr > td { text-align: left; }
|
|
.form-autorule { max-width: 200px; display: inline; margin-right: 4px; }
|
|
.form-check { width: 19px; height: 19px; vertical-align: bottom; margin-right: 2px !important; }
|
|
.autocomplete-suggestions { overflow: auto; border: 1px solid #CBD3DD; background: #FFF; }
|
|
.autocomplete-suggestion { overflow: hidden; padding: 5px 15px; white-space: nowrap; }
|
|
.autocomplete-selected { background: #F0F0F0; }
|
|
.autocomplete-suggestions strong { color: #029cca; font-weight: normal; }
|
|
</style>
|
|
}
|
|
|
|
<form id="formAutoRule" method="post" onsubmit="return false;" autocomplete="off">
|
|
|
|
<table class="table table-noborder table-autorule" style="width:100%;">
|
|
<colgroup>
|
|
<col span="1" width="120" />
|
|
<col span="1" />
|
|
</colgroup>
|
|
<tbody>
|
|
<tr>
|
|
<th>标的代码:</th>
|
|
<td>
|
|
@if (string.IsNullOrEmpty(Model.UnderlyingCode))
|
|
{
|
|
<input type="text" name="UnderlyingCode" id="autoRuleUnderlyingCode" value="@(Model.UnderlyingCode)" class="form-control form-autorule" />
|
|
}
|
|
else
|
|
{
|
|
<strong>@(Model.UnderlyingCode)</strong>
|
|
<input type="hidden" name="UnderlyingCode" id="autoRuleUnderlyingCode" value="@(Model.UnderlyingCode)" />
|
|
}
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>上限Delta:</td>
|
|
<td><input type="text" name="MaxDelta" id="autoRuleMaxDelta" value="@(Model.MaxDelta)" class="form-control form-autorule" />%</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>下限Delta:</td>
|
|
<td><input type="text" name="MinDelta" id="autoRuleMinDelta" value="@(Model.MinDelta)" class="form-control form-autorule" />%</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>Delta对冲比率:</td>
|
|
<td>
|
|
<input type="text" name="DeltaPercent" id="autoRuleDeltaPercent" value="@(Model.DeltaPercent)" class="form-control form-autorule" />%(0~200)
|
|
</td>
|
|
</tr>
|
|
|
|
@*<tr>
|
|
<td>盈亏调整幅度:</td>
|
|
<td>
|
|
<input type="text" name="PnlAdjust" id="autoRulePnlAdjust" value="@(Model.PnlAdjust)" class="form-control form-autorule" />
|
|
<select name="PnlAdjustType" id="autoRulePnlAdjustType" class="form-control" style="display:inline;width:70px;height:auto;">
|
|
<option value="固定" @(Model.PnlAdjustType == "固定" ? "selected" : "")>固定</option>
|
|
<option value="比例" @(Model.PnlAdjustType == "比例" ? "selected" : "")>比例</option>
|
|
</select>
|
|
</td>
|
|
</tr>*@
|
|
|
|
<tr>
|
|
<td></td>
|
|
<td>
|
|
<label><input type="checkbox" class="form-check" name="Enable" id="autoRuleEnable" @(Model.Enable ? "checked" : "") />激活使用</label>
|
|
<span style="margin-left:15px;"></span>
|
|
<label><input type="checkbox" class="form-check" name="AutoExecute" id="autoRuleAutoExecute" @(Model.AutoExecute ? "checked" : "") />自动执行</label>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td colspan="2" style="padding:20px 0 0 120px;">
|
|
<button type="button" class="btn btn-primary" onclick="saveAutoRule()">保存</button>
|
|
<button type="button" class="btn btn-primary" onclick="layer.closeMe()">关闭</button>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</form> |