Ejemplo n.º 1
0
    def testValidateBal2(self):
        file = join(get_current_path(), 'samples', 'CLM BAL 2018-05-31.xls')
        records, summary = readFile(file)
        equityRecords = list(filter(equity, records))
        self.assertEqual(len(equityRecords), 26)

        record = equityRecords[17]
        self.assertEqual(record['ticker'], '6886 HK')
        self.assertEqual(record['quantity'], 60000)
Ejemplo n.º 2
0
def open_dif(inputFile, portValues, outputDir, prefix):
    """
	Read an input file, write 3 output csv files, namely,

		1. HTM positions
		2. AFS positions
		3. cash

	the output file should be written to outputDir, and output file
	names should follow the below convention:

	<prefix>_yyyy-mm-dd_cash.csv
	<prefix>_yyyy-mm-dd_afs_positions.csv
	<prefix>_yyyy-mm-dd_htm_positions.csv

	output: return 3 string, for the full file path to the 3 output csv files.
	side effect: populate the portValues dictionary with 

	The interface is exactly the same as the old DIF package's
	open_dif.open_dif() function, to replace it.
	"""
    from os.path import join
    records, summary = readFile(inputFile)
    portfolioId = records[0]['portfolio']
    valuationDate = records[0]['valuation_date']

    if portfolioId == '19437':
        prefix = 'DIF_'

    cashCsvFile = join(outputDir, prefix + valuationDate + '_cash.csv')
    afsCsvFile = join(outputDir, prefix + valuationDate + '_afs_positions.csv')
    htmCsvFile = join(outputDir, prefix + valuationDate + '_htm_positions.csv')

    writeCashCsv(cashCsvFile, records)
    writeAfsCsv(afsCsvFile, records)
    writeHtmCsv(htmCsvFile, records)

    portValues['valuation_date'] = valuationDate
    portValues['portfolio'] = portfolioId
    for key in ['nav', 'number_of_units', 'unit_price']:
        portValues[key] = summary[key]

    return [cashCsvFile, afsCsvFile, htmCsvFile]
Ejemplo n.º 3
0
 def getRecordsGnt():
     file = join(get_current_path(), 'samples', 'CLM GNT 2017-10-25.xls')
     return readFile(file)
Ejemplo n.º 4
0
 def getRecordsBal():
     file = join(get_current_path(), 'samples', 'CLM BAL 2017-07-27.xls')
     return readFile(file)
Ejemplo n.º 5
0
 def getRecords():
     file = join(get_current_path(), 'samples',
                 'CL Franklin DIF 2018-05-28(2nd Revised).xls')
     return readFile(file)