def __init__(self, trade_info=None): if not trade_info == None: self.market = trade_info['market'] self.base_currency, self.quote_currency, self.exchange_name = self.market.split('_') self.exchange = Exchange(self.exchange_name) self.currency_pair = self.base_currency+'_'+self.quote_currency self.time = trade_info['time'] self.total = trade_info['total'] self.score = trade_info['score'] self.snapshot = trade_info['snapshot'] self.walls = trade_info['walls'] self.price = trade_info['price'] self.order_type = trade_info['order_type']
class Trade: def __init__(self, trade_info=None): if not trade_info == None: self.market = trade_info['market'] self.base_currency, self.quote_currency, self.exchange_name = self.market.split('_') self.exchange = Exchange(self.exchange_name) self.currency_pair = self.base_currency+'_'+self.quote_currency self.time = trade_info['time'] self.total = trade_info['total'] self.score = trade_info['score'] self.snapshot = trade_info['snapshot'] self.walls = trade_info['walls'] self.price = trade_info['price'] self.order_type = trade_info['order_type'] def was_executable(self): self.exchange.get_trades(self.currency_pair, start_time=self.time, end_time=datetime.datetime.now()) trades = self.exchange.markets[self.currency_pair]['trades']['all'] executable_trades = (trades.rate <+ self.price) if self.order_type == 'buy' else (trades.rate >= self.price) executable_volumes = (trades.total > self.total) was_executable = True if len(trades[executable_trades & executable_volumes]) > 0 else False return was_executable def was_profitable(self): self.exchange.get_trades(self.currency_pair, start_time=self.time, end_time=datetime.datetime.now()) trades = self.exchange.markets[self.currency_pair]['trades']['all'] profitable_trades = (trades.rate > self.price) if self.order_type == 'buy' else (trades.rate < self.price) executable_volumes = (trades.total > self.total) was_profitable= True if len(trades[profitable_trades & executable_volumes]) > 0 else False return was_profitable def compare_currentz_market_state(self): pass
def exchange(): return Exchange('Bittrex', 'a2cd9645fdb44078b1c18ca4581c747b', '83ca8a8e6a5440a5acbd26f9698c12b1')