Log in

Platform API

Integrate with the Tradewave platform and build your own trading applications.

  • Create, edit and manage strategies
  • Run backtests
  • Access the results of completed backtests
  • Start, stop and monitor live trading bots
  • Access the results of previous live trading sessions
  • Manage your exchange API keys

All endpoints require authentication and should be prefixed with: https://tradewave.net/api

Libraries

Get started quickly with these third party libraries.

Authentication

All of the endpoints listed below require token authentication. To authenticate, you'll need to pass headers containing the username and a corresponding token:

  • X-Tradewave-Username
  • X-Tradewave-Token

Users can manually supply a token to your application (generated at My API tokens while logged in). Alternatively you could prompt the user for a username/password and generate a token through the API:

POST /tokens/new

Generate an API token on behalf of your user. The user can revoke this token at any time.

  1. curl \
  2. --data "app_key=nw2MazrUbLJj8kSwnr2ByXdPRvLex7" \
  3. --data "username=some_username" \
  4. --data "password=password123" \
  5. https://tradewave.net/api/tokens/new
  1. {"token": "mytoken123"}

Please contact us if you need to use this endpoint in your application. We'll send you an application key.

Strategies

GET /strategies

List of strategies owned by the authenticated user.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. https://tradewave.net/api/strategies/

Returns a JSON array:

  1. [{
  2. id: "zlJMRckBNN",
  3. name: "My new strategy",
  4. public: false,
  5. featured: false,
  6. forked: false
  7. }, {
  8. id: "HscwOFKLqs",
  9. name: "Moving Average Crossover (copy)",
  10. public: false,
  11. featured: false,
  12. forked: true
  13. }]

GET /strategies/<id>

Returns an individual strategy. It must be public or owned by the authenticated user.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. https://tradewave.net/api/strategies/zlJMRckBNN
  1. [{
  2. id: "zlJMRckBNN",
  3. name: "My new strategy",
  4. public: false,
  5. featured: false,
  6. forked: false
  7. }]

GET /strategies/<id>/source

Returns the Python source code for an individual strategy. It must be public or owned by the authenticated user.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. https://tradewave.net/api/strategies/zlJMRckBNN/source

The source code is returned as text/plain:

  1. def tick():
  2. log(data.btc_usd.price)

POST /strategies

Create a new strategy.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. --data "name=My new strategy" \
  4. --data "public=1" \ # (Optional) strategies are private by default
  5. https://tradewave.net/api/strategies/

Returns a JSON object if the strategy was successfully created:

  1. {
  2. id: "zlJMRckBNN",
  3. name: "My new strategy",
  4. public: true,
  5. featured: false,
  6. forked: false
  7. }

POST /strategies/<id>/edit

Make changes to an existing strategy. You can pass either name or source (or both).

  1. # Changes the Python source code of a strategy
  2. curl \
  3. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  4. --data "source=def%20tick()%3A%0A%20%20%20%20log(%27Hello%27)" \ # URL-encoded Python
  5. https://tradewave.net/api/strategies/zlJMRckBNN/edit
  1. # Changes the name of a strategy
  2. curl \
  3. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  4. --data "name=Moving%20Average%20Crossover" \
  5. https://tradewave.net/api/strategies/zlJMRckBNN/edit

POST /strategies/<id>/delete

Deletes the given strategy. Returns an error if any live bots are running for this strategy.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. -X POST https://tradewave.net/api/strategies/zlJMRckBNN/delete

POST /strategies/<id>/fork

Create a new strategy for the authenticated user by copying the source of an existing strategy. The given strategy must be public.

Backtests

POST /backtests

Queue a new backtest. The given strategy must be public or owned or by the authenticated user.

A triplet uniquely identifies a currency pair traded on a particular exchange. For example, BTC/USD on BTC-e is referred to as btce-btc-usd.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. --data "strategy_id=zlJMRckBNN" \
  4. --data "begin=1400956462" \ # Unix timestamp
  5. --data "end=1401129262" \ # Unix timestamp
  6. --data "interval=3600" \ # Tick interval (seconds)
  7. --data "currency=usd" \ # Starting portfolio currency
  8. --data "amount=1000" \ # Amount in our starting portfolio
  9. --data "primary_triplet=btce-btc-usd" \ # Orders will be placed on this exchange
  10. --data "chart_triplets=btce-btc-usd" \ # Only the first triplet is charted for now
  11. --data "other_triplets=btce-ltc-usd,kraken-btc-eur" \ # (Optional) more data sources
  12. https://tradewave.net/api/backtests/

If the backtest is successfully queued, returns a JSON object:

  1. {id: "ntidlvrMmg"}

GET /strategies/<id>/last_backtest

A useful shortcut to fetch the last created backtest for a given strategy. This also works for currently running backtests.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. https://tradewave.net/api/strategies/zlJMRckBNN/last_backtest
  1. {
  2. id: "tJUiBvBOql",
  3. strategy_id: "zlJMRckBNN",
  4. created: "2014-05-12T19:43:38.534849+00:00",
  5. running: false,
  6. params: {
  7. currency: "usd",
  8. amount: "1000",
  9. interval: 3600,
  10. begin: 1400956462
  11. end: 1401129262,
  12. },
  13. result: {
  14. charts: [{
  15. triplet: "btce-btc-usd"
  16. series: {
  17. price: {secondary: 0, values: [[1400385600, 501.44], ...]}
  18. }
  19. }]
  20. }
  21. }

GET /backtests

Returns a JSON array of previously created backtests.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. https://tradewave.net/api/backtests/
  1. [{
  2. id: "ntidlvrMmg",
  3. created: "2014-05-24T02:36:15.467271+00:00"
  4. running: false,
  5. strategy_id: "zlJMRckBNN",
  6. params: {
  7. currency: "usd",
  8. amount: "1000",
  9. interval: 3600,
  10. begin: 1400288400,
  11. end: 1400893200
  12. }
  13. }, ...]

GET /backtests/<id>/logs

Returns the plaintext log output of a backtest. Empty if the backtest is still running. Each line starts with a Unix timestamp, followed by a comma, then the content logged at that point in time.

Content may contain HTML tags and entities.

  1. curl \
  2. --header "X-Tradewave-Username: some_username" --header "X-Tradewave-Token: mytoken123" \
  3. https://tradewave.net/api/backtests/ntidlvrMmg/logs
  1. 1400382000,Starting...
  2. 1400385600,The price is: 501.44
  3. 1400389200,The price is: 520.44
  4. 1400389200,Finished

Credentials

Manage the authenticated user's exchange API keys.

Contact us for more information.

GET /credentials

POST /credentials

POST /credentials/<exchange>/delete

Bots

Start, stop and monitor live trading bots.

Contact us for more information. For working with storage, please refer to this forum post.

GET /bots

POST /bots

POST /bots/<id>/stop

GET /bots/<id>/source

GET /bots/<id>/storage

POST /bots/<id>/storage

Log in