SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Al Greenleaf who wrote (3147)1/19/1998 10:12:00 PM
From: Jeff Grover  Read Replies (1) of 11149
 
..... the rest of it (too big for one message)

;===========================================================================

:QP_Update ; Subroutine

if(FileExist("dates retrieved.lst"))

qpfilename="none"
dates = FileOpen("dates retrieved.lst","read")
while @TRUE ; Loop till break do us end
prevqpfilename = qpfilename
qpfilename = FileRead(dates)
If qpfilename == "*EOF*" Then Break
qpfilename = StrSub(qpfilename,1,12)
; gosub getQpWebData
code=Run("%qpInstallPath%\qp_view","%qpDataPath%\incoming\%qpFileName%"); Process Files
winWaitExist("File received.",30) ; Wait for the Completed Window
SendKeysTo("File received.","{Enter}") ; Close the Window

endwhile
FileClose(dates)
FileDelete("dates retrieved.lst")

comment="QP_VIEW.EXE executed and returned RC=%code%"
GoSub AddMessageToLog

; Note: seems that return code always = one. Is this QP or
; winbatch??

code=RunWait("%qpInstallPath%\qp_proc.exe", ""); Process Files
comment="QP_PROC.EXE executed and returned RC=%code%"
GoSub AddMessageToLog

WinWaitClose("Process daily quotes")

; QP routine opened a window named MMDDYYYY.RPT - Close it.
; - This doesn't always work. Not sure why..
; Sometimes Winbatch doesn't find the window we want to close.
;
; Get list of all windows. Check for Name of NNNNNNNN.rpt
; where NNNNNNNN is an integer
; Assume only QP's window has this form. Close the window.

allwins = WinItemize()
wincount = ItemCount(allwins, @TAB)
For pos = 1 to wincount
win = ItemExtract(pos, allwins, @TAB)
date = StrSub(win, 1, 8)
rpt = StrSub(win, 9, 4)

if (rpt == ".rpt" && IsInt(date)) then
WinClose(win)
break
endif
pos = pos + 1
Next
code = 1
Return
else
code = 4
return
endif

;===========================================================================

:QP_Run_scans ; Subroutine
; Run scans against QP database

specs = FileOpen("qpday_spec1.txt","read")
while @TRUE
in_line = FileRead(specs)
If (in_line == "*EOF*") || (in_line == "SCANS:") then Break
endwhile
while @TRUE ; Loop till break do us end
in_line = FileRead(specs)
If (in_line == "*EOF*") || (in_line =="END_SCANS:") Then Break
If StrSub(in_line,1,1) != ";"
scan = ItemExtract (1, in_line, @TAB)
in_file = ItemExtract (2, in_line, @TAB)
out_file = ItemExtract (3, in_line, @TAB)
FileCopy("%qpDataPath%\LISTS\%in_file%.lst","%qpDataPath%\LISTS\in_file.lst" ,@FALSE)
code=RunWait("%qpInstallPath%\qp_scan.exe", "%scan%.scn")
FileCopy ("%qpDataPath%\LISTS\out_file.lst", "%qpDataPath%\LISTS\%out_file%.lst" ,@FALSE)
FileDelete("%qpDataPath%\LISTS\in_file.lst")
FileDelete("%qpDataPath%\LISTS\out_file.lst")
comment="QP_SCAN.EXE executed and returned RC=%code%"
GoSub AddMessageToLog
endif
endwhile
FileClose(specs)
code = 2
Return

;===========================================================================

;-----------------------------------------------------------------
:QP_Copy_files ; Subroutine
; Output files in Metastock format based on scans
; Note: Multiple scans to various directories.
;

specs = FileOpen("qpday_spec1.txt","read")
while @TRUE
in_line = FileRead(specs)
If (in_line == "*EOF*") || (in_line == "COPY:") then Break
endwhile
while @TRUE ; Loop till break do us end
in_line = FileRead(specs)
If (in_line == "*EOF*") || (in_line =="END_COPY:") Then Break
If StrSub(in_line,1,1) != ";"
src = ItemExtract (1, in_line, @TAB)
dst = ItemExtract (2, in_line, @TAB)
DataDir="%MS_DataDir%\%dst%"
ListName="%qpDataPath%\LISTS\%src%.lst" ; Export the List
; pause("%DataDir%","%ListName%")
GoSub QP_Metastock
comment="%qpDataPath%\LISTS\%src%.lst exported to %MS_DataDir%\%dst%"
GoSub AddMessageToLog
endif
endwhile
FileClose(specs)
;
; update the files in MS directory
;
Run("%qpInstallPath%\QP_META.EXE", "")
Delay(1) ; Let program start - before sending keystrokes
SendKeysTo(MSOutWin, "{Tab}{Tab}{Tab}{Enter}{Enter}")
SendKeysTo(MSOutWin, "{Tab}{Enter}")
WinClose(MSOutWin)
code = 3
Return

;===========================================================================

:QP_Metastock ;Subroutine
; Output QP data to Metastock data directories
; Requires parameters:
; DataDir - full pathname of data directory
; ListName- full pathname of list file
; CleanDir- @TRUE to start with clean Datadir
; @FALSE to just add files
;

exefile="%qpInstallPath%\QP_META.EXE"
MSOutWin="Metastock Options"
timeperstock=1 ; Allow .5 seconds per stock for Output to Metastock
; This is specific to my PC, and generous, from observation.

; Find number entries in the List file. Use this number to plan delay
fs1 = FileSize( ListName )
binbuf1 = binaryalloc( fs1 )
BinaryRead( binbuf1, ListName )
numlines = BinaryStrCnt( binbuf1, 0, fs1 - 1, @CRLF)
BinaryFree( binbuf1 )

; Set to output to single dir. Lists less than 255 for this option only....
Run(exefile, "")
Delay(1) ; Let program start - before sending keystrokes

; Output to Multiple Directories (in case more than 256 tickers)
; I don't have to care how many hits occured in a scan.
SendKeysTo(MSOutWin, "{Tab}{Enter}")
; Fill in DataDir and ListName
SendKeysTo(MSOutWin, "%DataDir%{Tab}%ListName%{Tab}{Enter}")

Delay(numlines*timeperstock) ; Allow time for transfer

WinClose(MSOutWin)

comment="%listname%.lst was exported to %dataDir%"
GoSub AddMessageToLog

Delay(1)
Return

;===========================================================================

:SetupDateFiles

TodayDate=TimeYmdHms(); Get the Date in a String
TodayYear=StrSub(TodayDate,1,2); Parse the fields from date
TodayMonth=StrSub(TodayDate,4,2);
TodayDay=StrSub(TodayDate,7,2);
Today = "%TodayMonth%%TodayDay%19%TodayYear%"

days_01=31 ;
days_02=28 ;
if(TodayYear == 4 * int( TodayYear / 4 )) then days_2 =29
days_03=31 ;
days_04=30 ;
days_05=31 ;
days_06=30 ; Specifies the number of
days_07=31 ; days in each month
days_08=31 ;
days_09=30 ;
days_10=31 ;
days_11=30 ;
days_12=31 ;

day_1 = "Sun" ;
day_2 = "Mon" ;
day_3 = "Tue" ; Names the days of the weeks
day_4 = "Wed" ;
day_5 = "Thu" ;
day_6 = "Fri" ;
day_7 = "Sat" ;

month_1 = "Jan" ;
month_2 = "Feb" ;
month_3 = "Mar" ; Names the months of the year
month_4 = "Apr" ;
month_5 = "May" ;
month_6 = "Jun" ;
month_7 = "Jul" ;
month_8 = "Aug" ;
month_9 = "Sep" ;
month_10 = "Oct" ;
month_11 = "Nov" ;
month_12 = "Dec" ;

dates = FileOpen("Last date retrieved.lst","read")
LastQuoteDate = FileRead(dates)
LastYear = StrSub(LastQuoteDate,7,2)
LastMonth = StrSub(LastQuoteDate,1,2)
LastDay = StrSub(LastQuoteDate,3,2)
LastQuoteDate = "%lastMonth%%LastDay%19%LastYear%"

if( StrLen(LastDay) == 1 ) then LastDay ="0%LastDay%"
FileClose(dates)

GetYear = LastYear
GetMonth = LastMonth
GetDay = LastDay + 1

if (LastQuoteDate != Today )
dates = FileOpen("dates to get.lst","write")
while("%GetMonth%%GetDay%19%GetYear%" != Today)
DOW = (TimeJulianDay("%GetYear%:%GetMonth%:%GetDay%") + 5 ) mod 7 + 1
if( DOW > 1 && DOW < 7)
DOW_st = day_%DOW%
FileWrite( dates, "%DOW_st% %GetMonth%/%GetDay% - %GetMonth%%GetDay%19%GetYear%.qpl" )
endif
GetDay = GetDay+1
if( StrLen(GetDay) == 1 ) then GetDay ="0%GetDay%"
if(GetDay > days_%GetMonth%)
GetDay = "01"
GetMonth = GetMonth + 1
if( StrLen(GetMonth) == 1 ) then GetMonth ="0%GetMonth%"
if( GetMonth == 13)
GetMonth = "01"
GetYear = GetYear + 1
endif
endif
endwhile

DOW = (TimeJulianDay("%GetYear%:%GetMonth%:%GetDay%") + 5 ) mod 7 + 1
if( DOW > 1 && DOW < 7)
DOW_st = day_%DOW%
FileWrite( dates, "%DOW_st% %GetMonth%/%GetDay% - %GetMonth%%GetDay%19%GetYear%.qpl" )
endif
FileClose(dates)
endif

