コード例 #1
0
ファイル: test_blp.py プロジェクト: ZhangSteven/blp_trade
 def testFile1(self):
     inputFile = join(get_current_path(), 'samples', 'test1.xml')
     outputTrade = join(get_current_path(), 'samples', 'output_trade1.xml')
     outputOther = join(get_current_path(), 'samples', 'output_other1.xml')
     extractTradesToXML(inputFile, outputTrade)
     extractOtherToXML(inputFile, outputOther)
     self.assertEqual(['000002', '000005', '000006'], list(extractTradeKeys(outputTrade)))
     self.assertEqual(['000002'], list(extractDeletionKeys(outputTrade)))
     self.assertEqual(['000001', '000003', '000004'], list(extractTradeKeys(outputOther)))
     self.assertEqual(['000001', '123256', '123254'], list(extractDeletionKeys(outputOther)))
コード例 #2
0
    def testTradeXML(self):
        inputFile = join(get_current_path(), 'samples',
                         'TransToGeneva20181031_morning.xml')
        outputFile = join(get_current_path(), 'output.xml')
        extractTradesToXML(inputFile, outputFile)
        self.assertEqual(loadKeys(), ['1232542018', '124351'])

        inputFile2 = join(get_current_path(), 'samples',
                          'TransToGeneva20181031_night.xml')
        extractTradesToXML(inputFile2, outputFile)

        # this time, the output file should contain only one trade. Therefore,
        # if we delete the key file, which means all trades will be extracted,
        # we should still see just one trade.
        deleteKeyFile()
        extractTradesToXML(outputFile, 'test.xml')
        self.assertEqual(loadKeys(), ['124357'])
コード例 #3
0
ファイル: test_blp.py プロジェクト: ZhangSteven/blp_trade
    def testFile2(self):
        """
        test2.xml is a super set of test1.xml, with more trades and deletions.

        But after testFile1() is called, outputTrade file should just reflect
        the incremental 40006 trades and deletions, outputOther file should 
        still reflect everything else, i.e., a super set of outputOther in
        testFile1().
        """
        inputFile = join(get_current_path(), 'samples', 'test2.xml')
        outputTrade = join(get_current_path(), 'samples', 'output_trade2.xml')
        outputOther = join(get_current_path(), 'samples', 'output_other2.xml')
        extractTradesToXML(inputFile, outputTrade)
        extractOtherToXML(inputFile, outputOther)
        self.assertEqual(['000008'], list(extractTradeKeys(outputTrade)))
        self.assertEqual(['000008', '000005'], list(extractDeletionKeys(outputTrade)))
        self.assertEqual(['000001', '000003', '000004', '000007'], list(extractTradeKeys(outputOther)))
        self.assertEqual(['000001', '123256', '123254', '000003'], list(extractDeletionKeys(outputOther)))
コード例 #4
0
ファイル: get_others.py プロジェクト: ZhangSteven/blp_trade
def outputFile():
    """
	The resulting XML file after trade extraction.
	"""
    return join(get_current_path(), 'uploads',
                'BlpOthers' + getDateString() + '.xml')
コード例 #5
0
ファイル: get_others.py プロジェクト: ZhangSteven/blp_trade
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--file', nargs='?', metavar='input file', type=str)
    parser.add_argument('--mode', nargs='?', metavar='mode', default='test')
    args = parser.parse_args()

    setDatabaseMode(args.mode)
    if args.mode == 'test':
        clearTestDatabase()  # clear test database so we can start from fresh

    if args.mode == 'production' and args.file == None:  # auto mode
        inputFile = inputFile()
        outputFile = outputFile()
    else:
        inputFile = join(get_current_path(), args.file)
        outputFile = join(get_current_path(), 'trade_output.xml')

    try:
        extractOtherToXML(inputFile, outputFile)

        # Only do upload when it's in auto mode
        if args.mode == 'production' and args.file == None:
            doUpload(outputFile)
            sendNotification(SUCCESS, outputFile)

    except:
        logger.exception('Error')

        # only send notification email on error if it is in auto mode
        if args.mode == 'production' and args.file == None:
コード例 #6
0
ファイル: get_trade.py プロジェクト: ZhangSteven/blp_trade
def outputFile():
    """
	The resulting XML file after trade extraction.
	"""
    return join(get_current_path(), 'uploads',
                'BlpTrades' + datetime.now().strftime('%Y%m%d%H%M%S') + '.xml')
コード例 #7
0
ファイル: get_trade.py プロジェクト: ZhangSteven/blp_trade
    import logging.config
    logging.config.fileConfig('logging.config', disable_existing_loggers=False)

    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--file', nargs='?', metavar='input file', type=str)
    parser.add_argument('--mode', nargs='?', metavar='mode', default='test')
    parser.add_argument('--noupload', nargs='?', metavar='whether to upload' \
         , const='Yes', default='No')
    args = parser.parse_args()
    # print(args.noupload)

    setDatabaseMode(args.mode)
    if args.mode == 'production':
        inputFile = inputFile()
    else:
        clearTestDatabase()  # clear test database so we can start from fresh
        inputFile = join(get_current_path(), args.file)

    try:
        outputFile = outputFile()
        extractTradesToXML(inputFile, outputFile)
        if args.mode == 'production' and args.noupload != 'Yes':
            doUpload(outputFile)

    except:
        logger.exception('Error')

    finally:
        closeConnection()