def loop_through_optionsfiles(self, indirectory):
        import readintomemorycreateoptioninstancesfromfilelocal
        import os

        dSymbols = {}

        indir = indirectory  #'C:\Documents and Settings\jmalinchak\My Documents\My Python\Active\downloads'
        d = {}
        i = 0
        for root, dirs, filenames in os.walk(indir):
            for f in filenames:
                print(f)
                filepath = indir + '\\' + f
                if f.split(' ', 4)[0] == 'Options':
                    print(
                        'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj'
                    )
                    d1 = readintomemorycreateoptioninstancesfromfilelocal.read(
                        filepath)
                    # Symbol ########################################################
                    print(d1.Symbol)
                    if not d1.Symbol in dSymbols.values():
                        dSymbols[len(dSymbols)] = d1.Symbol
                    print('mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm')
                    #                print('Symbol: ' + str(d1.Symbol))
                    #                print('QuoteDatetime: ' + str(d1.QuoteDatetime))
                    #                print('Expiration Date: ' + str(d1.ExpirationDate))
                    #                print('Count of BucketQuoteDatetime: ' + str(d1.BucketQuoteDatetime))
                    #print('Path To File: ' + d1.PathToFile)
                    #                print('Count of PriceClassInstances: ' + str(len(d1.DictionaryOfPriceClassInstances)) + '    ' + str(d1.BucketQuoteDatetime))
                    #                print('Count of OptionSymbols: ' + str(len(d1.DictionaryOfOptionSymbols)))
                    #                print('Count of CallStrikes: ' + str(len(d1.DictionaryOfCallStrikes)))
                    #                print('Count of PutStrikes: ' + str(len(d1.DictionaryOfPutStrikes)))

                    i = i + 1
                    d[i] = d1

        #        for k1,v1 in d1.DictionaryOfPriceClassInstances.items():
        #            print("OptionSymbol=" + k1 + " Bid=" + v1.bid)
        self.DictionaryOfProcessedOptionsFiles = d
        self.DictionaryOfSymbols = dSymbols
        print(str(len(d)) + ' files processed.')
    def loop_through_optionsfiles(self,indirectory):
        import readintomemorycreateoptioninstancesfromfilelocal
        import os  
    
        dSymbols={}    
    
        indir = indirectory #'C:\Documents and Settings\jmalinchak\My Documents\My Python\Active\downloads'
        d = {}
        i = 0
        for root, dirs, filenames in os.walk(indir):
            for f in filenames:
                print(f)
                filepath = indir + '\\' + f
                if f.split(' ',4)[0] == 'Options':
                    print('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj')
                    d1 = readintomemorycreateoptioninstancesfromfilelocal.read(filepath)
                    # Symbol ########################################################
                    print(d1.Symbol)
                    if not d1.Symbol in dSymbols.values():
                        dSymbols[len(dSymbols)] = d1.Symbol
                    print('mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm')   
    #                print('Symbol: ' + str(d1.Symbol))                        
    #                print('QuoteDatetime: ' + str(d1.QuoteDatetime))
    #                print('Expiration Date: ' + str(d1.ExpirationDate))
    #                print('Count of BucketQuoteDatetime: ' + str(d1.BucketQuoteDatetime))
                    #print('Path To File: ' + d1.PathToFile)
    #                print('Count of PriceClassInstances: ' + str(len(d1.DictionaryOfPriceClassInstances)) + '    ' + str(d1.BucketQuoteDatetime))
    #                print('Count of OptionSymbols: ' + str(len(d1.DictionaryOfOptionSymbols)))
    #                print('Count of CallStrikes: ' + str(len(d1.DictionaryOfCallStrikes)))
    #                print('Count of PutStrikes: ' + str(len(d1.DictionaryOfPutStrikes)))
            
                    i =  i + 1
                    d[i] = d1
                
        #        for k1,v1 in d1.DictionaryOfPriceClassInstances.items():
        #            print("OptionSymbol=" + k1 + " Bid=" + v1.bid)
        self.DictionaryOfProcessedOptionsFiles = d
        self.DictionaryOfSymbols = dSymbols
        print(str(len(d)) + ' files processed.')

        
        #log = open(os.path.join(root, f),'r')
