Beispiel #1
0
 def test_create_rf_when_trade_type_is_not_set(self):
     rp = RecordProcessor({'TradeType': "", 'Trade ID': "", 'Msg Type': ""})
     rp.create_rf()
     self.assertEquals(
         "'Msg Type': 'Valid Msg Types are New,Edit,Cancel', 'Trade ID': 'must be specified', 'TradeType': 'Valid values for TradeType are [Vanilla]'",
         rp.errors)
     self.assertEquals(None, rp._rf)
 def test_create_rf_will_fail_when_msg_type_is_new_and_id_aleady_exists(self):
     rec1 = get_record({"Quantity": 100, "Price":22,"Trade ID":"ZZSDZCX"})
     RecordProcessor(rec1).process()
     rp = RecordProcessor({'TradeType':"Vanilla", 'Trade ID':"ZZSDZCX", 'Msg Type':"new" })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Trade ID already exists'", rp.errors)
     self.assertEquals(None, rp._rf)
 def test_validate_record_when_missing_fields(self):
     rec = get_record({"Quantity": 100, "Price":123})
     del rec['Instrument']
     del rec['Fund']
     rp = RecordProcessor(rec)
     rp.process()
     self.assertEquals( "'Currency': 'Not set', 'Fund': 'Not set'",  rp.errors)
Beispiel #4
0
 def test_validate_record_when_missing_fields(self):
     rec = get_record({"Quantity": 100, "Price": 123})
     del rec['Instrument']
     del rec['Fund']
     rp = RecordProcessor(rec)
     rp.process()
     self.assertEquals("'Currency': 'Not set', 'Fund': 'Not set'",
                       rp.errors)
Beispiel #5
0
 def test_create_rf_will_fail_when_msg_type_is_cancel_and_id_does_not_exists(
         self):
     rp = RecordProcessor({
         'TradeType': "Vanilla",
         'Trade ID': "-ZZSDZCX",
         'Msg Type': "cancel"
     })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Trade ID does not exist'", rp.errors)
     self.assertEquals(None, rp._rf)
Beispiel #6
0
 def test_create_rf_when_invalid_action(self):
     rp = RecordProcessor({
         'TradeType': "Vanilla",
         'Trade ID': "123",
         'Msg Type': "Invalid"
     })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Valid Msg Types are New,Edit,Cancel'",
                       rp.errors)
     self.assertEquals(None, rp._rf)
Beispiel #7
0
 def test_create_rf_when_invalid_trade_type(self):
     rp = RecordProcessor({
         'TradeType': "Invalid",
         'Trade ID': "123",
         'Msg Type': "new"
     })
     rp.create_rf()
     self.assertEquals(
         "'TradeType': 'Valid values for TradeType are [Vanilla]'",
         rp.errors)
     self.assertEquals(None, rp._rf)
 def test_populate_rf_maps_fields_and_records_errors(self):
     rec = get_record({"Quantity": 'ABC', "Price":123,"Fund":"Invalid",  "Trade Date":"2015-13-01"})
     rp = RecordProcessor(rec)
     rp.create_rf()
     rp.populate_rf()
     rf = rp._rf
     self.assertEquals( None, rf.get_value('quantity' ))
     self.assertEquals( 123, rf.get_value('price' ))
     self.assertEquals( "Buy", rf.get_value('action' ))
     self.assertEquals( "BAC.N", rf.get_value('instrument' ))
     self.assertEquals( "USD", rf.get_value('currency'))
     self.assertEquals( None, rf.get_value('trade_date' ))
     self.assertEquals( None, rf.get_value('settle_date' ))
     self.assertEquals( "Invalid", rf.get_value('fund' ))        
     expect = "'Quantity': 'Invalid value >ABC< needs to be Numeric', 'Trade Date': 'Invalid value >2015-13-01< needs to be YYYY-MM-DD format'"
     self.assertEquals(expect,  rp.errors )
Beispiel #9
0
 def test_create_rf_will_fail_when_msg_type_is_new_and_id_aleady_exists(
         self):
     rec1 = get_record({
         "Quantity": 100,
         "Price": 22,
         "Trade ID": "ZZSDZCX"
     })
     RecordProcessor(rec1).process()
     rp = RecordProcessor({
         'TradeType': "Vanilla",
         'Trade ID': "ZZSDZCX",
         'Msg Type': "new"
     })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Trade ID already exists'", rp.errors)
     self.assertEquals(None, rp._rf)
    def test_delete_will_delete_the_trade(self):
        rec1 = get_record({"Quantity": 100, "Price":22,"Trade ID":"ZZSDZCY", 'Msg Type':"new" })
        RecordProcessor(rec1).process()
        rp = RecordProcessor({'TradeType':"Vanilla", 'Trade ID':"ZZSDZCY", 'Msg Type':"cancel" })
        rp.process()
        self.assertEquals("", rp.errors)

        rp = RecordProcessor({'TradeType':"Vanilla", 'Trade ID':"ZZSDZCY", 'Msg Type':"edit" })
        rp.process()
        self.assertEquals("'Msg Type': 'Trade ID does not exist'", rp.errors)
