示例#1
0
 def test_get_weeks_candles(self):
     upbit = Upbitpy()
     ret = upbit.get_weeks_candles('KRW-ICX')
     self.assertIsNotNone(ret)
     self.assertNotEqual(len(ret), 0)
     logging.info(ret)
     logging.info(upbit.get_remaining_req())
示例#2
0
def main():
    upbit = Upbitpy()

    # 모든 원화 market 얻어오기
    all_market = upbit.get_market_all()
    krw_markets = []
    for m in all_market:
        if m['market'].startswith('KRW'):
            krw_markets.append(m['market'])

    candles_7d = dict()
    # 7일간 거래량
    for m in krw_markets:
        candles_7d[m] = upbit.get_weeks_candles(m, count=1)[0]
        check_remaining_candles_req(upbit)

    while True:
        logging.info('평균 거래량 대비 {}분 거래량 비율========================'.format(
            INTERVAL_MIN))
        for m in krw_markets:
            vol = upbit.get_minutes_candles(
                1, m, count=1)[0]['candle_acc_trade_volume']
            vol_7d = candles_7d[m]['candle_acc_trade_volume']
            vol_7d_avg = (((vol_7d / 7.0) / 24.0) / 60.0) * INTERVAL_MIN
            vol_ratio = format((vol / vol_7d_avg) * 100.0, '.2f')
            logging.info('[{}] {}% (거래량:{}, 평균:{})'.format(
                m, vol_ratio, format(vol, '.2f'), format(vol_7d_avg, '.2f')))
            check_remaining_candles_req(upbit)
        wait(INTERVAL_MIN)