コード例 #1
0
    def test_get_btcusdt_when_loaded_returns_expected_instrument(self):
        # Arrange
        mock_client = MagicMock()
        mock_client.name = "Binance"

        with open(TEST_PATH + "res_instruments.json") as response:
            instruments = json.load(response)

        mock_client.markets = instruments

        provider = BinanceInstrumentProvider(client=mock_client)
        provider.load_all()

        symbol = Symbol("BTC/USDT", Venue("BINANCE"))

        # Act
        instrument = provider.get(symbol)

        # Assert
        self.assertEqual(Instrument, type(instrument))
        self.assertEqual(AssetClass.CRYPTO, instrument.asset_class)
        self.assertEqual(AssetType.SPOT, instrument.asset_type)
        self.assertEqual(BTC, instrument.base_currency)
        self.assertEqual(USDT, instrument.quote_currency)
        self.assertEqual(USDT, instrument.settlement_currency)
コード例 #2
0
    def test_load_all(self):
        # Arrange
        mock_client = MagicMock()
        mock_client.name = "Binance"

        with open(TEST_PATH + "res_instruments.json") as response:
            instruments = json.load(response)

        mock_client.markets = instruments

        provider = BinanceInstrumentProvider(client=mock_client)

        # Act
        provider.load_all()

        # Assert
        self.assertTrue(provider.count > 0)  # No exceptions raised
コード例 #3
0
    def test_get_all_when_loaded_returns_instruments(self):
        # Arrange
        mock_client = MagicMock()
        mock_client.name = "Binance"

        with open(TEST_PATH + "res_instruments.json") as response:
            instruments = json.load(response)

        mock_client.markets = instruments

        provider = BinanceInstrumentProvider(client=mock_client)
        provider.load_all()

        # Act
        instruments = provider.get_all()

        # Assert
        self.assertTrue(len(instruments) > 0)
        self.assertEqual(dict, type(instruments))
        self.assertEqual(Symbol, type(next(iter(instruments))))