Beispiel #11
0
    def test_delete_will_delete_the_trade(self):
        rec1 = get_record({
            "Quantity": 100,
            "Price": 22,
            "Trade ID": "ZZSDZCY",
            'Msg Type': "new"
        })
        RecordProcessor(rec1).process()
        rp = RecordProcessor({
            'TradeType': "Vanilla",
            'Trade ID': "ZZSDZCY",
            'Msg Type': "cancel"
        })
        rp.process()
        self.assertEquals("", rp.errors)

        rp = RecordProcessor({
            'TradeType': "Vanilla",
            'Trade ID': "ZZSDZCY",
            'Msg Type': "edit"
        })
        rp.process()
        self.assertEquals("'Msg Type': 'Trade ID does not exist'", rp.errors)
Beispiel #12
0
 def test_populate_rf_maps_fields_and_records_errors(self):
     rec = get_record({
         "Quantity": 'ABC',
         "Price": 123,
         "Fund": "Invalid",
         "Trade Date": "2015-13-01"
     })
     rp = RecordProcessor(rec)
     rp.create_rf()
     rp.populate_rf()
     rf = rp._rf
     self.assertEquals(None, rf.get_value('quantity'))
     self.assertEquals(123, rf.get_value('price'))
     self.assertEquals("Buy", rf.get_value('action'))
     self.assertEquals("BAC.N", rf.get_value('instrument'))
     self.assertEquals("USD", rf.get_value('currency'))
     self.assertEquals(None, rf.get_value('trade_date'))
     self.assertEquals(None, rf.get_value('settle_date'))
     self.assertEquals("Invalid", rf.get_value('fund'))
     expect = "'Quantity': 'Invalid value >ABC< needs to be Numeric', 'Trade Date': 'Invalid value >2015-13-01< needs to be YYYY-MM-DD format'"
     self.assertEquals(expect, rp.errors)
 def test_validate_record_when_all_is_good(self):
     rec = get_record({"Quantity": 100, "Price":123})
     rp = RecordProcessor(rec)
     rp.process()
     self.assertEquals('', rp.errors)
 def build_csv(cls, file_name):
     models = RecordProcessor.model_list()
     fields = RecordProcessor.FIELD_MAP
     records = cls.get_data_table(fields, models)
     CSVTradeLoader.write_csv(file_name, cls.get_headers(models), records)
 def test_create_rf_from_trade_type(self):
     rec = get_record({})
     rp = RecordProcessor(rec)
     rp.create_rf()
     self.assertEquals(VanillaModel, rp._rf.model.__class__)
Beispiel #16
0
 def get_processor(cls):
     rp = RecordProcessor(get_record({}))
     rp.create_rf()
     rp._rf = cls(rp._rf)
     return rp
 def test_get_model_from_trade_type(self):
     self.assertEquals(VanillaModel, RecordProcessor.get_model("Vanilla"))
     self.assertEquals(VanillaModel, RecordProcessor.get_model("vaNiLla"))
     self.assertEquals(None, RecordProcessor.get_model("Undefined"))
 def get_processor(cls):
     rp = RecordProcessor(get_record({}))
     rp.create_rf()
     rp._rf = cls(rp._rf)
     return rp
Beispiel #19
0
 def test_list_of_models(self):
     self.assertEquals([VanillaModel], RecordProcessor.model_list())
 def test_list_of_models(self):
     self.assertEquals([VanillaModel], RecordProcessor.model_list())
Beispiel #21
0
 def test_get_model_from_trade_type(self):
     self.assertEquals(VanillaModel, RecordProcessor.get_model("Vanilla"))
     self.assertEquals(VanillaModel, RecordProcessor.get_model("vaNiLla"))
     self.assertEquals(None, RecordProcessor.get_model("Undefined"))
 def test_create_rf_will_fail_when_msg_type_is_cancel_and_id_does_not_exists(self):
     rp = RecordProcessor({'TradeType':"Vanilla", 'Trade ID':"-ZZSDZCX", 'Msg Type':"cancel" })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Trade ID does not exist'", rp.errors)
     self.assertEquals(None, rp._rf)
 def test_create_rf_when_invalid_trade_type(self):
     rp = RecordProcessor({'TradeType':"Invalid", 'Trade ID':"123", 'Msg Type':"new" })
     rp.create_rf()
     self.assertEquals("'TradeType': 'Valid values for TradeType are [Vanilla]'", rp.errors)
     self.assertEquals(None, rp._rf)
 def test_create_rf_when_invalid_action(self):
     rp = RecordProcessor({'TradeType':"Vanilla", 'Trade ID':"123", 'Msg Type':"Invalid" })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Valid Msg Types are New,Edit,Cancel'", rp.errors)
     self.assertEquals(None, rp._rf)
 def test_create_rf_when_trade_type_is_not_set(self):
     rp = RecordProcessor({'TradeType':"", 'Trade ID':"", 'Msg Type':"" })
     rp.create_rf()
     self.assertEquals("'Msg Type': 'Valid Msg Types are New,Edit,Cancel', 'Trade ID': 'must be specified', 'TradeType': 'Valid values for TradeType are [Vanilla]'", rp.errors)
     self.assertEquals(None, rp._rf)
Beispiel #26
0
 def test_validate_record_when_all_is_good(self):
     rec = get_record({"Quantity": 100, "Price": 123})
     rp = RecordProcessor(rec)
     rp.process()
     self.assertEquals('', rp.errors)
Beispiel #27
0
 def test_create_rf_from_trade_type(self):
     rec = get_record({})
     rp = RecordProcessor(rec)
     rp.create_rf()
     self.assertEquals(VanillaModel, rp._rf.model.__class__)