COCO研究院

 找回密碼
 註冊
搜索
查看: 3519|回復: 2

[範例程式碼] 結算日前一天的下午

[複製鏈接]
發表於 17-9-17 21:13 | 顯示全部樓層 |閱讀模式
我指香港指數期貨:

假設下一個星期一是假期 (及假期已可在 quotemanager 查到), 星期二是期貨結算日, 目標是在結算日前一交易日(即星期五)下午四時把所有合約平倉

這需要一 function 能決定輸入日期是否假期, multicharts 能否做到?
發表於 17-9-19 16:16 | 顯示全部樓層
也許你可以試試 IsWorkDay()
 樓主| 發表於 17-9-29 15:33 | 顯示全部樓層
寫了這段程式:
   if isworkday(stringtodate("23/09/2017")) then  
   messagelog("isworkday(23/09/2017) is true");
   if isworkday(stringtodate("24/09/2017")) then
   messagelog("isworkday(24/09/2017) is true");
   if isworkday(stringtodate("25/09/2017")) then
   messagelog("isworkday(25/09/2017) is true");
   if isworkday(stringtodate("26/09/2017")) then
   messagelog("isworkday(26/09/2017) is true");
   if isworkday(stringtodate("27/09/2017")) then
   messagelog("isworkday(27/09/2017) is true");
   if isworkday(stringtodate("28/09/2017")) then
   messagelog("isworkday(28/09/2017) is true");
   if isworkday(stringtodate("29/09/2017")) then
   messagelog("isworkday(29/09/2017) is true");
   if isworkday(stringtodate("30/09/2017")) then
   messagelog("isworkday(30/09/2017) is true");
   if isworkday(stringtodate("01/10/2017")) then
   messagelog("isworkday(01/10/2017) is true");   
   if isworkday(stringtodate("02/10/2017")) then
   messagelog("isworkday(02/10/2017) is true");   
   if isworkday(stringtodate("03/10/2017")) then
   messagelog("isworkday(03/10/2017) is true");   
   if isworkday(stringtodate("04/10/2017")) then
   messagelog("isworkday(04/10/2017) is true");      
   if isworkday(stringtodate("05/10/2017")) then
   messagelog("isworkday(05/10/2017) is true");      
   if isworkday(stringtodate("06/10/2017")) then
   messagelog("isworkday(06/10/2017) is true");      
   if isworkday(stringtodate("07/10/2017")) then
   messagelog("isworkday(07/10/2017) is true");  

結果是 (我在香港, 是 default UK regional format):
isworkday(23/09/2017) is true
isworkday(24/09/2017) is true
isworkday(25/09/2017) is true
isworkday(28/09/2017) is true
isworkday(29/09/2017) is true
isworkday(30/09/2017) is true
isworkday(01/10/2017) is true
isworkday(02/10/2017) is true
isworkday(05/10/2017) is true
isworkday(06/10/2017) is true
isworkday(07/10/2017) is true

為何星期二, 三, 便是 false?
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-4-27 12:03

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook