smpParticipant
Average
Hi guys,
I have completed a strategy trading on the last trading day of each month but the code seems a little “clunky”, does anyone know how I can improve the code I have written to always trade on the last trading day of the month?
Area of the code to improve:
=========================
// Defines the End of Month and End of Quarter trading days.
TradingYear = 2021
JanEOM = Month=1 AND Day=29 // Friday, 29 Jan 2021
FebEOM = Month=2 AND Day=26 // Friday, 26 Feb 2021
MarEOM = Month=3 AND Day=31 // Wednesday, 31 Mar 2021
AprEOM = Month=4 AND Day=30 // Friday, 30 Apr 2021
MayEOM = Month=5 AND Day=31 // Monday, 31 May 2021
JunEOM = Month=6 AND Day=30 // Wednesday, 30 Jun 2021
JulEOM = Month=7 AND Day=30 // Friday, 30 Jul 2021
AugEOM = Month=8 AND Day=31 // Tuesday, 31 Aug 2021
SepEOM = Month=9 AND Day=30 // Thursday, 30 Sep 2021
OctEOM = Month=10 AND Day=29 // Friday, 29 Oct 2021
NovEOM = Month=11 AND Day=30 // Tuesday, 30 Nov 2021
DecEOM = Month=12 AND Day=31 // Friday, 31 Dec 2021
//EOMDate = JanEOM OR FebEOM OR AprEOM OR MayEOM OR JulEOM OR AugEOM OR OctEOM OR NovEOM
//EOQDate = MarEOM OR JunEOM OR SepEOM OR DecEOM
smpParticipant
Average
Thank you, my save hard coding each day every month. I Will still have to ensure the holidays and time differences plus daylight saving hours are put in every as PRC has no way to determine this! Or has it?
As to DST you have to account for it according to the instrument or asset traded, as there’s no way to automatically detect it.
As to holidays, well… you can’t start any trade as the market is closed. The only issue is when you want to close open positions BEFORE the holiday, in which case you will have to read a news calendar every year (they are usually available prior to December 31st) and set them manually in your code each year.
smpParticipant
Average
Thank you for your time. I have manually incorporated holidays now.