Coder Social home page Coder Social logo

erfaniaa / crypto-portfolio-optimizer Goto Github PK

View Code? Open in Web Editor NEW
34.0 1.0 2.0 38 KB

Cryptocurrency portfolio optimizer and simulator (Which coins to buy during a Bitcoin bull run?)

License: GNU General Public License v3.0

Python 100.00%
backtest backtesting bitcoin crypto cryptocurrencies cryptocurrency ethereum finance investment

crypto-portfolio-optimizer's Introduction

Crypto Portfolio Optimizer

A simple cryptocurrency portfolio optimizer and simulator (useful for investors and holders)

Description

This is a simple tool designed for investors stepping into the world of cryptocurrencies. This project is an essential guide for those uncertain about which assets to include in their portfolio. By leveraging a simulation (backtest) mechanism, provides a data-driven approach to asset allocation. This tool works by this controversial assumption: sometimes, the market repeats itself!

Key Features

  • Personalized Portfolio Simulation: Input your candidate cryptocurrencies and a specific time interval, and our tool will simulate (backtest) how these coins have performed historically.

  • Optimal Allocation Strategies: Through an analysis, the tool suggests allocations for each asset in your portfolio, ensuring a diversified investment strategy.

  • Brute-Force Algorithm for Precision: At its core, the project utilizes a brute-force (backtrack) algorithm. This technique meticulously tests various portfolio combinations to find the most effective one for your goals.

  • Focus on Minimizing Drawdowns: A key objective of our tool is to minimize the drawdown in your wealth chart over time, enhancing the stability and reliability of your investments.

What is Drawdown?

Drawdown in finance refers to the peak-to-trough decline during a specific recorded period of an investment, a trading account, or a fund. It is usually quoted as the percentage between the peak and the subsequent trough. If a trading account has $10,000 at the peak and then drops to $9,000 before rising again, the drawdown is 10%. Drawdowns are important for measuring the historical risk of different investments, comparing fund performance, or monitoring personal trading performance. A key goal in finance is to minimize drawdowns to preserve capital and ensure a smoother investment growth trajectory.

Why Use This Tool?

Investing in cryptocurrencies can be daunting due to their volatile nature. This tool empowers you to make informed decisions based on historical performance analysis, thus helping to demystify the process of crypto investment and asset allocation. There are some seasonalities in cryptocurrency prices due to Bitcoin halvings, and we want to take advantage of these Bitcoin cycles. Whether you're a seasoned investor or new to the crypto world, our Crypto Portfolio Optimizer is your companion in building a resilient crypto portfolio.

Installation

First, clone the repository and then run the following command.

pip3 install -r requirements.txt

Config

You can change the config.py file to change the simulation parameters.

  • CANDIDATE_COINS is a list of coins you want to buy.
  • WEIGHTS_STEP_PRECISION_PERCENT: if you set you set it to 20, your portfolio might be something like this: 20% BTC, 40% ETH, 60% ETH (each weight will be a factor of 20%)
  • SIMULATION_START_DATE indicates the start time interval of the simulation.
  • SIMULATION_END_DATE indicates the end time interval of the simulation.
  • START_WALLET_SIZE_USD indicates the total amount of money (in the US Dollars) you want to invest.

Usage

Just run the following command.

python3 main.py

Notes

  • The cryptocurrency market is risky. Do your own research before trading and investing. You are responsible for your own actions in trading and investing.
  • Use other tools, indicators, and analyses as well. Using this tool alone without the help of other tools and analyses may not be the right thing to do.
  • Try setting SIMULATION_START_DATE and SIMULATION_END_DATE to almost four years ago. Bitcoin halvings happen every four years, so some patterns may be repeated (obviously, it's not guaranteed).

crypto-portfolio-optimizer's People

Contributors

erfaniaa avatar

Stargazers

Michael Madeja avatar M.H.Zarei avatar SinaZem avatar Amr A Eid avatar Ali Daghighi avatar Maryam Nazari avatar Farshad Bolouri avatar Rozhan Mirzaei avatar Amin avatar Alireza Moradi avatar Mohammad javad avatar mobina avatar Navid salehi avatar Shaygan Hooshyari avatar Reza avatar Mohammadreza Razavian avatar sadegh javanmard avatar Vahid zolfaghari avatar Peyman Daei Reaei avatar Ali Nasrabadi avatar IMAN SMD avatar Cham avatar Alireza Ahmadi avatar Morteza Parvini avatar Ali Tavallaie avatar Mohammad Reza Bayati avatar Alireza Mahdi Barzi avatar Younes Mahmoudi avatar  avatar Milad Bafarassat avatar mj-haghighi avatar Amir Motavas avatar Ali Tavafi avatar Erfan Arefmehr avatar

Watchers

 avatar

crypto-portfolio-optimizer's Issues

AttributeError: 'DataFrame' object has no attribute 'tolist' in load_coin_prices

When downloading coin data, calling .tolist() on the df['Close'] column raises an AttributeError because it's sometimes a DataFrame rather than a Series. Applying .squeeze() should fix the issue.

Before:

coin_prices_list = df['Close'].astype(float).tolist()

After:

coin_prices_list = df['Close'].squeeze().astype(float).tolist()

Bugs in wallet_simulator.py

Thank you for this interesting repository. There are some minor bugs in wallet_simulator.py:

  • (line 39) coin_prices_list = df['Close'].astype(float).tolist() needs to change into coin_prices_list = df['Close'].astype(float)..values.tolist()
  • (line 51) current_wallet_usd += self.start_wallet_size_usd * self.weights[coin] * self.coin_prices[coin][i] / self.coin_prices[coin][0]
    • I changed this into current_wallet_usd += self.start_wallet_size_usd * self.weights[coin] * self.coin_prices[coin][i][0] / self.coin_prices[coin][0][0] and the code runs correctly but I am not sure about this being true.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.