The Market Cap Weighting Bot is an extended version of the Asset Cost Averaging bot. It lets you buy multiple assets weighted by the market capitalization.
The bot uses the same mechanisms and provides the same functionality as described in the Asset Cost Averaging Section. In addition to that, it lets you configure multiple buy assets where the investment amount
$$a_i = r_i v$$ $$r_i = \frac{w_i c_i}{t}$$ $$t = \sum_{i=1}^n w_i c_i$$
For example, if we have three assets, BTC, ETH, and LTC, and an investment amount of $100, the bot will first reach out to the CoinGecko API to determine the market capitalization
With $1600 as the total market capitalization and the help of Equation 2, the bot is now able to calculate the market cap ratio
With
With the above calculation steps, the bot determined an investment amount of $62.50 for BTC, $25 for ETH and $12.50 for LTC.
The weighting factor
To get the correct market cap of an asset, a mapping between CoinGeckos coin id and Krakens coin id is used. Have a look at the tools README to see how to add new coin mappings. You can find the already included coins in the asset-mapping.json file.
There are three ways to get the bot running. Each way requires you to have an API key pair created. Have a look at Krakens How to to get support. For buying assets you need to give permission to query funds and to create and modify orders. For withdrawing assets you also need to give permission to withdraw funds.
The easiest way to get started is to adapt the ./docker/docker-compose-finite.yml
or ./docker/docker-compose-infinite.yml
file, rename it to ./docker/docker-compose.yml
and start it with the following command:
./scripts/run-docker.sh
you can stop it with:
# stop
./scripts/pause-docker.sh
# stop and destroy
./scripts/stop-docker.sh
You need to have docker installed. The checked in docker-compose-finite.yml and docker-compose-infinite.yml files contain two different configurations. docker-compose-finite.yml contains the minimum required configuration to run the bot for a finite number of buy cycles. docker-compose-infinite.yml is a more robust setup and lets the bot run for infinite number of buy cycles. For a full set of available configuration variables have a look into the settings.env
file.
To use docker compose with your own created image, first build the image with the following command:
./scripts/build-docker-image.sh
you do not need to have Node installed on your machine. After your image is created, switch to the local image as described in the ./docker/docker-compose-*.yml
file and follow the steps described in the Docker Compose Section.
To start the bot with Node, first install the dependencies with:
yarn install
and build the javascript files with:
yarn build
You need to have your configuration available via environment variables before starting the bot. The easiest way to achieve this is to store your config in a .env
file. Use the following step to get a .env
file including the full set of available settings and configure it according to your preferences:
cp settings.env .env
The last step is to start the bot with:
yarn start
To start development, you must have Node.js and the Yarn package manager installed. You also need a valid .env
file. Follow the steps described in the Plain Section to create one.
# start in watch mode
yarn dev
# lint
yarn lint
# autofix lint errors
yarn lint:fix
# test
yarn test
# build production
yarn build
# start in production mode
yarn start