Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Minute Crypto Data via API

    General Discussion
    2
    3
    54
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LClassen last edited by

      Dear Backtraders,

      I am trying to download crypto trading data (preferrably Binance). I know that you can donwload day klines via YahooFinanceData. However, I did not find any api access to minute data. Can somebody help me out?

      Cheers,
      Leo

      1 Reply Last reply Reply Quote 0
      • G
        Gleetche last edited by

        @LClassen

        Get you api key and secret from your binance account
        Here's what I use for binance.

        import config, csv
        from binance.client import Client
        
        client = Client(config.API_KEY, config.API_SECRET)
        
        
        # prices = client.get_all_tickers()
        # for price in prices:
        #     print(prices)
        
        
        '''
        GUIDELINES
        
        To change the timeframe to 1minute data, replace "1HOUR" with 
        to "1MINUTE".
        
        '''
        csvfile = open("data/1HOUR/ZILBTC_Start_311220_1HOUR.csv", "w", newline="")
        candlestick_writer = csv.writercsvfile,delimiter=',')
        candlesticks = client.get_historical_klines("ZILBTC", Client.KLINE_INTERVAL_1HOUR,"01 Jan 2017","31 Dec 2020")
        
        
        for candlestick in  candlesticks:
            candlestick[0] = candlestick[0] / 1000
            candlestick_writer.writerow(candlestick)
        csvfile.close()
        
        1 Reply Last reply Reply Quote 0
        • L
          LClassen last edited by

          That helped. Thank you so much!

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }