Open bdambola opened 8 years ago
#import modules
import os
import datetime
import commands
#creating date variables
today = datetime.date.today()
trade_date = today.strftime('%Y-%m-%d')
prev = datetime.date.today()-datetime.timedelta(1)
prev_date = prev.strftime('%Y-%m-%d')
#removing yesterday's file
remove = 'rm D:\ise\\temp\ise\OCC_TRD_' + prev_date + '_CLShadow450Char.dat'
os.system(remove)
#copying current file to temp so we don't lock it
copy = 'cp D:\ise\occtr\OCC_TRD_' + today.strftime('%Y%m%d') + '_CLShadow450Char.dat D:\ise\\temp\ise'
os.system(copy)
def verify_send_to_occ(directory, filename, search_string):
#Searching for ISE OCC trade file
dir_content = os.listdir(directory)
result = False
for filename in dir_content:
print filename
#Getting results
if (filename in dir_content):
result = True
print ("\n")
occ = result
#reporting results
if occ:
print 'ISE OCC Trade file ' + filename + ' found'
print ("\n")
else:
print '!ALERT! ISE OCC Trade file not found'
print ("\n")
#Confirming trade was sent to occ
dir_content = os.listdir(directory)
result = False
for filename in dir_content:
#defining full path + file and opening it
for line in (open(directory + "/" + filename)):
#stripping out junk characters
line = line.rstrip ()
#Searching file to determine if trade was sent to OCC
if search_string in line:
result = True
trade = result
#reporting results
if trade:
print 'ISE Test trade successfully sent to OCC over the ISE MQ channel '
print ("\n")
else:
print '!ALERT! ISE Test trade not sent to OCC over the ISE MQ channel '
print ("\n")
#Calling function
addtrade = verify_send_to_occ( 'D:\ise\\temp\ise', 'D:\ise\temp\ise\OCC_TRD_' + today.strftime('%Y%m%d') + '_CLShadow450Char.dat', 'TrdDt="' + trade_date + '"')
Alert based script written in python to confirm exchange is reporting trades to OCC.