├── .circleci
└── config.yml
├── .dockerignore
├── .eslintignore
├── .eslintrc
├── .flowconfig
├── .gitignore
├── .istanbul.yml
├── .npmignore
├── Dockerfile
├── LICENSE
├── README.md
├── default.conf
├── demos
├── advanced
│ ├── demo.js
│ └── index.html
├── basic
│ ├── index.html
│ └── index.js
├── node
│ ├── node-demo.js
│ ├── package.json
│ └── webpack.config.js
└── oauth
│ ├── index.html
│ └── index.js
├── docs
└── networkcalls.md
├── flow-typed
├── binary-api.js.flow
└── binary-live-api.js.flow
├── gulpfile.js
├── mocha.opts
├── package.json
├── src
├── ApiState.js
├── LiveApi.js
├── LiveEvents.js
├── OAuth.js
├── ServerError.js
├── __tests__
│ ├── LiveApi-test.js
│ ├── LiveEvents-test.js
│ ├── ServerError-test.js
│ ├── admin-test.js
│ ├── custom-test.js
│ ├── oauth-test.js
│ ├── read-test.js
│ ├── resubscribe-test.js
│ ├── stateful-test.js
│ ├── trade-test.js
│ ├── unauthenticated-test.js
│ └── useRx-test.js
├── calls
│ ├── admin.js
│ ├── index.js
│ ├── payments.js
│ ├── read.js
│ ├── trade.js
│ └── unauthenticated.js
├── custom.js
└── index.js
├── wallaby.conf.js
├── webpack.config.js
└── yarn.lock
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 | orbs:
3 | k8s: circleci/kubernetes@0.7.0
4 | slack: circleci/slack@3.4.2
5 | commands:
6 | npm_install:
7 | description: "Install npm modules"
8 | steps:
9 | - restore_cache:
10 | name: Restore npm cache
11 | keys:
12 | - npm-v1-{{ checksum "package.json" }}
13 | - npm-v1-
14 | - run:
15 | name: Install npm modules
16 | command: yarn
17 | - save_cache:
18 | name: Save NPM cache
19 | key: npm-v1-{{ checksum "package.json" }}
20 | paths:
21 | - "node_modules"
22 | build:
23 | description: "Build"
24 | steps:
25 | - run:
26 | name: "yarn build"
27 | command: yarn build
28 | versioning:
29 | description: "Add version to build"
30 | parameters:
31 | target_branch:
32 | type: string
33 | steps:
34 | - run:
35 | name: Tag build
36 | command: echo "<< parameters.target_branch >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > lib/version
37 | docker_build_push:
38 | description: "Build and Push image to docker hub"
39 | steps:
40 | - setup_remote_docker
41 | - run:
42 | name: Building docker image
43 | command: |
44 | docker build -t ${DOCKHUB_ORGANISATION}/binary-static-liveapi:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/binary-static-liveapi:latest .
45 | - run:
46 | name: Pushing Image to docker hub
47 | command: |
48 | echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
49 | docker push ${DOCKHUB_ORGANISATION}/binary-static-liveapi:${CIRCLE_SHA1}
50 | docker push ${DOCKHUB_ORGANISATION}/binary-static-liveapi:latest
51 | k8s_deploy:
52 | description: "Deploy to k8s cluster"
53 | parameters:
54 | k8s_namespace:
55 | type: string
56 | default: "liveapi-binary-com-production"
57 | k8s_service:
58 | type: string
59 | default: "binary-static-liveapi"
60 | steps:
61 | - k8s/install-kubectl
62 | - run:
63 | name: Deploying to k8s cluster for service binary-liveapi
64 | command: |
65 | export NAMESPACE=<< parameters.k8s_namespace >>
66 | git clone https://github.com/binary-com/devops-ci-scripts
67 | cd devops-ci-scripts/k8s-build_tools
68 | echo $CA_CRT | base64 --decode > ca.crt
69 | ./release.sh << parameters.k8s_service >> ${CIRCLE_SHA1}
70 | notify_slack:
71 | description: "Notify slack"
72 | steps:
73 | - slack/status:
74 | include_project_field: false
75 | failure_message: "Release failed for liveapi.binary.com with version *$(cat lib/version)*"
76 | success_message: "Release succeeded for liveapi.binary.com with version *$(cat lib/version)*"
77 | webhook: ${SLACK_WEBHOOK}
78 | publish_to_pages_staging:
79 | description: "Publish to cloudflare pages"
80 | steps:
81 | - run:
82 | name: "Publish to cloudflare pages (staging)"
83 | command: |
84 | cd lib
85 | npx wrangler pages publish . --project-name=binary-live-api-pages --branch=staging
86 | echo "New staging website - http://staging.cf-pages-binary-live-api.binary.com"
87 |
88 | publish_to_pages_production:
89 | description: "Publish to cloudflare pages"
90 | steps:
91 | - run:
92 | name: "Publish to cloudflare pages (production)"
93 | command: |
94 | cd lib
95 | npx wrangler pages publish . --project-name=binary-live-api-pages --branch=main
96 | echo "New website - http://cf-pages-binary-live-api.binary.com"
97 | jobs:
98 | build:
99 | docker:
100 | - image: circleci/node:8.10.0-stretch
101 | steps:
102 | - checkout
103 | - npm_install
104 | - build
105 | release_staging:
106 | docker:
107 | - image: circleci/node:8.10.0-stretch
108 | steps:
109 | - checkout
110 | - npm_install
111 | - build
112 | - versioning:
113 | target_branch: "staging"
114 | - persist_to_workspace:
115 | root: lib
116 | paths:
117 | - .
118 | release_production:
119 | docker:
120 | - image: circleci/node:8.10.0-stretch
121 | steps:
122 | - checkout
123 | - npm_install
124 | - build
125 | - versioning:
126 | target_branch: "production"
127 | - persist_to_workspace:
128 | root: lib
129 | paths:
130 | - .
131 | - docker_build_push
132 | - k8s_deploy
133 | - notify_slack
134 | publish_cloudflare_staging:
135 | docker:
136 | - image: cimg/node:18.4.0
137 | steps:
138 | - attach_workspace:
139 | at: lib
140 | - publish_to_pages_staging
141 | publish_cloudflare_production:
142 | docker:
143 | - image: cimg/node:18.4.0
144 | steps:
145 | - attach_workspace:
146 | at: lib
147 | - publish_to_pages_production
148 |
149 | workflows:
150 | build:
151 | jobs:
152 | - build:
153 | filters:
154 | branches:
155 | ignore: /^master$/
156 | release_staging:
157 | jobs:
158 | - release_staging:
159 | filters:
160 | branches:
161 | only: /^master$/
162 | context: binary-frontend-artifact-upload
163 | - publish_cloudflare_staging:
164 | requires:
165 | - release_staging
166 | filters:
167 | branches:
168 | only: /^master$/
169 | context: binary-frontend-artifact-upload
170 | release_production:
171 | jobs:
172 | - release_production:
173 | filters:
174 | branches:
175 | ignore: /.*/
176 | tags:
177 | only: /^production.*/
178 | context: binary-frontend-artifact-upload
179 | - publish_cloudflare_production:
180 | requires:
181 | - release_production
182 | filters:
183 | branches:
184 | ignore: /.*/
185 | tags:
186 | only: /^production.*/
187 | context: binary-frontend-artifact-upload
188 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | .git
2 | Dockerfile
3 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build
2 | coverage
3 | lib
4 | demos
5 | node_modules
6 | **/*/all.js
7 | webpack.*.js
8 | server.js
9 | karma.*.js
10 | test/integration
11 | ./src/_constants/texts.js
12 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": "binary",
4 | "env": {
5 | "browser": true,
6 | "es6": true,
7 | "jest": true
8 | },
9 | "rules": {
10 | "camelcase": 0,
11 | "no-undef": 0,
12 | "react/jsx-indent": [0, "tab"],
13 | "react/prefer-stateless-function": 0,
14 | "react/jsx-indent-props": [0, "tab"],
15 | "react/jsx-filename-extension": 0,
16 | "import/named": 0,
17 | "import/default": 0,
18 | "import/namespace": 0,
19 | "import/prefer-default-export": 0,
20 | "import/no-extraneous-dependencies": 0,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | .*/wallaby.conf.js
3 | .*/node_modules
4 | .*/coverage
5 | .*/__tests__
6 | .*/lib
7 | .*/demos
8 | .*/webpack.config.js
9 |
10 | [include]
11 |
12 | [libs]
13 | ./node_modules/binary-utils/flow-typed/binary.js.flow
14 | ./node_modules/binary-utils/flow-typed/binary-utils.js.flow
15 | ./flow-typed/binary-api.js.flow
16 | ./flow-typed/binary-live-api.js.flow
17 |
18 | [options]
19 | esproposal.class_static_fields=enable
20 | esproposal.export_star_as=enable
21 | esproposal.class_instance_fields=enable
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | node_modules
3 | *.log
4 | .DS_Store
5 | lib
6 | coverage
7 | demos/node/dist
8 | demos/advanced/dist
9 | .publish
--------------------------------------------------------------------------------
/.istanbul.yml:
--------------------------------------------------------------------------------
1 | instrumentation:
2 | root: src
3 | include-all-sources: true
4 | verbose: true
5 | excludes:
6 | - index.js
7 | - __tests__/*.js
8 | reporting:
9 | dir: "coverage"
10 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.log
3 | src
4 | test
5 | demos
6 | examples
7 | coverage
8 | node_modules
9 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:alpine
2 | COPY ./lib /usr/share/nginx/html
3 | COPY ./default.conf /etc/nginx/conf.d/default.conf
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-present Binary Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # binary-live-api
2 |
3 | This repository is **deprecated**, please use https://github.com/binary-com/deriv-api/ instead.
4 |
5 | [](https://travis-ci.org/binary-com/binary-live-api)
6 |
7 | [](https://coveralls.io/github/binary-com/binary-live-api?branch=master)
8 |
9 | This library is a high-level abstraction over the [Binary.com Websockets API](https://developers.binary.com)
10 |
11 | ##
12 |
13 | ## Features
14 |
15 | 1. Promise based, all network calls return a promise that is resolved when response is received, request response mapping is handled out of the box
16 | 2. Automatic reconnect when disconnection, including resubscribe to subscription made before disconnection
17 |
18 | ## Usage in the Browser
19 |
20 | ```
21 | var api = new LiveApi();
22 | api.authorize('yourtoken');
23 | api.getPortfolio();
24 | api.events.on('portfolio', function(data) {
25 | // do stuff with portfolio data
26 | });
27 | ```
28 |
29 | ## Usage From Node
30 |
31 | Install a WebSockets library like 'ws'
32 |
33 | ```
34 | npm init
35 | npm install ws --save
36 | npm install binary-live-api --save
37 | ```
38 |
39 | Alternatively, you can add the library to your project with the following link: [https://liveapi.binary.com/binary-live-api.js](https://liveapi.binary.com/binary-live-api.js) - or to fix to a specific version, put the version number in the URL as follows: [https://liveapi.binary.com/27.0.0/binary-live-api.js](https://liveapi.binary.com/27.0.0/binary-live-api.js)
40 |
41 | Require the library and then pass it to LiveApi's constructor.
42 |
43 | ```
44 | var ws = require('ws');
45 | var LiveApi = require('binary-live-api').LiveApi;
46 |
47 | var api = new LiveApi({ websocket: ws });
48 | api.authorize('yourtoken');
49 | api.getPortfolio();
50 | api.events.on('portfolio', function(data) {
51 | // do stuff with portfolio data
52 | });
53 | ```
54 |
55 | For all available calls, please check [here](docs/networkcalls.md)
56 |
57 | ## Experimental feature (Not for production)
58 | support [RxJs](https://github.com/Reactive-Extensions/RxJS)
59 |
60 | User can opt to use observables API instead of Promise API by passing `useRx = true` in constructor, like below
61 |
62 | ```
63 | var api = new LiveApi({ useRx: true });
64 | api.ping() // return Observable, instead of Promise
65 | ```
66 |
67 | No more global events ~!! as Stream is now modelled as observables, you can pass it around, instead of listening to global event.
68 | This will allow better composition of streams, right now it only include rx.lite, thus not all observables operator are supported,
69 | all supported operators can be check [here](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/libraries/lite/rx.lite.md)
70 |
71 | Example
72 |
73 | ```
74 | var api = new LiveApi({ useRx: true });
75 | var r100TickStream = api.subscribeToTicks('R_100');
76 |
77 | // silly example, but to illustrate you can now operate on them independently
78 | var epochs = r100TickStream.map(function(json){return json.tick.epoch});
79 | var quotes = r100TickStream.map(function(json){return json.tick.quote});
80 |
81 | ```
82 |
83 | ## To deploy as library on gh pages
84 | run `gulp deploy` to deploy library to origin/gh-pages
85 |
86 | run `gulp deploy-prod` to deploy library to upstream/gh-pages
87 |
--------------------------------------------------------------------------------
/default.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | server_name localhost;
4 |
5 | add_header Cache-Control "public, max-age=7200, s-maxage=600, must-revalidate";
6 | charset UTF-8;
7 |
8 | error_page 404 /404.html;
9 |
10 | location @custom_error_503 {
11 | return 503;
12 | }
13 |
14 | location ~ /\.git {
15 | return 404;
16 | }
17 |
18 | location / {
19 | root /usr/share/nginx/html;
20 | index index.html index.htm;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/demos/advanced/demo.js:
--------------------------------------------------------------------------------
1 | var LiveApi = window['binary-live-api'].LiveApi;
2 |
3 | var api = new LiveApi();
4 |
5 | const token = 'qdJ86Avvrsh0Le4';
6 | api.authorize(token).then(
7 | () => console.log('Authorized!'),
8 | () => console.log('Not Authorized')
9 | );
10 |
11 | function tickHistoryDemo() {
12 | api.events.on('history', function(response) {
13 | console.log(response);
14 | });
15 | api.getTickHistory({symbol: 'frxUSDJPY', end: 'latest', count: 10});
16 | }
17 |
18 | function tickHistoryPromiseDemo() {
19 | api.getTickHistory('frxUSDJPY', {end: 'latest', count: 10}).then(function(response) {
20 | console.log(response);
21 | });
22 | }
23 |
24 | function forgetDemo() {
25 | api.unsubscribeFromAllTicks();
26 | }
27 |
28 | function tickStreamDemo() {
29 | api.events.on('tick', function(response) {
30 | console.log(response);
31 | });
32 | api.subscribeToTick('frxUSDJPY');
33 | }
34 |
35 | function pingDemo() {
36 | api.events.on('ping', function(response) {
37 | console.log(response);
38 | });
39 | api.ping();
40 | }
41 |
42 | function pingPromiseDemo() {
43 | api.ping().then(response => {
44 | console.log(response)
45 | });
46 | }
47 |
48 | function openPositionsDemo() {
49 | api.events.on('portfolio', function(response) {
50 | console.log(response);
51 | });
52 | api.getPortfolio();
53 | }
54 |
55 | function tradingTimesDemo() {
56 | api.events.on('trading_times', function(response) {
57 | console.log(response);
58 | });
59 | api.getTradingTimes();
60 | }
61 |
62 | api.events.on('*', function(response) {
63 | console.log('all', response);
64 | });
65 |
66 | console.log(api.events.messageHandlers);
67 |
68 | // tickHistoryPromiseDemo();
69 | pingPromiseDemo();
70 |
--------------------------------------------------------------------------------
/demos/advanced/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/demos/basic/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/demos/basic/index.js:
--------------------------------------------------------------------------------
1 | var LiveApi = window['binary-live-api'].LiveApi;
2 | var api = new LiveApi();
3 |
4 | function pingWithEventHandlers() {
5 | api.events.on('ping', function(response) {
6 | console.log(response);
7 | });
8 | api.ping();
9 | }
10 |
11 | function pingWithPromises() {
12 | api.ping().then(function(response) {
13 | console.log(response);
14 | });
15 | }
16 |
17 | function foreverPing() {
18 | setInterval(() => api.ping().then(response => console.log(response)), 1000);
19 | }
20 |
21 | api.subscribeToTick('R_100');
22 | api.unsubscribeFromTick('R_100');
23 |
24 | api.resubscribe();
25 |
--------------------------------------------------------------------------------
/demos/node/node-demo.js:
--------------------------------------------------------------------------------
1 | var ws = require('ws');
2 | var LiveApi = require('binary-live-api').LiveApi;
3 |
4 | var api = new LiveApi({ websocket: ws });
5 |
6 | function pingWithEventHandlers() {
7 | api.events.on('ping', function(response) {
8 | console.log(response);
9 | });
10 | api.ping();
11 | }
12 |
13 | function pingWithPromises() {
14 | api.ping().then(function(response) {
15 | console.log(response);
16 | });
17 | }
18 |
19 | pingWithEventHandlers();
20 |
--------------------------------------------------------------------------------
/demos/node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "node-demo",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "node-demo.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node server.js"
9 | },
10 | "author": "Boris Yankov (https://github.com/borisyankov)",
11 | "license": "ISC",
12 | "dependencies": {
13 | "binary-live-api": "*",
14 | "ws": "^7.0.0"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demos/node/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var webpack = require('webpack');
3 |
4 | module.exports = {
5 | devtool: 'eval',
6 | entry: [
7 | './demo'
8 | ],
9 | output: {
10 | path: path.join(__dirname, 'dist'),
11 | filename: 'bundle.js',
12 | publicPath: '/static/'
13 | },
14 | plugins: [
15 | new webpack.HotModuleReplacementPlugin(),
16 | new webpack.NoErrorsPlugin()
17 | ],
18 | resolve: {
19 | alias: {
20 | 'library-boilerplate': path.join(__dirname, '..', '..', 'src')
21 | },
22 | extensions: ['', '.js']
23 | },
24 | module: {
25 | loaders: [{
26 | test: /\.js$/,
27 | loaders: ['babel'],
28 | exclude: /node_modules/,
29 | include: __dirname
30 | }, {
31 | test: /\.js$/,
32 | loaders: ['babel'],
33 | include: path.join(__dirname, '..', '..', 'src')
34 | }]
35 | }
36 | };
37 |
--------------------------------------------------------------------------------
/demos/oauth/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/demos/oauth/index.js:
--------------------------------------------------------------------------------
1 | console.log(window['binary-live-api']);
2 | const { oauthUrl, parseOAuthResponse } = window['binary-live-api'].OAuth;
3 |
4 | const url = oauthUrl('id-ud5PPOTeBcEnkam7ArXIc4AO9e9gw');
5 |
6 | window.location = url;
7 |
8 | // const accounts = parseOAuthResponse(returnUrl);
9 |
--------------------------------------------------------------------------------
/docs/networkcalls.md:
--------------------------------------------------------------------------------
1 | ## Network calls api
2 |
3 | This library provide JS friendly wrapper for all network calls
4 |
5 | Details are documented at https://developers.binary.com/api/
6 |
7 | ### ADMIN
8 |
9 | * `deleteApiToken(token: string)`
10 |
11 | * `getApiTokens()`
12 |
13 | * `createApiToken(token: string, scopes: string[])`
14 |
15 | * `changePassword(oldPassword: string, newPassword: string)`
16 |
17 | * `registerApplication(options: Object)`
18 |
19 | * `getAllAppList()`
20 |
21 | * `getAppslistById(appid: number)`
22 |
23 | * `deleteApplication(appid: number)`
24 |
25 | * `createRealAccountMaltaInvest(options: Object)`
26 |
27 | * `createRealAccount(options: Object)`
28 |
29 | * `setAccountCurrency(currency: string)`
30 |
31 | * `setSelfExclusion(options: Object)`
32 |
33 | * `setAccountSettings(options: Object)`
34 |
35 | * `setTnCApproval()`
36 |
37 | ----
38 |
39 | ### PAYMENT
40 |
41 | * `getCashierLockStatus()`
42 |
43 | * `setCashierLock(options: Object)`
44 |
45 | * `withdrawToPaymentAgent(options: Object)`
46 |
47 | * `paymentAgentTransfer(options: Object)`
48 |
49 | * `transferBetweenAccounts(options: Object)`
50 |
51 |
52 | -----
53 |
54 | ### READ
55 |
56 | * `getAccountLimits()`
57 |
58 | * `getAccountSettings()`
59 |
60 | * `getAccountStatus()`
61 |
62 | * `getSelfExclusion()`
63 |
64 | * `logOut()`
65 |
66 | * `getStatement(options: Object)`
67 |
68 | * `getPortfolio()`
69 |
70 | * `getProfitTable(options: Object)`
71 |
72 | * `getRealityCheckSummary()`
73 |
74 | * `unsubscribeFromBalance()`
75 |
76 | * `subscribeToOpenContract(contractId: number)`
77 |
78 | * `getContractInfo(contractId: number)`
79 |
80 | * `subscribeToAllOpenContracts()`
81 |
82 | * `unsubscribeFromAllOpenContracts()`
83 |
84 | * `subscribeToTransactions()`
85 |
86 | * `unsubscribeFromTransactions()`
87 |
88 |
89 | ----
90 |
91 | ### TRADE
92 |
93 | * `buyContract(contractId: number, price: number)`
94 |
95 | * `sellContract(contractId: number, price: number)`
96 |
97 | * `sellExpiredContracts()`
98 |
99 | * `topUpVirtualAccount()`
100 |
101 |
102 | -----
103 |
104 | ### UNAUTHENTICATED
105 |
106 | * `getActiveSymbolsBrief()`
107 |
108 | * `getActiveSymbolsFull()`
109 |
110 | * `getAssetIndex()`
111 |
112 | * `authorize(token: string)`
113 |
114 | * `getContractsForSymbol(symbol: string)`
115 |
116 | * `unsubscribeFromTick(symbol: string)`
117 |
118 | * `unsubscribeFromTicks(symbols: string[])`
119 |
120 | * `unsubscribeByID(id: number)`
121 |
122 | * `unsubscribeFromAllTicks()`
123 |
124 | * `unsubscribeFromAllCandles()`
125 |
126 | * `unsubscribeFromAllProposals()`
127 |
128 | * `unsubscribeFromAllPortfolios()`
129 |
130 | * `unsubscribeFromAllProposalsOpenContract()`
131 |
132 | * `getLandingCompany(landingCompany: string)`
133 |
134 | * `getLandingCompanyDetails(landingCompany: string)`
135 |
136 | * `createVirtualAccount(options: Object)`
137 |
138 | * `ping()`
139 |
140 | * `getPaymentAgentsForCountry(countryCode: string)`
141 |
142 | * `getPayoutCurrencies()`
143 |
144 | * `getPriceProposalForContract(options: Object)`
145 |
146 | * `subscribeToPriceForContractProposal(options: Object)`
147 |
148 | * `getResidences()`
149 |
150 | * `getStatesForCountry(countryCode: string)`
151 |
152 | * `subscribeToTick(symbol: string)`
153 |
154 | * `subscribeToTicks(symbols: string[])`
155 |
156 | * `getTickHistory(symbol: string, options: Object)`
157 |
158 | * `getCandles(symbol: string, options: Object)`
159 |
160 | * `getCandlesForLastNDays(symbol: string, ndays: number)`
161 |
162 | * `getServerTime()`
163 |
164 | * `getTradingTimes(date: Date)`
165 |
166 | * `verifyEmail(email: string, type: string)`
167 |
168 | * `getWebsiteStatus()`
169 |
170 |
--------------------------------------------------------------------------------
/flow-typed/binary-api.js.flow:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-unused-vars */
2 | /* eslint-disable max-len */
3 |
4 | type Epoch = number;
5 |
6 | type TransactionAction = 'deposit' | 'withdrawal' | 'buy' | 'sell';
7 |
8 | type LandingCompany = 'japan' | 'costarica' | 'malta' | 'maltainvest' | 'iom';
9 |
10 | type MarketType = 'forex' | 'indices' | 'stocks' | 'commodities' | 'volidx';
11 |
12 | type DurationUnit = 'd' | 'm' | 's' | 'h' | 't';
13 |
14 | type AccessScope = 'read' | 'trade' | 'payments' | 'admin';
15 |
16 | declare class ApiRequest {
17 | req_id?: number,
18 | }
19 |
20 | declare class ApiResponse {
21 | msg_type: string,
22 | echo_req?: Object,
23 | req_id?: number,
24 | }
25 |
26 | type ApiErrorResponse = {
27 | msg_type: string,
28 | echo_req?: Object,
29 | error: {
30 | code: string,
31 | message: string,
32 | },
33 | }
34 |
35 |
36 | // active_symbols
37 |
38 | declare class ActiveSymbolsRequest extends ApiRequest {
39 | active_symbols: 'brief' | 'full',
40 | landing_company?: LandingCompany,
41 | }
42 |
43 | declare class ActiveSymbol {
44 | symbol: string,
45 | intraday_interval_minutes: number,
46 | symbol_type: string,
47 | exchange_is_open: ?number,
48 | exchange_name: string,
49 | delay_amount: number,
50 | display_name: string,
51 | spot: ?number,
52 | spot_time: string,
53 | is_trading_suspended: number,
54 | quoted_currency_symbol: string,
55 | spot_age: string,
56 | market: string,
57 | market_display_name: string,
58 | submarket: string,
59 | submarket_display_name: string,
60 | pip: number,
61 | }
62 |
63 | declare class ActiveSymbolsResponse extends ApiResponse {
64 | active_symbolsarray: ActiveSymbol[],
65 | }
66 |
67 | // TODO: asset_index
68 |
69 | declare class AssetIndexRequest extends ApiRequest {
70 | asset_index: 1,
71 | landing_company?: LandingCompany,
72 | }
73 |
74 | declare class AssetIndexResponse extends ApiResponse {
75 | asset_index: any[],
76 | }
77 |
78 | // authorize
79 |
80 | declare class AuthorizeRequest extends ApiRequest {
81 | authorize: string,
82 | }
83 |
84 | declare class AuthorizeResponse extends ApiResponse {
85 | authorize: {
86 | email: string,
87 | currency: string,
88 | balance: number,
89 | loginid: string,
90 | is_virtual: 0 | 1,
91 | landing_company_name: string,
92 | fullname: string,
93 | },
94 | }
95 |
96 | // contracts_for
97 |
98 | declare class ForwardStartingOption {
99 | close: Epoch,
100 | date: Epoch,
101 | open: Epoch,
102 | }
103 |
104 | declare class AvailableContractDetails {
105 | market: MarketType,
106 | contracts_display: string,
107 | max_contract_duration: string,
108 | barrier_category: string,
109 | payout_limit: number,
110 | submarket: string,
111 | exchange_name: string,
112 | contract_category_display: string,
113 | contract_type: string,
114 | min_contract_duration: string,
115 | sentiment: string,
116 | barriers: number,
117 | contract_category: string,
118 | start_type: string,
119 | expiry_type: string,
120 | underlying_symbol: string,
121 | forward_starting_options: ForwardStartingOption[],
122 | available_barriers?: number[],
123 | expired_barriers?: any[],
124 | trading_period?: {
125 | date_expiry: {
126 | date: string,
127 | epoch: Epoch,
128 | },
129 | date_start: {
130 | date: string,
131 | epoch: Epoch,
132 | },
133 | duration: string,
134 | }
135 | }
136 |
137 | declare class ContractsForRequest extends ApiRequest {
138 | contracts_for: string,
139 | currency?: string,
140 | region?: 'japan' | 'other',
141 | }
142 |
143 | declare class ContractsForResponse extends ApiResponse {
144 | contracts_for: {
145 | available: AvailableContractDetails,
146 | close: Epoch,
147 | open: Epoch,
148 | hit_count: number,
149 | spot: ?number,
150 | feed_license: string,
151 | },
152 | }
153 |
154 | // forget
155 |
156 | declare class ForgetRequest extends ApiRequest {
157 | forget: string,
158 | }
159 |
160 | declare class ForgetResponse extends ApiResponse {
161 | forget: 0 | 1,
162 | }
163 |
164 | // forget_all
165 |
166 | declare class ForgetAllRequest extends ApiRequest {
167 | forget_all: 'ticks' | 'candles' | 'proposal' | 'portfolio' | 'proposal_open_contract' | 'balance' | 'transaction' | 'pricing_table',
168 | }
169 |
170 | declare class ForgetAllResponse extends ApiResponse {
171 | forget_all: number[],
172 | }
173 |
174 | // get_corporate_actions
175 |
176 | declare class CorporateAction {
177 | display_date: string,
178 | type: number,
179 | value: number,
180 | modifier: string,
181 | }
182 |
183 | declare class CorporateActionsRequest extends ApiRequest {
184 | get_corporate_actions: 1,
185 | symbol: string,
186 | start: string,
187 | end: string,
188 | }
189 |
190 | declare class CorporateActionsResponse extends ApiResponse {
191 | get_corporate_actions: {
192 | actions: CorporateAction[],
193 | }
194 | }
195 |
196 | // landing_company
197 |
198 | declare class LandingCompanyDetails {
199 | id: string,
200 | name: string,
201 | gaming_company: {
202 | shortcode: string,
203 | name: string,
204 | address: string[],
205 | country: string,
206 | legal_default_currency: string,
207 | legal_allowed_currencies: string[],
208 | legal_allowed_markets: string[],
209 | has_reality_check: 0 | 1,
210 | },
211 | }
212 |
213 | declare class LandingCompanyRequest extends ApiRequest {
214 | landing_company: string,
215 | }
216 |
217 | declare class LandingCompanyResponse extends ApiResponse {
218 | landing_company: LandingCompanyDetails,
219 | }
220 |
221 | // landing_company_details
222 |
223 | declare class LandingCompanyDetailsRequest extends ApiRequest {
224 | landing_company_details: string,
225 | }
226 |
227 | declare class LandingCompanyDetailsResponse extends ApiResponse {
228 | landing_company_details: LandingCompanyDetails,
229 | }
230 |
231 | // new_account_virtual
232 |
233 | declare class NewAccountVirtualRequest extends ApiRequest {
234 | new_account_virtual: 1,
235 | verification_code: string,
236 | client_password: string,
237 | residence: string,
238 | affiliate_token?: string,
239 | utm_source?: string,
240 | utm_medium?: string,
241 | utm_campaign?: string,
242 | }
243 |
244 | declare class NewAccountVirtualResponse extends ApiResponse {
245 | new_account_virtual: {
246 | client_id: string,
247 | email: string,
248 | currency: string,
249 | balance: number,
250 | oauth_token: string,
251 | },
252 | }
253 |
254 | // ping
255 |
256 | declare class PingRequest extends ApiRequest {
257 | ping: 1,
258 | }
259 |
260 | declare class PingResponse extends ApiResponse {
261 | ping: 'pong',
262 | }
263 |
264 | // paymentagent_list
265 |
266 | declare class PaymentAgentDetails {
267 | currencies: string,
268 | deposit_commission: string,
269 | email: string,
270 | further_information: string,
271 | name: string,
272 | paymentagent_loginid: string,
273 | summary: string,
274 | supported_banks: string,
275 | telephone: string,
276 | url: string,
277 | withdrawal_commission: string,
278 | }
279 |
280 | declare class PaymentAgentListRequest extends ApiRequest {
281 | paymentagent_list: string,
282 | }
283 |
284 | declare class PaymentAgentListResponse extends ApiResponse {
285 | paymentagent_list: {
286 | available_countries: any[],
287 | list: PaymentAgentDetails[],
288 | }
289 | }
290 |
291 | // payout_currencies
292 |
293 | declare class PayoutCurrenciesRequest extends ApiRequest {
294 | payout_currencies: 1,
295 | }
296 |
297 | declare class PayoutCurrenciesResponse extends ApiResponse {
298 | payout_currencies: string[],
299 | }
300 |
301 | // proposal
302 |
303 | // TODO
304 |
305 | // residence_list
306 |
307 | declare class ResidenceListRequest extends ApiRequest {
308 | residence_list: 1,
309 | }
310 |
311 | declare class ResidenceListResponse extends ApiResponse {
312 | residence_list: string[],
313 | }
314 |
315 | // states_list
316 |
317 | declare class StatesListRequest extends ApiRequest {
318 | states_list: 1,
319 | }
320 |
321 | declare class StatesListResponse extends ApiResponse {
322 | states_list: string[],
323 | }
324 |
325 | // ticks
326 |
327 | declare class TickSpotData {
328 | epoch: Epoch,
329 | id: string,
330 | quote: number,
331 | symbol: string,
332 | }
333 |
334 | declare class TicksRequest extends ApiRequest {
335 | ticks: string | string[],
336 | subscribe?: 1,
337 | }
338 |
339 | declare class TicksResponse extends ApiResponse {
340 | tick: TickSpotData,
341 | }
342 |
343 | // ticks_history
344 |
345 | declare class TickHistoryRequest extends ApiRequest {
346 | ticks_history: string | string[],
347 | end?: Epoch | 'latest',
348 | start: Epoch,
349 | count: number,
350 | style: 'candles' | 'ticks',
351 | granularity?: number,
352 | adjust_start_time?: 1,
353 | subscribe?: 1,
354 | }
355 |
356 | declare class TickHistoryResponse extends ApiResponse {
357 | history?: {
358 | times: Epoch[],
359 | prices: number,
360 | },
361 | candles?: Candle[],
362 | }
363 |
364 | // time
365 |
366 | declare class TimeRequest extends ApiRequest {
367 | time: 1,
368 | }
369 |
370 | declare class TimeResponse extends ApiResponse {
371 | time: Epoch,
372 | }
373 |
374 | // trading_times
375 |
376 | declare class TradingTimesRequest extends ApiRequest {
377 | trading_times: string,
378 | }
379 |
380 | declare class TradingTimesResponse extends ApiResponse {
381 | trading_times: {
382 | markets: any[],
383 | }
384 | }
385 |
386 | // verify_email
387 |
388 | declare class VerifyEmailRequest extends ApiRequest {
389 | verify_email: string,
390 | type: 'account_opening' | 'reset_password' | 'paymentagent_withdraw' | 'payment_withdraw',
391 | }
392 |
393 | declare class VerifyEmailResponse extends ApiResponse {
394 | verify_email: 1,
395 | }
396 |
397 | // website_status
398 |
399 | declare class WebsiteStatus {
400 | terms_conditions_version: string,
401 | api_call_limits: {
402 | max_proposal_subscription: {
403 | applies_to: string,
404 | max: number,
405 | },
406 | max_requestes_general: {
407 | applies_to: string,
408 | hourly: number,
409 | minutely: number,
410 | },
411 | max_requests_outcome: {
412 | applies_to: string,
413 | hourly: number,
414 | minutely: number,
415 | },
416 | max_requests_pricing: {
417 | applies_to: string,
418 | hourly: number,
419 | minutely: number,
420 | }
421 | },
422 | clients_country: string,
423 | }
424 |
425 | declare class WebsiteStatusRequest extends ApiRequest {
426 | website_status: 1,
427 | }
428 |
429 | declare class WebsiteStatusResponse extends ApiResponse {
430 | website_status: WebsiteStatus,
431 | }
432 |
433 | // get_limits
434 |
435 | declare class AccountLimits {
436 | account_balance: number,
437 | daily_turnover: number,
438 | open_positions: number,
439 | payout: number,
440 | lifetime_limit: number,
441 | num_of_days: number,
442 | num_of_days_limit: number,
443 | remainder: number,
444 | withdrawal_for_x_days_monetary: number,
445 | }
446 |
447 | declare class AccountLimitsRequest extends ApiRequest {
448 | get_limits: 1,
449 | }
450 |
451 | declare class AccountLimitsResponse extends ApiResponse {
452 | get_limits: AccountLimits,
453 | }
454 |
455 | // get_settings
456 |
457 | declare class AccountSettings {
458 | email: string,
459 | country: ?string,
460 | country_code: ?string,
461 | salutation: string,
462 | first_name: string,
463 | last_name: string,
464 | date_of_birth: ?number,
465 | address_line_1: string,
466 | address_line_2: string,
467 | address_city: string,
468 | address_state: string,
469 | address_postcode: string,
470 | phone: string,
471 | is_authenticated_payment_agent: number,
472 | jp_account_status: {
473 | status: 'activated' | 'jp_knowledge_test_pending' | 'jp_knowledge_test_fail' | 'jp_activation_pending' | 'disabled',
474 | last_test_epoch: number,
475 | next_test_epoch: number,
476 | },
477 | jp_settings: {
478 | gender: 'm' | 'f',
479 | occupation: 'Office worker' | 'Director' | 'Public worker' | 'Self-employed Housewife / Househusband' | 'Contract / Temporary / Part Time Student' | 'Unemployed' | 'Others',
480 | annual_income: 'Less than 1 million JPY' | '1-3 million JPY' | '3-5 million JPY' | '5-10 million JPY' | '10-30 million JPY' | '30-50 million JPY' | '50-100 million JPY' | 'Over 100 million JPY',
481 | financial_asset: 'Less than 1 million JPY' | '1-3 million JPY' | '3-5 million JPY' | '5-10 million JPY' | '10-30 million JPY' | '30-50 million JPY' | '50-100 million JPY' | 'Over 100 million JPY',
482 | daily_loss_limit: number,
483 | trading_experience_equities: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
484 | trading_experience_commodities: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
485 | trading_experience_foreign_currency_deposit: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
486 | trading_experience_margin_fx: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
487 | trading_experience_investment_trust: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
488 | trading_experience_public_bond: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
489 | trading_experience_option_trading: 'No experience' |'Less than 6 months' | '6 months to 1 year' | '1-3 years' | '3-5 years' | 'Over 5 years',
490 | trading_purpose: 'Targeting short-term profits' | 'Targeting medium-term / long-term profits' | 'Both the above Hedging',
491 | hedge_asset: 'Foreign currency deposit' | 'Margin FX' | 'Other',
492 | hedge_asset_amount: ?number,
493 | }
494 | }
495 |
496 | declare class AccountSettingsRequest extends ApiRequest {
497 | get_settings: 1,
498 | }
499 |
500 | declare class AccountSettingsResponse extends ApiResponse {
501 | get_settings: AccountSettings,
502 | }
503 |
504 | // get_account_status
505 |
506 | declare class AccountStatus {
507 | status: string[],
508 | risk_classification: 'low' | 'standard' | 'high',
509 | }
510 |
511 | declare class AccountStatusRequest extends ApiRequest {
512 | get_account_status: 1,
513 | }
514 |
515 | declare class AccountStatusResponse extends ApiResponse {
516 | get_account_status: AccountStatus,
517 | }
518 |
519 | // balance
520 |
521 | declare class Balance {
522 | balance: number,
523 | currency: string,
524 | loginid: string,
525 | id: string,
526 | }
527 |
528 | declare class BalanceRequest extends ApiRequest {
529 | balance: 1,
530 | subscribe?: 1,
531 | }
532 |
533 | declare class BalanceResponse extends ApiResponse {
534 | balance: Balance,
535 | }
536 |
537 | // get_self_exclusion
538 |
539 | declare class SelfExclusionSettings {
540 | max_balance: number,
541 | max_turnover: number,
542 | max_losses: number,
543 | max_7day_turnover: number,
544 | max_7day_losses: number,
545 | max_30day_turnover: number,
546 | max_30day_losses: number,
547 | max_open_bets: number,
548 | session_duration_limit: number,
549 | exclude_until: string,
550 | timeout_until: number,
551 | }
552 |
553 | declare class SelfExclusionRequest extends ApiRequest {
554 | get_self_exclusion: 1,
555 | }
556 |
557 | declare class SelfExclusionResponse extends ApiResponse {
558 | get_self_exclusion: SelfExclusionSettings,
559 | }
560 |
561 | // login_history
562 |
563 | declare class LoginHistoryEntry {
564 | time: Epoch,
565 | action: string,
566 | environment: string,
567 | status: 0 | 1,
568 | }
569 |
570 | declare class LoginHistoryRequest extends ApiRequest {
571 | login_history: 1,
572 | limit: number,
573 | }
574 |
575 | declare class LoginHistoryResponse extends ApiResponse {
576 | login_history: LoginHistoryEntry[],
577 | }
578 |
579 | // logout
580 |
581 | declare class LogoutRequest extends ApiRequest {
582 | logout: 1,
583 | }
584 |
585 | declare class LogoutResponse extends ApiResponse {
586 | logout: number,
587 | }
588 |
589 | // statement
590 |
591 | declare class StatementTransaction {
592 | balance_after: number,
593 | transaction_id: number,
594 | contract_id: ?number,
595 | transaction_time: Epoch,
596 | purchase_time: Epoch,
597 | action_type: TransactionAction,
598 | amount: number,
599 | longcode: string,
600 | shortcode: ?string,
601 | payout: ?number,
602 | app_id: ?number,
603 | }
604 |
605 | declare class StatementOptions {
606 | description?: 1,
607 | limit: number,
608 | offset: number,
609 | date_from: Epoch,
610 | date_to: Epoch,
611 | action_type: 'buy' | 'sell' | 'deposit' | 'withdrawal',
612 | }
613 |
614 | declare class StatementRequest extends ApiRequest mixins StatementOptions {
615 | statement: 1,
616 | }
617 |
618 | declare class StatementResponse extends ApiResponse {
619 | statement: {
620 | count: number,
621 | transactions: StatementTransaction[],
622 | }
623 | }
624 |
625 | // portfolio
626 |
627 | declare class OpenContract {
628 | contract_id: number,
629 | transaction_id: number,
630 | purchase_time: Epoch,
631 | symbol: string,
632 | payout: number,
633 | buy_price: number,
634 | date_start: Epoch,
635 | expiry_time: Epoch,
636 | contract_type: ContractType,
637 | currency: string,
638 | longcode: string,
639 | app_id: ?number,
640 | }
641 |
642 | declare class PortfolioRequest extends ApiRequest {
643 | portfolio: 1,
644 | }
645 |
646 | declare class PortfolioResponse extends ApiResponse {
647 | portfolio: {
648 | contracts: OpenContract[],
649 | }
650 | }
651 |
652 | // profit_table
653 |
654 | declare class ProfitTableTransaction {
655 | transaction_id: number,
656 | contract_id: ?number,
657 | purchase_time: Epoch,
658 | sell_time: Epoch,
659 | buy_price: number,
660 | sell_price: number,
661 | longcode: string,
662 | shortcode: string,
663 | payout: number,
664 | app_id: ?number,
665 | }
666 |
667 | declare class ProfitTableOptions {
668 | description?: 1,
669 | limit: number,
670 | offset: number,
671 | date_from: string,
672 | date_to: string,
673 | sort: 'ASC' | 'DESC',
674 | }
675 |
676 | declare class ProfitTableRequest extends ApiRequest mixins ProfitTableOptions {
677 | profit_table: 1,
678 | }
679 |
680 | declare class ProfitTableResponse extends ApiResponse {
681 | profit_table: {
682 | count: number,
683 | transactions: ProfitTableTransaction[],
684 | }
685 | }
686 |
687 | // proposal_open_contract
688 |
689 | declare class PriceProposal {
690 | high_barrier?: number,
691 | low_barrier?: number,
692 | barrier?: number,
693 | original_high_barrier?: number,
694 | original_low_barrier?: number,
695 | original_barrier?: number,
696 | barrier_count: number,
697 | bid_price: number,
698 | contract_id: number,
699 | contract_type: string,
700 | currency: string,
701 | current_spot?: number,
702 | current_spot_time: Epoch,
703 | entry_spot?: number,
704 | date_expiry?: Epoch,
705 | date_settlement?: Epoch,
706 | date_start?: Epoch,
707 | id: string,
708 | has_corporate_actions: 0 | 1,
709 | is_expired: 0 | 1,
710 | is_forward_starting: 0 | 1,
711 | is_intraday: 0 | 1,
712 | is_path_dependent: number,
713 | is_valid_to_sell: 0 | 1,
714 | longcode: string,
715 | payout: number,
716 | shortcode: string,
717 | display_value: number,
718 | underlying: string,
719 | display_name: string,
720 | entry_tick: number,
721 | entry_tick_time: Epoch,
722 | exit_tick: number,
723 | exit_tick_time: Epoch,
724 | tick_count: number,
725 | validation_error?: string,
726 | sell_price?: number,
727 | buy_price: number,
728 | purchase_time?: Epoch,
729 | sell_time?: Epoch,
730 | sell_spot: number,
731 | sell_spot_time?: Epoch,
732 | entry_level?: number,
733 | amount_per_point?: string,
734 | stop_loss_level?: number,
735 | stop_profit_level?: number,
736 | current_level?: number,
737 | exit_level?: number,
738 | current_value_in_dollar?: number,
739 | current_value_in_point?: number,
740 | transaction_ids: string[],
741 | }
742 |
743 | declare class ProposalOpenContractRequest extends ApiRequest {
744 | proposal_open_contract: 1,
745 | contract_id: number,
746 | subscribe?: 1,
747 | }
748 |
749 | declare class ProposalOpenContractResponse extends ApiResponse {
750 | proposal_open_contract: LoginHistoryEntry[],
751 | }
752 |
753 | // reality_check
754 |
755 | declare class RealityCheckSummary {
756 | start_time: Epoch,
757 | loginid: string,
758 | currency: string,
759 | buy_count: number,
760 | buy_amount: number,
761 | sell_count: number,
762 | sell_amount: number,
763 | potential_profit: number,
764 | open_contract_count: number,
765 | }
766 |
767 | declare class RealityCheckRequest extends ApiRequest {
768 | reality_check: 1,
769 | }
770 |
771 | declare class RealityCheckResponse extends ApiResponse {
772 | reality_check: RealityCheckSummary,
773 | }
774 |
775 | // transaction
776 |
777 | declare class TrasnactionUpdate {
778 | balance: number,
779 | action: TransactionAction,
780 | contract_id: number,
781 | transaction_id: number,
782 | amount: number,
783 | id: string,
784 | transaction_time: Epoch,
785 | purchase_time: Epoch,
786 | currency: string,
787 | longcode: string,
788 | symbol: string,
789 | display_name: string,
790 | date_expiry: Epoch,
791 | }
792 |
793 | declare class TransactionRequest extends ApiRequest {
794 | transaction: 1,
795 | subscribe?: 1,
796 | }
797 |
798 | declare class TransactionResponse extends ApiResponse {
799 | transaction: TrasnactionUpdate,
800 | }
801 |
802 | // buy
803 |
804 | declare class BuyContractParameters {
805 | amount: number,
806 | basis: 'payout' | 'stake',
807 | contract_type: string,
808 | currency: string,
809 | date_start: Epoch,
810 | date_expiry: Epoch,
811 | duration: number,
812 | duration_unit: DurationUnit,
813 | symbol: string,
814 | barrier: string,
815 | barrier2: string,
816 | }
817 |
818 | declare class BuySpreadContractParameters extends BuyContractParameters {
819 | amount_per_point: number,
820 | stop_typee: 'dollar' | 'point',
821 | stop_profit: number,
822 | stop_loss: number,
823 | }
824 |
825 | declare class ReceiptConfirmation {
826 | balance_after: number,
827 | longcode: string,
828 | shortcode: string,
829 | start_time: Epoch,
830 | contract_id: number,
831 | buy_price: number,
832 | purchase_time: Epoch,
833 | transaction_id: number,
834 | }
835 |
836 | declare class SpreadReceiptConfirmation extends ReceiptConfirmation {
837 | amount_per_point: number,
838 | stop_profit_level: number,
839 | stop_loss_level: number,
840 | payout: number,
841 | }
842 |
843 | declare class BuyContractRequest extends ApiRequest {
844 | buy: string,
845 | price: number,
846 | parameters: BuyContractParameters,
847 | }
848 |
849 | declare class BuyContractResponse extends ApiResponse {
850 | buy: ReceiptConfirmation,
851 | }
852 |
853 | // buy_contract_for_multiple_accounts
854 |
855 | declare class BuyContractForMultipleAccountsRequest extends ApiRequest {
856 | buy_contract_for_multiple_accounts: 1,
857 | tokens: string[],
858 | price: number,
859 | parameters: BuyContractParameters,
860 | }
861 |
862 | declare class BuyContractForMultipleAccountsResponse extends ApiResponse {
863 | buy_contract_for_multiple_accounts: {
864 | result: ReceiptConfirmation[],
865 | },
866 | }
867 |
868 | // sell
869 |
870 | declare class SellReceipt {
871 | balance_after: number,
872 | contract_id: number,
873 | sold_for: number,
874 | transaction_id: number,
875 | }
876 |
877 | declare class SellContractRequest extends ApiRequest {
878 | sell: number,
879 | price: number,
880 | }
881 |
882 | declare class SellContractResponse extends ApiResponse {
883 | sell: SellReceipt,
884 | }
885 |
886 | // sell_expired
887 |
888 | declare class SellExpiredContractsRequest extends ApiRequest {
889 | sell_expired: 1,
890 | }
891 |
892 | declare class SellExpiredContractsResponse extends ApiResponse {
893 | sell_expired: {
894 | count: number,
895 | },
896 | }
897 |
898 | // topup_virtual
899 |
900 | declare class TopUpVirtualRequest extends ApiRequest {
901 | topup_virtual: 1,
902 | }
903 |
904 | declare class TopUpVirtualResponse extends ApiResponse {
905 | topup_virtual: {
906 | currency: string,
907 | amount: number,
908 | },
909 | }
910 |
911 | // api_token
912 |
913 | declare class ApiTokenManagementRequest extends ApiRequest {
914 | api_token: 1,
915 | new_token: string,
916 | new_token_scope: AccessScope[],
917 | delete_token: string,
918 | sub_account: string,
919 | }
920 |
921 | declare class ApiTokenManagementResponse extends ApiResponse {
922 | api_token: {
923 | tokens: string[],
924 | new_token?: 1,
925 | delete_token?: 1,
926 | sub_account: string,
927 | },
928 | }
929 |
930 | // app_register
931 |
932 | declare class ApplicationDetails {
933 | name: string,
934 | scopes: AccessScope[],
935 | homepage?: string,
936 | github?: string,
937 | appstore?: string,
938 | googleplay: string,
939 | redirect_uri: string,
940 | app_markup_percentage?: number,
941 | }
942 |
943 | declare class ApplicationRegisterRequest extends ApiRequest mixins ApplicationDetails {
944 | app_register: 1,
945 | }
946 |
947 | declare class ApplicationRegisterResponse extends ApiResponse {
948 | app_register: ApplicationDetails,
949 | }
950 |
951 | // app_list
952 |
953 | declare class ApplicationListRequest extends ApiRequest {
954 | app_list: 1,
955 | }
956 |
957 | declare class ApplicationListResponse extends ApiResponse {
958 | app_list: ApplicationDetails[],
959 | }
960 |
961 | // app_get
962 |
963 | declare class ApplicationDetailsRequest extends ApiRequest {
964 | app_get: number,
965 | }
966 |
967 | declare class ApplicationDetailsResponse extends ApiResponse {
968 | app_get: ApplicationDetails,
969 | }
970 |
971 | // app_delete
972 |
973 | declare class ApplicationDeleteRequest extends ApiRequest {
974 | app_delete: number,
975 | }
976 |
977 | declare class ApplicationDeleteResponse extends ApiResponse {
978 | app_delete: 1,
979 | }
980 |
981 | // app_update
982 |
983 | declare class ApplcationUpdateRequest extends ApiRequest mixins ApplicationDetails {
984 | app_update: 1,
985 | }
986 |
987 | declare class ApplcationUpdateResponse extends ApiResponse {
988 | app_update: ApplicationDetails,
989 | }
990 |
991 | // oauth_apps
992 |
993 | declare class OAuthApplication {
994 | name: string,
995 | app_id: number,
996 | last_used?: string,
997 | scopes: AccessScope[],
998 | app_markup_percentage: number,
999 | }
1000 |
1001 | declare class OAuthApplicationsRequest extends ApiRequest {
1002 | oauth_apps: 1,
1003 | revoke_app: number,
1004 | }
1005 |
1006 | declare class OAuthApplicationsResponse extends ApiResponse {
1007 | oauth_apps: OAuthApplication[],
1008 | }
1009 |
1010 | // change_password
1011 |
1012 | declare class ChangePasswordRequest extends ApiRequest {
1013 | change_password: 1,
1014 | old_password: string,
1015 | new_password: string,
1016 | }
1017 |
1018 | declare class ChangePasswordResponse extends ApiResponse {
1019 | change_password: 1,
1020 | }
1021 |
1022 | // jp_knowledge_test
1023 |
1024 | declare class JapanKnowledgeTestRequest extends ApiRequest {
1025 | jp_knowledge_test: 1,
1026 | score: number,
1027 | status: 'pass' | 'fail',
1028 | }
1029 |
1030 | declare class JapanKnowledgeTestResponse extends ApiResponse {
1031 | jp_knowledge_test: {
1032 | test_taken_epoch: Epoch,
1033 | },
1034 | }
1035 |
1036 | // get_financial_assessment
1037 |
1038 | declare class FinancialAssessmentDetails {
1039 | score: number,
1040 | forex_trading_frequency: string,
1041 | forex_trading_experience: string,
1042 | indices_trading_frequency: string,
1043 | indices_trading_experience: string,
1044 | commodities_trading_frequency: string,
1045 | commodities_trading_experience: string,
1046 | stocks_trading_experience: string,
1047 | stocks_trading_frequency: string,
1048 | other_derivatives_trading_frequency: string,
1049 | other_derivatives_trading_experience: string,
1050 | other_instruments_trading_frequency: string,
1051 | other_instruments_trading_experience: string,
1052 | employment_industry: string,
1053 | education_level: string,
1054 | income_source: string,
1055 | net_income: string,
1056 | estimated_worth: string,
1057 | }
1058 |
1059 | declare class GetFinancialAssesmentRequest extends ApiRequest {
1060 | get_financial_assessment: 1,
1061 | }
1062 |
1063 | declare class GetFinancialAssesmentResponse extends ApiResponse {
1064 | get_financial_assessment: FinancialAssessmentDetails,
1065 | }
1066 |
1067 | // set_financial_assessment
1068 |
1069 | declare class SetFinancialAssessmentRequest extends ApiRequest mixins FinancialAssessmentDetails {
1070 | set_financial_assessment: 1,
1071 | }
1072 |
1073 | declare class SetFinancialAssessmentResponse extends ApiResponse {
1074 | set_financial_assessment: FinancialAssessmentDetails,
1075 | }
1076 |
1077 | // new_account_maltainvest
1078 |
1079 | declare class CreateMaltainvestAccountOptions {
1080 | salutation: 'Mr' | 'Mrs' | 'Ms' | 'Miss',
1081 | first_name: string,
1082 | last_name: string,
1083 | date_of_birth: string,
1084 | residence: string,
1085 | address_line_1: string,
1086 | address_line_2?: string,
1087 | address_city: string,
1088 | address_state?: string,
1089 | address_postcode?: string,
1090 | phone: string,
1091 | secret_question: string,
1092 | secret_answer: string,
1093 | affiliate_token?: string,
1094 | forex_trading_experience: string,
1095 | forex_trading_frequency: string,
1096 | indices_trading_experience: string,
1097 | indices_trading_frequency: string,
1098 | commodities_trading_experience: string,
1099 | commodities_trading_frequency: string,
1100 | stocks_trading_experience: string,
1101 | stocks_trading_frequency: string,
1102 | other_derivatives_trading_experience: string,
1103 | other_derivatives_trading_frequency: string,
1104 | other_instruments_trading_experience: string,
1105 | other_instruments_trading_frequency: string,
1106 | employment_industry: string,
1107 | education_level: string,
1108 | income_source: string,
1109 | net_income: string,
1110 | estimated_worth: string,
1111 | accept_risk: number,
1112 | }
1113 |
1114 | declare class CreateMaltainvestAccountRequest extends ApiRequest mixins CreateMaltainvestAccountOptions {
1115 | new_account_maltainvest: 1,
1116 | }
1117 |
1118 | declare class CreateMaltainvestAccountResponse extends ApiResponse {
1119 | new_account_maltainvest: {
1120 | client_id: string,
1121 | landing_company: string,
1122 | landing_company_short: string,
1123 | oauth_token: string,
1124 | },
1125 | }
1126 |
1127 | // new_account_real
1128 |
1129 | declare class CreateRealAccountOptions {
1130 | salutation: 'Mr' | 'Mrs' | 'Ms' | 'Miss',
1131 | first_name: string,
1132 | last_name: string,
1133 | date_of_birth: string,
1134 | residence: string,
1135 | address_line_1: string,
1136 | address_line_2?: string,
1137 | address_city: string,
1138 | address_state?: string,
1139 | address_postcode?: string,
1140 | phone: string,
1141 | secret_question: string,
1142 | secret_answer: string,
1143 | affiliate_token?: string,
1144 | }
1145 |
1146 | declare class CreateRealAccountRequest extends ApiRequest mixins CreateRealAccountOptions {
1147 | new_account_real: 1,
1148 | }
1149 |
1150 | declare class CreateRealAccountResponse extends ApiResponse {
1151 | new_account_real: {
1152 | client_id: string,
1153 | landing_company: string,
1154 | landing_company_short: string,
1155 | oauth_token: string,
1156 | },
1157 | }
1158 |
1159 | // new_sub_account
1160 |
1161 | declare class CreateRealSubAccountRequest extends ApiRequest {
1162 | new_account_real: 1,
1163 | salutation: 'Mr' | 'Mrs' | 'Ms' | 'Miss',
1164 | first_name: string,
1165 | last_name: string,
1166 | date_of_birth: string,
1167 | residence: string,
1168 | address_line_1: string,
1169 | address_line_2?: string,
1170 | address_city: string,
1171 | address_state?: string,
1172 | address_postcode?: string,
1173 | phone: string,
1174 | secret_question: string,
1175 | secret_answer: string,
1176 | affiliate_token?: string,
1177 | }
1178 |
1179 | declare class CreateRealSubAccountResponse extends ApiResponse {
1180 | new_account_real: {
1181 | client_id: string,
1182 | landing_company: string,
1183 | landing_company_short: string,
1184 | },
1185 | }
1186 |
1187 | // set_account_currency
1188 |
1189 | declare class SetAccountCurrencyRequest extends ApiRequest {
1190 | set_account_currency: string,
1191 | }
1192 |
1193 | declare class SetAccountCurrencyResponse extends ApiResponse {
1194 | set_account_currency: 0 | 1,
1195 | }
1196 |
1197 | // set_self_exclusion
1198 |
1199 | declare class SetSelfExclusionRequest extends ApiRequest mixins SelfExclusionSettings {
1200 | set_self_exclusion: 1,
1201 | }
1202 |
1203 | declare class SetSelfExclusionResponse extends ApiResponse {
1204 | set_self_exclusion: 1,
1205 | }
1206 |
1207 | // set_settings
1208 |
1209 | declare class SetSettingsRequest extends ApiRequest mixins AccountSettings {
1210 | set_settings: 1,
1211 | }
1212 |
1213 | declare class SetSettingsResponse extends ApiResponse {
1214 | set_settings: 1,
1215 | }
1216 |
1217 | // tnc_approval
1218 |
1219 | declare class TncApprovalRequest extends ApiRequest {
1220 | tnc_approval: 1,
1221 | ukgc_funds_protection: 1,
1222 | }
1223 |
1224 | declare class TncApprovalResponse extends ApiResponse {
1225 | tnc_approval: 1,
1226 | }
1227 |
1228 | // cashier
1229 |
1230 | declare class CashierRequest extends ApiRequest {
1231 | cashier: 'deposit' | 'withdraw',
1232 | verification_code: string,
1233 | }
1234 |
1235 | declare class CashierResponse extends ApiResponse {
1236 | cashier: string,
1237 | }
1238 |
1239 | // cashier_password
1240 |
1241 | declare class CashierPasswordRequest extends ApiRequest {
1242 | cashier_password: 1,
1243 | unlock_password: string,
1244 | lock_password: string,
1245 | }
1246 |
1247 | declare class CashierPasswordResponse extends ApiResponse {
1248 | cashier_password: 0 | 1,
1249 | }
1250 |
1251 | // paymentagent_withdraw
1252 |
1253 | declare class PaymentAgentWithdrawRequest extends ApiRequest {
1254 | paymentagent_withdraw: 1,
1255 | paymentagent_loginid: string,
1256 | currency: string,
1257 | amount: number,
1258 | verification_code: string,
1259 | description: string,
1260 | dry_run?: 1,
1261 | }
1262 |
1263 | declare class PaymentAgentWithdrawResponse extends ApiResponse {
1264 | paymentagent_withdraw: 1 | 2,
1265 | paymentagent_name: string,
1266 | transaction_id: number,
1267 | }
1268 |
1269 | // paymentagent_transfer
1270 |
1271 | declare class PaymentAgentTransferRequest extends ApiRequest {
1272 | paymentagent_transfer: 1,
1273 | transfer_to: string,
1274 | currency: string,
1275 | amount: number,
1276 | dry_run?: 1,
1277 | }
1278 |
1279 | declare class PaymentAgentTransferResponse extends ApiResponse {
1280 | paymentagent_transfer: 1 | 2,
1281 | client_to_full_name: string,
1282 | client_to_loginid: string,
1283 | transaction_id: number,
1284 | }
1285 |
1286 | // transfer_between_accounts
1287 |
1288 | declare class Account {
1289 | loginid: string,
1290 | balance: string,
1291 | currency: string,
1292 | }
1293 |
1294 | declare class TransferBetweenAccountsRequest extends ApiRequest {
1295 | transfer_between_accounts: 1,
1296 | account_from: string,
1297 | account_to: string,
1298 | currency: string,
1299 | amount: number,
1300 | }
1301 |
1302 | declare class TransferBetweenAccountsResponse extends ApiResponse {
1303 | transfer_between_accounts: number,
1304 | accounts: Account[],
1305 | client_to_full_name: string,
1306 | client_to_loginid: string,
1307 | transaction_id: number,
1308 | }
1309 |
--------------------------------------------------------------------------------
/flow-typed/binary-live-api.js.flow:
--------------------------------------------------------------------------------
1 | type LivePromise = Promise