Beispiel #1
0
def fillhistory(request):
    candle_interval = "MINUTE_1"
    market_symbol = "USDT-BTC"

    start_date = date(2016, 10, 12)
    end_date = date(2021, 4, 29)
    market_sym_exp = market_symbol.split("-")

    for single_date in daterange(start_date, end_date):
        year = single_date.strftime("%Y")
        month = single_date.strftime("%m")
        day = single_date.strftime("%d")

        bittrex_api_link = f"https://api.bittrex.com/v3/markets/{market_sym_exp[1]}-{market_sym_exp[0]}" \
            f"/candles/{candle_interval}/historical/{year}/{month}/{day}"
        response = Request.get(bittrex_api_link)

        if "code" in response.json():
            return print("ERROR: ", response.json()["code"])
        else:
            for entry in response.json():
                new_record = PairHistory(starts_at=entry["startsAt"],
                                         pair=market_symbol,
                                         open=entry["open"],
                                         high=entry["high"],
                                         low=entry["low"],
                                         close=entry["close"],
                                         volume=entry["volume"],
                                         quote_volume=entry["quoteVolume"])
                new_record.save()
            print(
                f"Responce of {single_date} contains {len(response.json())} records"
            )

    return HttpResponse("Started")
Beispiel #2
0
 def get_ticker(pair):
     print(f"Requesting {BITTREX_BASE}markets/{str(pair).upper()}/ticker")
     response = Request.get(
         f"{BITTREX_BASE}markets/{str(pair).upper()}/ticker").json()
     if response.get("code"):
         return print("ERROR: ", response.get("code"))
     return response
 def _send_request(url):
     return Request.get(self.base + url)
 def _handle_response(url):
     return Request.get(url)
Beispiel #5
0
 def get_open_orders(self, marketsymbol: str = ""):
     # Return local exchange orders and remote
     response = Request.get(f"{BITTREX_BASE}orders/open")
     if response.get("code"):
         return print("ERROR: ", response.get("code"))
     return response