Пример #3
0
    def loop_through_subdirectories(self, topdirectory, showresults):
        print('Looping through subdirectories on ' + topdirectory)

        if showresults == 1:
            print(
                '111111 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 111111'
            )
        import readintomemorycreateoptioninstancesfromfilelocal
        import os
        dSymbols = {}
        d = {}

        #from os.path import join
        print('---------')
        print('     ' + 'processing files in: ')
        print('     ')
        print('     ' + topdirectory)
        print('     ')
        print('---------')
        for (topdirectory, dirs, files) in os.walk(topdirectory):
            if showresults == 1:
                print('here 1')
            for filename in files:
                if showresults == 1:
                    print('here 2')
                if filename[:7] == 'Options':
                    if showresults == 1:
                        print('here 3')
                    filepath = os.path.join(topdirectory, filename)

                    if showresults == 1:
                        print(
                            '222222 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 2222222'
                        )
                        print('filepath=' + filepath)

                    ObjectRepresentingEntireOptionFile = readintomemorycreateoptioninstancesfromfilelocal.read(
                        filepath, showresults)
                    if showresults == 1:
                        print(
                            '333333 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 333333'
                        )
                        if ObjectRepresentingEntireOptionFile.HasError == 1:
                            print(
                                '444444 readintomemoryprocessallfilesindirectorylocal.YES errors 444444'
                            )
                    if ObjectRepresentingEntireOptionFile.HasError == 0:
                        if showresults == 1:
                            print(
                                '444444 readintomemoryprocessallfilesindirectorylocal=NO errors 444444'
                            )

                        if not ObjectRepresentingEntireOptionFile.Symbol in dSymbols.values(
                        ):
                            dSymbols[len(
                                dSymbols
                            )] = ObjectRepresentingEntireOptionFile.Symbol

                        d[len(d)] = ObjectRepresentingEntireOptionFile

        self.DictionaryOfProcessedOptionsFiles = d
        self.DictionaryOfSymbols = dSymbols
        print(
            str(len(d)) +
            ' files processed via readintomemoryprocessallfilesindirectorylocal, please wait...'
        )

        #log = open(os.path.join(root, f),'r')


#    def loop_through_optionsfiles(self,indirectory,showresults):
#        print('Looping through options files, please wait...')
#        try:
#            print('111111 readintomemoryprocessallfilesindirectorylocal.loop_through_optionsfiles 111111')
#            import readintomemorycreateoptioninstancesfromfilelocal
#            import os
#
#            dSymbols={}
#
#            indir = indirectory #'C:\Documents and Settings\jmalinchak\My Documents\My Python\Active\downloads'
#            d = {}
#            i = 0
#            for root, dirs, filenames in os.walk(indir):
#                for f in filenames:
#                    if showresults == 1:
#                        print('2222222 readintomemoryprocessallfilesindirectorylocal,filepath='+ f + ' 2222222')                    #print(f)
#                    filepath = indir + '\\' + f
#                    if f.split(' ',4)[0] == 'Options':
#                        #print('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj')
#                        if showresults == 1:
#                            print('readintomemorycreateoptioninstancesfromfilelocal,filepath='+filepath)
#                        d1 = readintomemorycreateoptioninstancesfromfilelocal.read(filepath)
#
#                        # Symbol ########################################################
#                        #print(d1.Symbol)
#                        print(len(d1.DictionaryOfOptionInstances))
#
#                        if not d1.Symbol in dSymbols.values():
#                            print('rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr')
#                            print(d1.Symbol)
#                            dSymbols[len(dSymbols)] = d1.Symbol
#
#
#                        i =  i + 1
#                        d[i] = d1
#
#            #        for k1,v1 in d1.DictionaryOfPriceClassInstances.items():
#            #            print("OptionSymbol=" + k1 + " Bid=" + v1.bid)
#            self.DictionaryOfProcessedOptionsFiles = d
#            self.DictionaryOfSymbols = dSymbols
#            print(str(len(d)) + ' files processed.')
#        except ValueError as e:
#            print(str(e))
#        except Exception as e:
#            print('there was an error')
#        finally:
#            print('complete')
Пример #4
0
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  7 12:46:34 2015

