How to use the ctpwrapper.ApiStructure.ExchangeRateField.from_dict function in ctpwrapper

To help you get started, we’ve selected a few ctpwrapper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nooperpudd / ctpwrapper / tests / test_structure.py View on Github external
def test_from_dict(self):
        result = {
            "BrokerID": "45544",
            "FromCurrencyID": "4343",
            "FromCurrencyUnit": 19.0,
            "ToCurrencyID": "4334",
            "ExchangeRate": 11.0
        }
        field = ApiStructure.ExchangeRateField.from_dict(result)

        self.assertEqual(field.BrokerID, b"45544")
        self.assertEqual(field.FromCurrencyID, b"4343")
        self.assertEqual(field.FromCurrencyUnit, 19.0)
        self.assertEqual(field.ToCurrencyID, b"4334")
        self.assertEqual(field.ExchangeRate, 11.0)
github nooperpudd / ctpwrapper / tests / test_structure.py View on Github external
def test_dict_missing_parameter(self):
        result = {
            "BrokerID": "45544",

            "ToCurrencyID": "4334",
            "ExchangeRate": 11.0
        }
        field = ApiStructure.ExchangeRateField.from_dict(result)

        self.assertEqual(field.BrokerID, b"45544")
        self.assertEqual(field.FromCurrencyID, b"")
        self.assertEqual(field.FromCurrencyUnit, 0.0)
        self.assertEqual(field.ToCurrencyID, b"4334")
        self.assertEqual(field.ExchangeRate, 11.0)