Ejemplo n.º 1
0
    def recalculate_total(self):

        price = self.get_trade_price()
        size = self.get_trade_size()
        total = money.multiply(price, size)

        self.set_trade_total(total)
Ejemplo n.º 2
0
    def execute_trade(self):

        trade_type = self.get_selected_trade_type()

        size = self.get_trade_size()
        price = self.get_trade_price()
        total = money.multiply(price, size)

        trade_name = "BID" if trade_type == "BUY" else "ASK"

        self.status_message(
            "Placing order: {0} {1} at {2} (total {3})...".format(  # @IgnorePep8
                trade_name,
                money.to_long_string(size, self.get_base_currency()),
                money.to_long_string(price, self.get_quote_currency()),
                money.to_long_string(total, self.get_quote_currency()),
            )
        )

        if trade_type == "BUY":
            self.market.buy(price, size)
        else:
            self.market.sell(price, size)
Ejemplo n.º 3
0
 def get_quote(self, index):
     '''
     Returns the quote price for the level at the specified index.
     '''
     return money.multiply(self.get_price(index), self.get_volume(index))
Ejemplo n.º 4
0
 def get_total_quote(self, index):
     '''
     Returns the quote price for all levels up to the specified index.
     '''
     return money.multiply(self.get_price(index), self.get_total(index))
Ejemplo n.º 5
0
 def test_multiply(self):
     self.assertEqual(1000000000,
         money.multiply(200000000, 500000000))