Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Developing Bitcoin Trading Algorithms with Quantiacs

    News and Feature Releases
    1
    1
    170
    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.
    • news-quantiacs
      news-quantiacs last edited by news-quantiacs

      This article was published on gitconnected on Medium: check it out here.

      In this article we describe the implementation of a simple quantitative strategy on the Bitcoin Futures contract with Quantiacs.

      This month we released a new version of the Quantiacs platform with several major improvements. In addition to providing a new open-source backtesting tool and the possibility to download for free financial data, we created a cloud environment for quants. Here it is possible to code trading algorithms in Python using Jupyter Notebook or JupyterLab and to run them directly online using our resources for free.

      1*0E92vDwrjbDRmyUzc0XAww.jpeg

      The competition model has also changed: the 15th edition of the Futures contest, based on 75 liquid Futures contracts (including stock indices, bonds, forex and commodities), is running together with the 1st edition of the Bitcoin Futures contest.

      We are going to allocate 4M USD to the best systems. 7 quants will get allocations for their Futures systems, and 7 quants for their Bitcoin Futures systems, provided they are submitted before May 31st, 2021, and they have an in-sample Sharpe ratio larger than 1.

      1*J6MwuPLVavImpOaQWEX7MQ.png

      In this article we describe the implementation of a simple trading algorithm on the Bitcoin Futures contract.

      After registering to Quantiacs, you can open your personal development area, Clone one example and edit it with Jupyter Notebook or JupyterLab.

      1*b1ze_Dr49KxSNqa4DPYqBA.png

      After opening the notebook we import the needed libraries:

      import xarray as xr
      import qnt.backtester as qnbt
      import qnt.data as qndata
      import qnt.ta as qnta
      

      We based Quantiacs on xarray as it makes working with multi-dimensional arrays very efficient. Our qnt library can be accessed at our github repository and the documentation can be accessed at our page.

      Next we define two functions: one for loading the Bitcoin Futures data, the second one for defining an elementary trend-following strategy based on the crossing of two simple moving averages:

      def load_data(period):
          crypto= qndata.cryptofutures.load_data(tail=period)
          return crypto
      
      def strategy(data):
          close_crypto= data.sel(field=”close”)
          sma100= qnta.sma(close_crypto, 100).isel(time=-1)
          sma20 = qnta.sma(close_crypto, 20).isel(time=-1)
          return xr.where(sma100 < sma20, 1, 0)
      

      The strategy is investing in Bitcoin Futures when the 20-day moving average is larger than the 100-day one, otherwise it is not allocating anything.

      Finally we call the Quantiacs backtesting function:

      qnbt.backtest(
          competition_type= “cryptofutures”,
          load_data= load_data,
          lookback_period= 365,
          start_date= “2013-06-01”,
          strategy= strategy
      )
      

      and run the notebook. Among the output messages, you will see that the Sharpe ratio in the in-sample period relevant for the competition is larger than 1:

      Check the sharpe ratio...
      Period: 2014-01-01 - 2021-02-17
      Sharpe Ratio = 1.4853014048450253
      Ok.
      

      This means that this system can be submitted and will be eligible for the contest. Of course this idea represents only a starting point, so you should improve it.

      Once you have completed your research, you can select this strategy from your Development area and click on the Submit button. The strategy will be processed every day on our servers with new market data, and you will be able to monitor the progress in your personal Competition area.

      The first submissions are already arriving and they can be checked out at the Leaderboard page:

      1*ObpOqzMN9UT643luyOqJpA.png

      The full strategy

      import xarray as xr
      
      import qnt.backtester as qnbt
      import qnt.data as qndata
      import qnt.ta as qnta
      
      def load_data(period):
          crypto= qndata.cryptofutures.load_data(tail=period)
          return crypto
      
      def strategy(data):
          close_crypto= data.sel(field=”close”)
          sma100= qnta.sma(close_crypto, 100).isel(time=-1)
          sma20 = qnta.sma(close_crypto, 20).isel(time=-1)
          return xr.where(sma100 < sma20, 1, 0)
      
      qnbt.backtest(
          competition_type= “cryptofutures”,
          load_data= load_data,
          lookback_period= 365,
          start_date= “2013-06-01”,
          strategy= strategy
      )
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB | Contributors
      • Documentation
      • About
      • Career
      • My account
      • Privacy policy
      • Terms and Conditions
      • Cookies policy
      Home
      Copyright © 2014 - 2021 Quantiacs LLC.
      Powered by NodeBB | Contributors