def run(self): log_content = "" # A_prices,B_prices = self._get_prices_for_test() A_prices,B_prices = self._get_prices() log_content += self._ex_A.name() + ":" + str(A_prices) + "\n" log_content += self._ex_B.name() + ":" + str(B_prices) + "\n" m_max = max(A_prices[self._currency_m], B_prices[self._currency_m]) m_min = min(A_prices[self._currency_m], B_prices[self._currency_m]) n_max = max(A_prices[self._currency_n], B_prices[self._currency_n]) n_min = min(A_prices[self._currency_n], B_prices[self._currency_n]) is_same_side = (A_prices[self._currency_m] == m_max and A_prices[self._currency_n] == n_max) or (B_prices[self._currency_m] == m_max and B_prices[self._currency_n] == n_max) if is_same_side: symbol = 1 else: symbol = -1 rate = round(abs((m_max - m_min)*100/ m_min - (n_max - n_min) * 100 * symbol / n_min), 2) log_content += "Rate: {0}%".format(rate) core.log(log_content) if rate > MIN_EXPECT_RATE: core.pushover(push_over_id, log_content) self._send_sms(rate)
def _record(self, currency, new_price, old_price, bids, asks): rate = round((new_price - old_price) / old_price, 3) * 100 print(currency) # print('bids = ',bids) # print('asks = ',asks) bid_volume_offset = {} for bid_order in bids: for p_offset in price_offset: if bid_order['price'] > new_price * (1 - p_offset): if p_offset in bid_volume_offset: bid_volume_offset[p_offset] += bid_order[ 'volume'] * bid_order['price'] else: bid_volume_offset[p_offset] = bid_order[ 'volume'] * bid_order['price'] ask_volume_offset = {} for ask_order in asks: for p_offset in price_offset: if ask_order['price'] < new_price * (1 + p_offset): if p_offset in ask_volume_offset: ask_volume_offset[p_offset] += ask_order[ 'volume'] * ask_order['price'] else: ask_volume_offset[p_offset] = ask_order[ 'volume'] * ask_order['price'] # deal with edge condition for p_offset in price_offset: if bids[-1]['price'] > new_price * (1 - p_offset): bid_volume_offset[p_offset] = 0 if asks[-1]['price'] < new_price * (1 + p_offset): ask_volume_offset[p_offset] = 0 for k, v in bid_volume_offset.iteritems(): bid_volume_offset[k] = round(v, 2) for k, v in ask_volume_offset.iteritems(): ask_volume_offset[k] = round(v, 2) msg = str.format('\nname={0},last_price={1},new_pair={2},offset={3}', currency, old_price, new_price, rate) + '\n' msg += str.format('bid volume = {0}\n', bid_volume_offset) msg += str.format('ask volume = {0}\n', ask_volume_offset) core.info(msg) core.pushover(push_over_id, msg)
def _record(self, currency, new_price, old_price, bids, asks): rate = round((new_price - old_price) / old_price, 3) * 100 print(currency) # print('bids = ',bids) # print('asks = ',asks) bid_volume_offset = {} for bid_order in bids: for p_offset in price_offset: if bid_order['price'] > new_price * (1 - p_offset): if p_offset in bid_volume_offset: bid_volume_offset[p_offset] += bid_order['volume'] * bid_order['price'] else: bid_volume_offset[p_offset] = bid_order['volume'] * bid_order['price'] ask_volume_offset = {} for ask_order in asks: for p_offset in price_offset: if ask_order['price'] < new_price * (1 + p_offset): if p_offset in ask_volume_offset: ask_volume_offset[p_offset] += ask_order['volume'] * ask_order['price'] else: ask_volume_offset[p_offset] = ask_order['volume'] * ask_order['price'] # deal with edge condition for p_offset in price_offset: if bids[-1]['price'] > new_price * (1 - p_offset): bid_volume_offset[p_offset] = 0 if asks[-1]['price'] < new_price * (1 + p_offset): ask_volume_offset[p_offset] = 0 for k,v in bid_volume_offset.iteritems(): bid_volume_offset[k] = round(v,2) for k,v in ask_volume_offset.iteritems(): ask_volume_offset[k] = round(v,2) msg = str.format('\nname={0},last_price={1},new_pair={2},offset={3}', currency, old_price, new_price, rate) + '\n' msg += str.format('bid volume = {0}\n', bid_volume_offset) msg += str.format('ask volume = {0}\n', ask_volume_offset) core.info(msg) core.pushover(push_over_id, msg)
def _findit(tid, url, title): content = ("tid = {0}\n url = {1}\n title = ".format(tid, url) + title) core.pushover(PUSHOVER_APP_ID, content)
def _send_sms(content): core.pushover(PUSHOVER_APP_ID, content)
def _findit(item): content = str(item) core.info(content) core.pushover(PUSHOVER_APP_ID, content)
def _findit(desc,topic, time_str, content_str, url): content = "{0}\n{1}\n{2}\n{3}\n{4}".format(desc,topic, url,time_str, content_str) core.info(content) # print content core.pushover(PUSHOVER_APP_ID, content)
def _findit(desc, topic, time_str, content_str, url): content = "{0}\n{1}\n{2}\n{3}\n{4}".format(desc, topic, url, time_str, content_str) core.info(content) # print content core.pushover(PUSHOVER_APP_ID, content)