This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

TCL script help - us holiday check

Help for those learning Tcl or writing their own scripts.
Post Reply
d
dutch1918
Voice
Posts: 14
Joined: Wed Jul 30, 2014 10:30 am

TCL script help - us holiday check

Post by dutch1918 »

holiday.csv format
date,name,bank holiday,TRUE or FALSE

Code: Select all

proc do_930_post {min hour day month weekday} {
	global stockchan
	if {get date,TRUE/FALSE from holiday.csv and compare to todays date if TRUE then} {
		putserv "privmsg #swingtrader :\0030,4 09:30ET\0030,12 ((( US MARKET CLOSED - US HOLIDAY ))) \017"
	} else {
		putserv "privmsg #swingtrader :\0030,4 09:30ET\0030,12 ((( US MARKET OPEN ))) \017"
	}
}
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Can you be more explicit about your need ? And about your .csv (ie date format) ?
d
dutch1918
Voice
Posts: 14
Joined: Wed Jul 30, 2014 10:30 am

Post by dutch1918 »

I finally figured it out with some help... In case someone else is looking the same thing here is the code I came up with:

holiday.csv file

Code: Select all

Dec 25	Christmas	       US Holiday	True
Jan 1	New Year's Day	US Holiday	True
Jan 19	Martin Luther King	US Holiday	True
Feb 16	Presidents Day	US Holiday	True
Apr 3	Good Friday	       US Holiday	True
May 25	Memorial Day	       US Holiday	True
Jul 3 	Independance Day	US Holiday	True
Sep 7	Labor Day	       US Holiday	True
Nov 26	Thanksgiving Day	US Holiday	True

bind cron script

Code: Select all


proc do_930_post {min hour day month weekday} {
	set holiday_file [open "holiday.csv" r]
	set holidays [list]
	while {[gets $holiday_file line] != -1} {
    	lappend holidays [lindex [split $line ,] 0]
	}
	set today [clock format [clock seconds] -timezone :America/New_York -format "%b %d"]
	lset today 1 [scan [lindex $today 1] %d]
	if {[lsearch -exact $holidays $today] > -1} {
    	putserv "privmsg #options :\0030,4 09:30ET\0030,12 ((( US MARKET CLOSED -   US HOLIDAY ))) \017"
	putserv "privmsg #marketnews :\0030,4 09:30ET\0030,12 ((( US MARKET CLOSED -   US HOLIDAY ))) \017"
	} else {
	putserv "privmsg #options :\0030,4 09:30ET\0030,12 ((( US MARKET OPEN ))) \017"
	putserv "privmsg #marketnews :\0030,4 09:30ET\0030,12 ((( US MARKET OPEN ))) \017"
Post Reply