Fix option day splits to daily Beijing 16:00 lines.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -410,27 +410,24 @@
|
|||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** OKX 期权到期:每周五 08:00 UTC(=北京 16:00) */
|
/** OKX 期权到期切日:每天 08:00 UTC(=北京 16:00),对应日期权 1/2/3 日间隔 */
|
||||||
function collectOptionExpiryBoundaries(candles) {
|
function collectOptionExpiryBoundaries(candles) {
|
||||||
if (!candles.length) return [];
|
if (!candles.length) return [];
|
||||||
const minT = Number(candles[0].time);
|
const minT = Number(candles[0].time);
|
||||||
const maxT = Number(candles[candles.length - 1].time);
|
const maxT = Number(candles[candles.length - 1].time);
|
||||||
if (!Number.isFinite(minT) || !Number.isFinite(maxT)) return [];
|
if (!Number.isFinite(minT) || !Number.isFinite(maxT)) return [];
|
||||||
|
// 北京日历日 → UTC 当天 08:00(=北京 16:00)
|
||||||
|
const minP = utcSecToBjParts(minT);
|
||||||
|
const maxP = utcSecToBjParts(maxT);
|
||||||
const out = [];
|
const out = [];
|
||||||
const cur = new Date(minT * 1000);
|
let curMs = Date.UTC(minP.y, minP.m, minP.d, 8, 0, 0) - 86400000;
|
||||||
cur.setUTCHours(0, 0, 0, 0);
|
const endMs = Date.UTC(maxP.y, maxP.m, maxP.d, 8, 0, 0) + 2 * 86400000;
|
||||||
cur.setUTCDate(cur.getUTCDate() - 1);
|
while (curMs <= endMs) {
|
||||||
const endSec = maxT + 2 * 86400;
|
const boundary = Math.floor(curMs / 1000);
|
||||||
while (cur.getTime() / 1000 <= endSec) {
|
|
||||||
if (cur.getUTCDay() === 5) {
|
|
||||||
const boundary = Math.floor(
|
|
||||||
Date.UTC(cur.getUTCFullYear(), cur.getUTCMonth(), cur.getUTCDate(), 8, 0, 0) / 1000
|
|
||||||
);
|
|
||||||
if (boundary >= minT - 3600 && boundary <= maxT + 3600) {
|
if (boundary >= minT - 3600 && boundary <= maxT + 3600) {
|
||||||
if (!out.length || out[out.length - 1] !== boundary) out.push(boundary);
|
if (!out.length || out[out.length - 1] !== boundary) out.push(boundary);
|
||||||
}
|
}
|
||||||
}
|
curMs += 86400000;
|
||||||
cur.setUTCDate(cur.getUTCDate() + 1);
|
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@
|
|||||||
<label class="market-day-split-opt" title="北京时间 8:00 交易切日竖线">
|
<label class="market-day-split-opt" title="北京时间 8:00 交易切日竖线">
|
||||||
<input type="checkbox" id="market-day-split" /> 交易间隔日
|
<input type="checkbox" id="market-day-split" /> 交易间隔日
|
||||||
</label>
|
</label>
|
||||||
<label class="market-day-split-opt" title="OKX 期权到期:每周五 08:00 UTC(北京 16:00) 黄虚线">
|
<label class="market-day-split-opt" title="OKX 期权到期切日:每天北京 16:00(UTC 08:00) 黄虚线,对应 1/2/3 日期权">
|
||||||
<input type="checkbox" id="market-option-expiry-split" /> 期权间隔日
|
<input type="checkbox" id="market-option-expiry-split" /> 期权间隔日
|
||||||
</label>
|
</label>
|
||||||
<details class="market-ind-menu">
|
<details class="market-ind-menu">
|
||||||
@@ -1396,8 +1396,8 @@
|
|||||||
|
|
||||||
<div id="toast"></div>
|
<div id="toast"></div>
|
||||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
||||||
<script src="/assets/chart_draw.js?v=20260720-option-expiry-split"></script>
|
<script src="/assets/chart_draw.js?v=20260720-option-day-1600"></script>
|
||||||
<script src="/assets/chart.js?v=20260720-option-expiry-split"></script>
|
<script src="/assets/chart.js?v=20260720-option-day-1600"></script>
|
||||||
<script src="/assets/plan.js?v=20260720-autofill"></script>
|
<script src="/assets/plan.js?v=20260720-autofill"></script>
|
||||||
<script src="/assets/calculator.js?v=20260715-calc-tabs"></script>
|
<script src="/assets/calculator.js?v=20260715-calc-tabs"></script>
|
||||||
<script src="/assets/trade_stats_calendar.js?v=3"></script>
|
<script src="/assets/trade_stats_calendar.js?v=3"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user