Code Monkey home page Code Monkey logo

etoro-api's Introduction

Etoro trading API

CI Docker Image Build

Support project:

BTC: 3FRPsX4QsNNFzKZwtXh92JfKeetWJcn3SY

ETH: 0x8134888B3429aea645b34fcd576842a204d9C9aE

Requirments:
  • java 11 (JDK11)
  • Google Chrome (tested on version 78)
  • internet connection
Build executable jar
./gradlew build
Set your account credentials into Environment variables: LOGIN, PASSWORD
export LOGIN=yourusername
export PASSWORD=yourpassword
Start API server
 java -jar build/libs/etoro-api-0.0.1-SNAPSHOT.jar

Execute Requests

All requests are in the postman collection under postman/ import it to the Postman and try it out.

Using API server

All requests are in the postman collection under postman/ import it to the Postman and try it out.

In order to trade you have to add asset to watchlist first, then you can open or close positions with this asset. Your watchlist will be persisted locally in the watchlist.json if you start the server from the project folder.

Examples

Buy in Demo mode

1 Adding asset to your watchlist

Bitcoin

 curl -X PUT \
   http://localhost:8088/etoro-api/watchlist/byName \
   -H 'Content-Type: application/json' \
   -H 'cache-control: no-cache' \
   -d '{
 	"param": "btc"
 }'
NASDQ100
 curl -X PUT \
   http://localhost:8088/etoro-api/watchlist/byName \
   -H 'Content-Type: application/json' \
   -H 'cache-control: no-cache' \
   -d '{
 	"param": "nsdq100"
 }'
GOLD
 curl -X PUT \
   http://localhost:8088/etoro-api/watchlist/byName \
   -H 'Content-Type: application/json' \
   -H 'cache-control: no-cache' \
   -d '{
 	"param": "gold"
 }'

1.1 Review your watchlist

curl -X GET \
  http://localhost:8088/etoro-api/watchlist \
  -H 'cache-control: no-cache' \
  -H 'mode: Demo'

2 Open position

curl -X POST \
  http://localhost:8088/etoro-api/positions/open \
  -H 'Content-Type: application/json' \
  -H 'mode: Demo' \
  -d '{
	"name": "btc",
	"type": "BUY",
	"amount": 100,
	"leverage": 2,
	"takeProfitRate": 13000,
	"stopLossRate": 1000
}'
Make sure that "takeProfit" and "stopLoss" have valid values.
for some trades (all x1 buy) they are optional.

Response:

{
    "date": "2020-02-22T12:28:53.574543",
    "requestToken": "a859ec38-12bd-41b2-87f3-205515f2d608",
    "errorMessageCode": 0,
    "notificationParams": null,
    "position": {
        "leverage": 2,
        "stopLossRate": 8000,
        "takeProfitRate": 13000,
        "amount": 100,
        "instrumentID": "100000",
        "positionID": "1621284697",
        "isBuy": true,
        "isTslEnabled": false,
        "view_MaxPositionUnits": 0,
        "view_Units": 0,
        "view_openByUnits": null,
        "isDiscounted": false,
        "viewRateContext": null,
        "openDateTime": "2020-02-22T11:28:53.3993309",
	"openRate": 10100.1
    }
}

you can use positionID to close this position later on.

Close BTC position in Demo mode

curl -X DELETE \
  'http://localhost:8088/etoro-api/positions/close?id=1621284697' \
  -H 'mode: Demo'

etoro-api's People

Contributors

ok24601 avatar mortenscheel avatar tszkan avatar tkwong avatar mkjiau 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.