This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled Flask server.
This example uses the Connexion library on top of Flask.
Python 3.5.2+
This server is configured out of the box to connect to a default test exchange 'TestEx', this is an implementation of the base_gateway class that simply directs all requests to read or modify data in the flat file 'swagger_server/test/test_exchange.dat'.
Also, included in this package is a nascent implementation of a Binance Gateway, currently (12th Sep 2018) this implementation allows for the creation and retrieval of orders and not much else. To enable this gateway you will need to do a few things...
-
Modify the ecnMap within gateway_factory.py module; uncomment the 'Binance' entry in the map and comment out the 'TestEx' entry.
-
Create a binance.ini file under the directory swagger_server/gateway/binance. You may use the test_exchange.ini file that already exists under swagger_server/gateway/test_ex as a template. The server value needs to be changed to https://api.binance.com and the account details need to changed to reflect your Binance api and secret key.
Once these two steps are complete the server will now direct all requests to the Binance exchange.
Final point to note: the Binance gateway defaults to 'test' mode, i.e. if you try and create an order it will not be directed to the matching engine at Binance but will simply verify the request and return blank. To run in full trading mode modify the binance.ini file to include a 'mode = trade' entry under connection.details. CAVEAT EMPTOR! YOU WILL NOW BE PLACING LIVE ORDERS ON BINANCE, BE CAREFUL!
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
python -m swagger_server
and open your browser to here:
http://localhost:8080/tradingview/v1/ui/
Your Swagger definition lives here:
http://localhost:8080/tradingview/v1/swagger.json
To launch the integration tests, use tox:
sudo pip install tox
tox
To run the server on a Docker container, please execute the following from the root directory:
# building the image
docker build -t swagger_server .
# starting up a container
docker run -p 8080:8080 swagger_server