Skip to content

Instantly share code, notes, and snippets.

@jooize
Last active January 7, 2018 22:41
Show Gist options
  • Save jooize/c77eaad424379f46ba6213a4fbb0f49d to your computer and use it in GitHub Desktop.
Save jooize/c77eaad424379f46ba6213a4fbb0f49d to your computer and use it in GitHub Desktop.

Revisions

  1. jooize revised this gist Jan 7, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion setup-nubot.markdown
    Original file line number Diff line number Diff line change
    @@ -159,7 +159,8 @@ cat << 'EOF' > ~/start
    ```
    #!/usr/bin/env sh
    tmux new-session -d -s "NuBot" -n "Debug" "$SHELL"
    tmux new-window -n "USNBT-USD" "cd southxchange_usnbt-usd && java -jar NuBot.jar -server -cfg=../southxchange_usnbt-usd.json ; $SHELL || $SHELL"```
    tmux new-window -n "USNBT-USD" "cd southxchange_usnbt-usd && java -jar NuBot.jar -server -cfg=../southxchange_usnbt-usd.json ; $SHELL || $SHELL"
    ```
    ```
    EOF
    ```
  2. jooize created this gist Jan 7, 2018.
    179 changes: 179 additions & 0 deletions setup-nubot.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,179 @@
    # Liquidity with NuBot

    ## Exchange (SouthXchange)

    - Create account.
    - Enable multi-factor authentication.
    - Enable API access.
    - Create API key.
    - Restrict API access to IP of gateway (consider).

    ## Setup VPS

    - Create Droplet on DigitalOcean.
    - Use Ubuntu LTS.
    - Choose specifications.
    - Activate backups?
    - Select SSH key.
    - Open console and note its fingerprint. Compare at SSH login.

    ## Set SSH alias for VPS

    ```sh
    vpsip=
    cat << EOF >> ~/.ssh/config
    Host southxchange
    User nu
    HostName $vpsip
    EOF
    ```

    ## NuBot on VPS

    ```sh
    ssh root@southxchange
    ```

    ### Add user `nu` without password

    *Passwordless logins are denied by default.*

    ```sh
    adduser nu --disabled-pass‐word
    ```

    ```sh
    mkdir /home/nu/.ssh
    chown nu:nu /home/nu/.ssh
    chmod 700 /home/nu/.ssh
    cat /root/.ssh/authorized_keys >> /home/nu/.ssh/authorized_keys
    chown nu:nu /home/nu/.ssh/authorized_keys
    ```

    ### Install unarchiver

    ```sh
    apt install -y unzip
    ```

    ### Install Java

    ```sh
    apt-add-repository ppa:webupd8team/java
    ```

    Press Enter.

    ```sh
    apt update
    apt install -y oracle-java8-installer
    ```

    Accept the terms for Java. (Enter, Left, Enter)

    **Firewall:**

    ```sh
    ufw allow ssh/tcp
    ufw show added
    ufw enable
    ```

    Press Y, Enter.

    **Automatic security updates:**

    Won't reboot.

    ```sh
    dpkg-reconfigure --priority=low unattended-upgrades
    ```

    ## Setup NuBot

    ```sh
    ssh nu@southxchange
    ```

    ```sh
    curl -LO https://bitbucket.org/JordanLeePeershares/nubottrading/downloads/nubot-v0.5.0-RC11.zip
    unzip nubot-v0.5.0-RC11.zip
    ```

    ```sh
    ln -s nubot-v0.5.0-RC11.zip southxchange_usnbt-usd
    ```

    ### Auth key (required for streamer server)

    Key for protected credentials in NuBot.

    ```sh
    AUTHKEY=
    echo "$AUTHKEY" > ~/southxchange_usnbt-usd/res/authkey.txt
    ```

    ### NuBot config

    ```sh
    cd southxchange_usnbt-usd/config
    ln -s ../../southxchange_usnbt-usd.json nubot-config.json
    ```

    ```
    APIKEY=
    APISECRET=
    cat << EOF > ~/southxchange_usnbt-usd.json
    {
    "exchangeName": "southxchange",
    "pair": "nbt_btc",
    "txFee": 0.4,
    "apiKey": "$APIKEY",
    "apiSecret": "$APISECRET",
    "bypassStreaming": false,
    "streamingServer": "price.crypto-daio.co.uk:5556",
    "verbosity": "high",
    "executeOrders": true,
    "bookDisableTier2": true,
    "bookBuyWall": 10,
    "bookBuyOffset": 0.005,
    "bookSellWall": 10,
    "bookSellOffset": 0.005,
    "submitLiquidity": false,
    "mailNotifications": "none"
    }
    EOF
    ```

    ## Autostart

    ```sh
    cat << 'EOF' > ~/start
    ```
    ```
    #!/usr/bin/env sh
    tmux new-session -d -s "NuBot" -n "Debug" "$SHELL"
    tmux new-window -n "USNBT-USD" "cd southxchange_usnbt-usd && java -jar NuBot.jar -server -cfg=../southxchange_usnbt-usd.json ; $SHELL || $SHELL"```
    ```
    EOF
    ```

    ```sh
    chmod +x ~/start
    ```

    #### Cron autostart

    ```sh
    crontab -e
    ```

    ```
    @reboot /home/nu/start
    ```