Example #1
0
 def setUp(self) -> None:
     super().setUp()
     self.base = "HBOT"
     self.quote = "COINALPHA"
     self.trading_pair = f"{self.base}-{self.quote}"
     self.exchange = PerpetualFinanceDerivative(
         trading_pairs=[self.trading_pair],
         wallet_private_key="someKey",
         ethereum_rpc_url="someUrl",
     )
Example #2
0
class PerpetualFinanceDerivativeTest(unittest.TestCase):
    def setUp(self) -> None:
        super().setUp()
        self.base = "HBOT"
        self.quote = "COINALPHA"
        self.trading_pair = f"{self.base}-{self.quote}"
        self.exchange = PerpetualFinanceDerivative(
            trading_pairs=[self.trading_pair],
            wallet_private_key="someKey",
            ethereum_rpc_url="someUrl",
        )

    def test_get_buy_and_sell_collateral_token(self):
        buy_collateral_token = self.exchange.get_buy_collateral_token(self.trading_pair)
        sell_collateral_token = self.exchange.get_sell_collateral_token(self.trading_pair)

        self.assertEqual(self.quote, buy_collateral_token)
        self.assertEqual(self.quote, sell_collateral_token)
 def setUpClass(cls):
     cls.ev_loop = asyncio.get_event_loop()
     cls.clock: Clock = Clock(ClockMode.REALTIME)
     cls.connector: PerpetualFinanceDerivative = PerpetualFinanceDerivative(
         [trading_pair], "PRIVATE_KEY_HERE", "")
     print(
         "Initializing PerpetualFinanceDerivative market... this will take about a minute."
     )
     cls.connector.set_leverage(trading_pair, leverage)
     cls.connector.set_position_mode(PositionMode.ONEWAY)
     cls.clock.add_iterator(cls.connector)
     cls.stack: contextlib.ExitStack = contextlib.ExitStack()
     cls._clock = cls.stack.enter_context(cls.clock)
     cls.ev_loop.run_until_complete(cls.wait_til_ready())
     print("Ready.")
 async def xdai_balances() -> Dict[str, Decimal]:
     connector = PerpetualFinanceDerivative("",
                                            get_eth_wallet_private_key(),
                                            "", True)
     await connector._update_balances()
     return connector.get_all_balances()