Return

;===========================================================================
:GetQuotes

Run("%qpInstallPath%\QP_NET.EXE", "go")

if(FileExist("dates to get.lst"))

qpfilename="none"
dates = FileOpen("dates to get.lst","read")
while @TRUE ; Loop till break do us end
prevqpfilename = qpfilename
qpfilename = FileRead(dates)
If qpfilename == "*EOF*" Then Break
qpfilename = StrSub(qpfilename,13,12)
code = 0
gosub getQpWebData
endwhile

FileClose(dates)

else

qpfilename="%month%%day%19%year%.qpl"
prevqpfilename = qpfilename
;Message("single fetch", qpfilename)
;gosub getQpWebData
endif

; if (code == 200)
; dates = FileOpen("Last date retrieved.lst","write")
; FileWrite(dates,prevqpfilename)
; FileClose(dates)
; endif

return
;===========================================================================
:getQpWebData
code=0

HTTPAuth(userid,passwd)
url = "http://%webHost%/%webPath%/%qpFileName%"

; Try to get file from Host. Successful download from web server
; returns 200. You set maxConnectAttempts to support variable
; timeout.
;
attempts=0
while ((code != 200) && (attempts < maxConnectAttempts)) ; 200 = Success
;Message("Download Quotes", qpfilename)
; Display(5,"",url)
BoxDrawRect(1,"480,680,950,750",2)
BoxColor(1,LTGRAY,0) ; Light Gray no gradient
BoxDrawText(1, "480,680,500,750", "%qpFileName% : downloading", 0, 0)
code=HttpRecvFile(webHost,"%webPath%/%qpFileName%","%qpDataPath%/incoming/%qpFileName%",0)

if (code == 404)
comment="file not ready %code% : %qpFileName%"
GoSub AddMessageToLog
BoxDrawRect(1,"480,680,950,750",2)
BoxColor(1,LTGRAY,0) ; Light Gray no gradient
BoxDrawText(1, "480,680,500,750", "%qpFileName%", 0, 0)
return
endif

if (code != 200)
; Delay(180)
endif
attempts=attempts+1

if (code == 404)
; pause("Download Failure", "data not up on server yet")
status = "Data not ready (try - #%attempts%)"
BoxDrawRect(1,"480,680,950,750",2)
BoxColor(1,LTGRAY,0) ; Light Gray no gradient
BoxDrawText(1, "480,680,500,750", "%qpFileName% : #%attempts%", 0, 0)
status="not"
; return
endif
endwhile

if (code == 200)
date = FileOpen("Last date retrieved.lst","write")
FileWrite(date,qpfilename)
FileClose(date)

date = FileOpen("dates retrieved.lst","append")
FileWrite(date,qpfilename)
FileClose(date)
endif

if (code == 200)
comment="Download Web Quotes RC: %code% Attempts: %attempts%"
else
comment="WARNING: Download Web Quotes Timed out after %attempts% attempts"
endif
GoSub AddMessageToLog

return

;===========================================================================

:archQpLists ; Create Archive of Daily scan results as well as archive
; of weekly IBD YWR Lists

code=0
date=TimeYmdHms()
year=StrSub(date,1,2);
month=StrSub(date,4,2);
day=StrSub(date,7,2);

; Do Daily Stuff First
;

; Backup IBD_BBB Daily Scan
code=FileCopy("%qpDataPath%\lists\ibd_bbb.lst", "%qpListArchPath%\ibd_bbb\ibd_bbb_%month%_%day%_%year%.lst", @TRUE)

comment="RC=%code% %qpListArchPath%\ibd_bbb\ibd_bbb_%month%_%day%_%year%.lst created! "
GoSub AddMessageToLog

; Use Julian Day to easily determine day of week
; This scan only checks for monday as this is
; the day I designated for to backup my friday
; IBD list. Program assumes it is only run
; on mon-friday. no real reason to run on weekend
;
a=TimeYmdHms()
b=TimeJulianDay(a)
c=(b+5) mod 7
dayOfWeek=ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat", " ")

if (dayOfWeek=="Mon")
code=FileCopy("%qpDataPath%\lists\ibd.lst", "%qpListArchPath%\ibd\ibd_%month%_%day%_%year%.lst", @TRUE)
comment="RC=%code% %qpListArchPath%\ibd\ibd_%month%_%day%_%year%.lst created! "
GoSub AddMessageToLog
endif
return

;===========================================================================

; Simple task to append a comment to logfile
;
:AddMessageToLog
handle=fileopen(logFile, "append")
stamp=TimeDate()
filewrite(handle, "%stamp% %comment%")
fileclose(handle)
return
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext