1. Installation

1.1. Installing on a Computer

Installing the bot on a computer is drag-and-drop and platform independent.

1.1.1. Prerequisites

You will need:

  • Python 2.7.x (Must be added to PATH)

Recommended for easier use:

  • git
  • pip (to install following required Python modules)
  • Numpy (if using Analysis module)
  • requests (HTTPS communication)
  • pytz (Timezone calculations)

It is possible to install all required Python modules after downloading of the bot running:

pip install -r requirements.txt

or, if you need to run it as root under Linux:

sudo pip install -r requirements.txt

1.1.2. Downloading

To download the bot you can either:

  • (Recommended) Run git clone https://github.com/BitBotFactory/poloniexlendingbot if you have git installed. Using this method will allow you to do git pull at any time to grab updates.
  • Download the source .zip file from the GitHub repo page or from this link. Extract it into an empty folder you won’t accidentally delete.

1.1.3. (Optional) Automatically Run on Startup

  • Windows using Startup Folder:

    Add a shortcut to lendingbot.py to the startup folder of the start menu. Its location may change with OS version, but for Windows 8/10 is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

  • Linux using systemd:

    Create the file /lib/systemd/system/lendingbot.service which contains the following text:

    [Unit]
    Description=LendingBot service
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/python <INSTALLATION DIRECTORY>/lendingbot.py
    WorkingDirectory=<INSTALLATION DIRECTORY>
    RestartSec=10
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    

    Credit to GitHub user utdrmac.

    Modify the ExecStart and WorkingDirectory to match your setup.

    Enable the service using sudo systemctl enable lendingbot.service

  • OSx:

    Help needed! If you have a solution for OSx and would like to share, you can either share it directly with us or make a PR with the edits.

1.1.4. Configuring

You have to configure the bot, especially choosing the exchange and api key/secret to use.

To configure the bot with your settings:

  1. Copy default.cfg.example to default.cfg (Running lendingbot.py also does this for you if default.cfg doesn’t already exist.)
  2. Open default.cfg and enter your desired settings (information on settings here).
  3. Save default.cfg

You are now ready to run the bot.

1.1.5. Running

To run, either:

  • Double-click lendingbot.py (if you have .py associated with the Python executable)
  • Run python lendingbot.py in command prompt or terminal.

Note

You can use arguments to specify a specific config file -cfg or to do dry runs -dry. To see these args do: python lendingbot.py -h

1.2. Installing on Pythonanywhere.com

Pythonanywhere.com is a useful website that will host and run Python code for you. This is perfect for our bot.

1.2.1. Prerequisites

You will need:

  • A pythonanywhere.com account (Free version works fine)

1.2.2. Downloading the bot’s files to Pythonanywhere

  1. Start a new bash console from the “Consoles” tab.
  2. Get the source code from git GitHub by running git clone https://github.com/Mikadily/poloniexlendingbot.
  3. You should see some output with counters increasing.
  4. Change directory to the source code cd poloniexlendingbot
  5. You should now see ~/poloniexlendingbot (master)$ this means you are looking at the master branch and things are ok to continue.
  6. Run the command python2.7 lendingbot.py once to generate the default.cfg
  7. Modify the default.cfg with your settings (See Configuration.) You can do this with a tool called nano.
  8. Run nano default.cfg, then use the arrow keys and backspace key to change YourAPIKey and YourSecret. Make sure the layout of the file stays the same as it was. They should both be on separate lines.
  9. Press Ctr+x to exit, then press y to save the file, then press enter to accept the file name as default.cfg.
  10. Now you can start up the bot. Run python2.7 lendingbot.py
  11. If it’s working you will see Welcome to Poloniex Lending Bot displayed in the console.
  12. To update the bot just enter its directory, cd poloniexlendingbot and type, git pull. This will not change the default.cfg file.

Note

If you are running out of CPU time every day: It is recommended to use a high sleeptimeinactive time for this website, as they meter your CPU usage.

1.2.3. Creating the Web App (Optional)

  1. If you would like to use the Webserver to view your bot’s status, navigate to the “Web” tab.
  2. Add a new web app.
  3. Set the working directory to /home/<username>/poloniexlendingbot/www/
  4. Set the static files to URL: /static/ Directory: /home/<username>/poloniexlendingbot/www
  5. Reload your website with the button at the top of the page.
  6. You will be able to access the webapp at http://<username>.pythonanywhere.com/static/lendingbot.html once it finishes setting up.
  7. To have the webserver communicate with your bot, you need to edit your settings (default.cfg) and uncomment (remove the # in front of) the following settings: jsonfile and jsonlogsize. Make sure that startWebServer REMAINS commented.

Warning

Do not use the built-in Simple Web Server on any host you do not control.

1.2.4. Running the Bot

To run the bot continuously (Recommended for free accounts):

  1. Navigate to the “Consoles” tab.
  2. Add a new “Custom console,” name it “Poloniexlendingbot” and set the path to python /home/<username>/poloniexlendingbot/lendingbot.py
  3. Click this link whenever you want to start the bot, it will run continuously until the website goes down for maintenance or the bot experiences an unexpected error.

To have the bot restart itself every 24 hours, you need to have a premium pythonanywhere account. This will make the bot more or less invincible to crashes and resets, but is not necessary.

  1. Navigate to the “Schedule” tab.
  2. Create a new task to run daily (time does not matter) set the path to: python /home/<username>/poloniexlendingbot/lendingbot.py
  3. The bot will start once the time comes (UTC) and run indefinitely.

Note

If you are a free user, it will allow you to make the scheduled restart, but then it will only run for one hour and stop for 23.

Note

Free users are also limited to the number of output currencies they can use as blockchain.info is blocked from their servers. You can always use the pairs listed on poloniex, BTC, USDT. But will not have access to currencies such as EUR, GBP.

1.3. Using Docker

There is a docker-compose.yaml file in the root of the source that can be used to start the bot via docker. Compose is a tool for defining and running docker applications using a single file to configure the application’s services.

To use this file:-

  1. Install and setup docker for your platform, available on linux, mac and windows.
  2. If you are using linux or windows server, you’ll need to install docker-compose separately, see here.
  3. If you don’t already have a default.cfg created, then copy the example one and change the values as required using the instructions in this document.
  4. You can now start the service with docker-compose up -d. It may take a minute or two on the first run as it has to download the required image and then some packages for that image when it starts.
  5. If all went well you should see something like Starting bitbotfactory_bot_1.
  6. When you see that message it just means that the container was started successfully, we still need to check the application is running as expected. In the yaml file the web service in the container is mapped to localhost. So you can open your web browser at this point and see if you can connect to the serivce. It should be runnning on http://127.0.0.1:8000/lendingbot.html.
  7. If you don’t see anything when connecting to that you can check the logs of the container with docker-compose logs. You should get some useful information from there. You may need to change some config vaules.
  8. When you change the config values you need to restart the container, this can be done with docker-compose stop and then after changing configs, docker-compose up -d. You should notice it’s significantly quicker than the first run now.
  9. The last command to note is docker-compose ps this will give infomation on all running instances and the ports that are mapped. This can be useful if you plan on running multiple bots, or you just want to know if it’s running.