Esempio n. 1
0
 def sell_market(self, symbol: str, amount: float) -> Order:
     ticker = self.exchange.fetch_ticker(symbol)
     o = Order(self.__order_id, symbol, 'market', 'sell', amount,
               ticker['last'])
     self.__order_history.append(o)
     self.__order_id += 1
     logging.info('sell (' + str(amount) + ') at (' + str(ticker['last']) +
                  ')')
     return o
Esempio n. 2
0
 def sell_market(self, symbol: str, amount: float) -> Order:
     # Load history
     h, i = self.__load_history(symbol, self.__interval)
     # TODO Check whether amount is enough to sell
     o = Order(self.__order_id, symbol, 'market', 'sell', amount, h.iloc[i]['Open'],
               self.__current_time)
     self.__order_history.append(o)
     self.__order_id += 1
     return o
Esempio n. 3
0
    def buy_market(self, symbol: str, amount: float) -> Order:
        # Load history
        h, i = self.__load_history(symbol, self.__interval)

        # Assume market price is close to the open price of the next record
        # TODO Check whether balance is enough to buy
        o = Order(self.__order_id, symbol, 'market', 'buy', amount, h.iloc[i]['Open'],
                  self.__current_time)
        self.__order_history.append(o)
        self.__order_id += 1
        return o
Esempio n. 4
0
 def sell_limit(self, symbol: str, amount: float, price: float) -> Order:
     o = Order(self.__order_id, symbol, 'limit', 'sell', amount, price)
     self.__order_history.append(o)
     self.__order_id += 1
     logging.info('sell (' + str(amount) + ') at (' + str(price) + ')')
     return o
Esempio n. 5
0
 def sell_limit(self, symbol: str, amount: float, price: float) -> Order:
     o = Order(self.__order_id, symbol, 'limit', 'sell', amount, price, self.__current_time)
     self.__order_history.append(o)
     self.__order_id += 1
     return o