@author: jmalinchak
"""

import readintomemorycreateoptioninstancesfromfilelocal
#readintomemorycreateoptioninstancesfromfilelocal.read('C:\Documents and Settings\jmalinchak\My Documents\My Python\Active\py\downloads\2015-02-04\09\45\CZR\Options CZR 2015-02-06 20150204100858.csv',1)
readintomemorycreateoptioninstancesfromfilelocal.read('C:\Documents and Settings\jmalinchak\My Documents\My Python\Active\py\downloads\2015-02-04\09\45\CZR\Options CZR 2015-03-20 20150204100904.csv',1)
    def read_option_file(self, pathfilename, showresults):

        if showresults == 1:
            print(
                '111111 readintomemoryprocessallfilesindirectorylocal.read_option_file'
            )

        import readintomemorycreateoptioninstancesfromfilelocal

        dSymbols = self.DictionaryOfSymbols
        d = self.DictionaryOfProcessedOptionsFiles
        if showresults == 1:
            print("000000", 'current count', len(d))
            print('11111X', pathfilename)

        filename = self.path_leaf(pathfilename)
        countofoptioninstances = 0
        if showresults == 1:
            print(filename)
        if filename[:7] == 'Options':
            if showresults == 1:
                print('11111Y')
            #pathfilename = pathfilename #os.path.join(topdirectory,pathfilename)

            if showresults == 1:
                print(
                    '222222 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 2222222'
                )
#____________________________
#               showresults = 1
#____________________________
            ObjectRepresentingEntireOptionFile = readintomemorycreateoptioninstancesfromfilelocal.read(
                pathfilename, showresults)

            if showresults == 1:
                print(
                    '333333 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 333333'
                )
                if ObjectRepresentingEntireOptionFile.HasError == 1:
                    print(
                        '444444 readintomemoryprocessallfilesindirectorylocal.YES errors 444444'
                    )
            if ObjectRepresentingEntireOptionFile.HasError == 0:
                countofoptioninstances = len(
                    ObjectRepresentingEntireOptionFile.
                    DictionaryOfOptionInstances)
                if showresults == 1:
                    print(
                        '444444 readintomemoryprocessallfilesindirectorylocal=NO errors 444444'
                    )

                if not ObjectRepresentingEntireOptionFile.Symbol in dSymbols.values(
                ):
                    dSymbols[len(
                        dSymbols)] = ObjectRepresentingEntireOptionFile.Symbol

                d[len(d)] = ObjectRepresentingEntireOptionFile

        self.DictionaryOfProcessedOptionsFiles = d
        self.DictionaryOfSymbols = dSymbols

        print('--', '--', '--', '--', str(len(d)), 'of',
              self.CountOfFilesFoundUnderTopDirectory, 'files processed',
              filename,
              str(countofoptioninstances) + ' instances')
    def loop_through_subdirectories(self,topdirectory,showresults):
        print('Looping through subdirectories on ' + topdirectory)
        
        if showresults==1:
            print('111111 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 111111')
        import readintomemorycreateoptioninstancesfromfilelocal        
        import os
        dSymbols={}            
        d = {}
        
        #from os.path import join
        print('---------')
        print('     ' + 'processing files in: ' )
        print('     ' )
        print('     ' + topdirectory)
        print('     ' )
        print('---------')
        for (topdirectory, dirs, files) in os.walk(topdirectory):
            if showresults == 1:
                print('here 1')
            for filename in files:
                if showresults == 1:
                    print('here 2')
                if filename[:7] == 'Options' :
                    if showresults == 1:
                        print('here 3')
                    filepath = os.path.join(topdirectory,filename)
                    
                    if showresults==1:
                        print('222222 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 2222222')
                        print('filepath='+filepath)
                        
                    ObjectRepresentingEntireOptionFile = readintomemorycreateoptioninstancesfromfilelocal.read(filepath,showresults)
                    if showresults==1:
                        print('333333 readintomemoryprocessallfilesindirectorylocal.loop_through_subdirectories 333333')
                        if ObjectRepresentingEntireOptionFile.HasError == 1:
                            print('444444 readintomemoryprocessallfilesindirectorylocal.YES errors 444444')
                    if ObjectRepresentingEntireOptionFile.HasError == 0:
                        if showresults==1:
                            print('444444 readintomemoryprocessallfilesindirectorylocal=NO errors 444444')

                        if not ObjectRepresentingEntireOptionFile.Symbol in dSymbols.values():
                            dSymbols[len(dSymbols)] = ObjectRepresentingEntireOptionFile.Symbol
                        
                        d[len(d)] = ObjectRepresentingEntireOptionFile
                
        self.DictionaryOfProcessedOptionsFiles = d
        self.DictionaryOfSymbols = dSymbols
        print(str(len(d)) + ' files processed via readintomemoryprocessallfilesindirectorylocal, please wait...')
        

        #log = open(os.path.join(root, f),'r')

#    def loop_through_optionsfiles(self,indirectory,showresults):
#        print('Looping through options files, please wait...')
#        try:
#            print('111111 readintomemoryprocessallfilesindirectorylocal.loop_through_optionsfiles 111111')
#            import readintomemorycreateoptioninstancesfromfilelocal
#            import os  
#        
#            dSymbols={}    
#        
#            indir = indirectory #'C:\Documents and Settings\jmalinchak\My Documents\My Python\Active\downloads'
#            d = {}
#            i = 0
#            for root, dirs, filenames in os.walk(indir):
#                for f in filenames:
#                    if showresults == 1:
#                        print('2222222 readintomemoryprocessallfilesindirectorylocal,filepath='+ f + ' 2222222')                    #print(f)
#                    filepath = indir + '\\' + f
#                    if f.split(' ',4)[0] == 'Options':
#                        #print('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj')
#                        if showresults == 1:
#                            print('readintomemorycreateoptioninstancesfromfilelocal,filepath='+filepath)
#                        d1 = readintomemorycreateoptioninstancesfromfilelocal.read(filepath)
#                        
#                        # Symbol ########################################################
#                        #print(d1.Symbol)
#                        print(len(d1.DictionaryOfOptionInstances))
#                        
#                        if not d1.Symbol in dSymbols.values():
#                            print('rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr')
#                            print(d1.Symbol)
#                            dSymbols[len(dSymbols)] = d1.Symbol
#    
#                
#                        i =  i + 1
#                        d[i] = d1
#                    
#            #        for k1,v1 in d1.DictionaryOfPriceClassInstances.items():
#            #            print("OptionSymbol=" + k1 + " Bid=" + v1.bid)
#            self.DictionaryOfProcessedOptionsFiles = d
#            self.DictionaryOfSymbols = dSymbols
#            print(str(len(d)) + ' files processed.')
#        except ValueError as e:
#            print(str(e))
#        except Exception as e:
#            print('there was an error')
#        finally:
#            print('complete')