예제 #1
0
 def save(self):
     Ticker.create(currency=self.currency,
                   epoch=self.epoch,
                   datetime=self.datetime,
                   price=self.price,
                   volume24h=self.volume24h,
                   prev_price=self.prev_price,
                   price_diff_prev=self.price_diff_prev,
                   price_diff_prev_pct=self.price_diff_prev_pct)
     print(self)
예제 #2
0
def scrape(currency):
    symbol = "{}{}".format(currency, CURRENCY)

    try:
        price = get_ticker(symbol)
        if price is not None:
            now = datetime.now()
            Ticker.create(currency=currency,
                          price=price['lastPrice'],
                          epoch=now.timestamp(),
                          datetime=now)
    except ValueError as e:
        print(e)
예제 #3
0
def task(arg1, arg2):
    r = api.ticker()
    t = datetime.datetime.fromtimestamp(int(r['timestamp']))
    print(r)
    if Ticker.select().where(Ticker.timestamp == t).count() == 0:
        Ticker.create(
            last=r['last'],
            bid=r['bid'],
            ask=r['ask'],
            high=r['high'],
            low=r['low'],
            volume=r['volume'],
            timestamp=t
        )