Git Product home page Git Product logo

vnpy-docker's Introduction

A Container of VNPY with Sinopac Gateway

The purpose of this project is for ease of setup VNPY trading application. 

With this project, the VNPY is running in a docker container, then user can use SSH to access the VNPY in the container. 

```shell
+--------------+                             +------------------------------------+
| Host machine |---> SSH (port 23456) --->   | Container (Ubuntu 18.04 with VNPY) |
+--------------+                             +------------------------------------+
```

Test environment

It should work on other platforms, but currently it has been only tested on:

  • Macbook Pro (Intel) with Docker Desktop.

VNPY container

For compiling successfully the ta-lib, it have to configure the 4GB+ memory resources.

Docker memory resource

Prepare VNPY container

* Pull from Docker Hub (recommended)

```shell
docker pull edwardyang/vnpy
```

```shell
$ docker images

REPOSITORY        TAG       IMAGE ID       CREATED          SIZE
edwardyang/vnpy   latest    7813668517cc   41 minutes ago   5.53GB
```

* Build from Dockerfile (it take hours)

Clone source code:

```shell
git clone https://github.com/Ed-Yang/vnpy-docker.git
```

Build VNPY container:

<yourname>: the user name (also used as default password) of Linux's account.

```shell
cd vnpy-docker
docker build -t vnpy --build-arg USERNAME=<yourname> .
```

```shell
$ docker images

docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
vnpy         latest    7813668517cc   4 minutes ago   5.53GB
```

Run VNPY container

  • Setup environment variable

    <root-of-repo>: the root path of this repo.
    <yourname>: the login name given in container building. (default: edward)

    cd vnpy-docker
    export VNPY_ROOT=`pwd`
    export USERNAME=<yourname>
  • Setup working folder

    In local host:

    cp -r $VNPY_ROOT/examples $VNPY_ROOT/run
  • Start VNPY container

    Pull from Docker Hub:

    docker run --rm --name vnpy -v $VNPY_ROOT/run:/home/$USERNAME/workspace/run -p 23456:23456 -it edwardyang/vnpy

    Build from Dockerfile:

    docker run --rm --name vnpy -v $VNPY_ROOT/run:/home/$USERNAME/workspace/run -p 23456:23456 -it vnpy

VNPY trading application

Currently, the VPNY container only support SSH connection.

Local Host - Setup SSH

  • macOS

    First, install X windows client [XQuartz][https://www.xquartz.org].

    If the image is pulled from Docker Hub, the default username and password are 'edward'. Add an config "vnpy" in ~/.ssh/config:

    Host vnpy
    User <yourname>
    HostName localhost
    Port 23456
    SendEnv LANG LC_*
    XAuthLocation /opt/X11/bin/xauth
    ForwardAgent yes
    ForwardX11 yes
    SendEnv TERM=xterm-256color

    Setup SSH password:

    # remove old key
    ssh-keygen -R [localhost]:23456  # or remove manually from ~/.ssh/known_hosts
    ssh-copy-id vnpy # setup passwd

    Connect to VNPY container:

    In host, open a shell terminal, and run:

    ssh -X vnpy
    

Login VNPY

  • Sinopac account

    There are 10 of test accounts PAPIUSER01~PAPIUSER10 (All of the account's password are 2222) which can be used to connect to Sinopac gateway.

    There are limited functions available the simulation environment, so it is suggested to use real account to test VNPY.

    Logging with real account, you could get the live tick and also your current orders.

    It if you want to place order, you have to provide the certificate additionly.

    i.e. In host, copy the certificate to the working folder:

    cp Sinopac.pfx $VNPY_ROOT/run
  • After SSHed in container, execute the following commands and the VNPY application window will show up.

    In container:

    cd workspace/run
    python run.py

Logging:

VNPY application

After logged in with simulation account:

VNPY application

Reference

System

VNPY

Sinopac

Q/A

  • Install ta-lib failed. error message: note: expected ‘const TA_FuncHandle **’

It's due to gcc run out of memory, enlarge the RAM size in Docker's preference and rebuilt it.

  • qt.qpa.xcb: could not connect to display
ssh -X vnpy
  • convert BIG-5

iconv -f BIG-5 -t UTF-8 excd.csv

  • warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

Re-install requests to resolve:

pip install requests

vnpy-docker's People

Contributors

ed-yang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.