Beispiel #1
0
def collector(exchange, market):

    api_key, secret_key = load_api_key(exchange)
    bittrex = Bittrex(api_key, secret_key)
    order_slice = bittrex.get_market_history(market, 100)

    return order_slice
Beispiel #2
0
 def __init__(self, exchange):
     self.__exchange = exchange
     self.__api_class = {
         'bigone': Bigone,
         'binance': Binance,
         'bittrex': Bittrex,
         'okex': Okex,
         'hitbtc': Hitbtc,
         'poloniex': Poloniex,
         'bitstamp': Bitstamp,
     }[exchange]
     self.__api_client = self.__api_class(*load_api_key(exchange))
Beispiel #3
0
def laplace_indicator(pair, exchange):
    bittrex_api = Bittrex(*load_api_key(exchange))

    full_order_book = bittrex_api.get_orderbook(pair, 'both', 20)

    assert full_order_book['success'] is True

    df_buy = pd.DataFrame(full_order_book['result']['buy'])
    df_sell = pd.DataFrame(full_order_book['result']['sell'])

    bid_sum = df_buy['Quantity'] * df_buy['Rate']
    ask_sum = df_sell['Quantity'] * df_sell['Rate']

    laplace_value = (bid_sum.sum() - ask_sum.sum()) / (bid_sum.sum() +
                                                       ask_sum.sum())
    return laplace_value
Beispiel #4
0
def get_volatility_df(exchange):
    pair_list = [
        'USDT-BTC', 'BTC-1ST', 'BTC-ETH', 'BTC-OMG', 'BTC-GNT', 'BTC-XRP',
        'BTC-SC', 'BTC-DASH', 'BTC-QTUM', 'BTC-SNT'
    ]

    bittrex_api = Bittrex(*load_api_key(exchange))

    for pair in pair_list:
        hist = pd.DataFrame(
            bittrex_api.getHistoricalData(market=pair, period=100, unit='day'))
        hist['H'] = hist['H'] / hist['C'].mean()
        hist['L'] = hist['L'] / hist['C'].mean()

        hist['v'] = hist['H'] / hist['L']

        print("volatility of {} is {}".format(pair, hist['v'].std()))
Beispiel #5
0
def find_breakout(p):
    while True:
        my_bittrex = Bittrex(*load_api_key('bittrex'))
        closing_prices_1min = my_bittrex.getClosingPrices(p, 100, 'oneMin')
        df = pd.DataFrame([])
        df['close'] = closing_prices_1min
        df['ma5'] = df['close'].rolling(5).mean().fillna(method='bfill')
        df['diff'] = df['close'] - df['ma5']
        df['higher'] = df['diff'].apply(lambda x: x > 0)
        cpx = df['close'].tolist()[-1]
        if df['higher'].tail(5).tolist()[::-1] == [
                False, False, False, False, True
        ]:
            print(green("{} breakout up at price {}".format(p, cpx)))
        if df['higher'].tail(5).tolist()[::-1] == [
                True, True, True, True, False
        ]:
            print(red("{} breakout down at price {}".format(p, cpx)))
        print("{} hodl current price: {}".format(p, cpx))
        time.sleep(10)
Beispiel #6
0
def break_bollinger_bands(p, exchange):
    while True:
        my_bittrex = Bittrex(*load_api_key(exchange))
        closing_prices_1min = my_bittrex.getClosingPrices(p, 100, 'fiveMin')
        cpx = closing_prices_1min[-1]

        pct_change = closing_prices_1min[-1] / closing_prices_1min[-2]
        upper, middle, lower = talib.BBANDS(np.asarray(closing_prices_1min),
                                            timeperiod=15,
                                            nbdevup=1,
                                            nbdevdn=1,
                                            matype=0)

        upper = upper[-1]
        lower = lower[-1]
        if cpx < lower and pct_change > 0.97:
            # break bollinger bands up
            print(green("{} breakout up at price {}".format(p, cpx)))

        elif cpx > upper or pct_change < 0.97:
            # break bollinger bands down
            print(red("{} breakout down at price {}".format(p, cpx)))
        time.sleep(10)
        print("\n")
Beispiel #7
0
def test_api():
    key, secret = load_api_key('zb')
    api = ZB(key, secret)
    print(api.trades('1stbtc'))
Beispiel #8
0
                    for k in ks:
                        item = "orders[][%s]=%s" % (k, v[k])
                        query = "%s&%s" % (query,
                                           item) if len(query) else "%s" % item
        return query

    def sign(self, verb, path, params=None):
        query = self.urlencode(params)
        msg = ("|".join([verb, path, query])).encode('utf-8')
        signature = hmac.new(self.secret_key.encode('utf-8'),
                             msg=msg,
                             digestmod=hashlib.sha256).hexdigest()

        return signature

    def sign_params(self, verb, path, params=None):
        if not params:
            params = {}
        params.update({
            'tonce': int(1000 * time.time()),
            'access_key': self.access_key
        })
        signature = self.sign(verb, path, params)

        return signature, params


if __name__ == '__main__':
    api_key, secret_key = load_api_key('bigone')
    client = Client(api_key, secret_key)
Beispiel #9
0
        return signature

    def sign_params(self, verb, path, params=None):
        if not params:
            params = {}
        params.update({
            'tonce': int(1000 * time.time()),
            'access_key': self.access_key
        })
        signature = self.sign(verb, path, params)

        return signature, params


if __name__ == '__main__':
    api_key, secret_key = load_api_key('yunbi')
    client = Client(api_key, secret_key)
    buy_order_count = 0
    sell_order_count = 0
    last = 0

    while True:
        print("===============================================")
        #pprint.pprint(client.getOrderBook('1stcny', limit=10))

        #time.sleep(10)
        #continue
        #k = client.getHistory('1stcny')
        tick = client.getTickers('1stcny')
        print(tick)
        if tick['last'] == last: