Skip to content

Commit

Permalink
feat: Add login
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Dec 4, 2020
0 parents commit 27988ba
Show file tree
Hide file tree
Showing 27 changed files with 2,981 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
4 changes: 4 additions & 0 deletions .env.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://www.ig.com/de/myig/settings/api-keys
IG_API_KEY=""
IG_USERNAME=""
IG_PASSWORD=""
95 changes: 95 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"env": {
"browser": true,
"node": true
},
"extends": ["prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 8,
"project": "./tsconfig.json",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "typescript-sort-keys", "prettier"],
"rules": {
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/member-ordering": [
"error",
{
"default": [
"public-instance-field",
"private-instance-field",
"public-constructor",
"private-constructor",
"public-instance-method",
"protected-instance-method",
"private-instance-method"
]
}
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/typedef": "off",
"curly": "error",
"dot-notation": "error",
"no-console": [
"error",
{
"allow": ["error", "info", "warn"]
}
],
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-inner-declarations": "error",
"no-lonely-if": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-unused-vars": "off",
"no-useless-return": "error",
"no-var": "error",
"one-var": ["error", "never"],
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-promise-reject-errors": "error",
"prettier/prettier": "error",
"sort-imports": "off",
"sort-keys": [
"warn",
"asc",
{
"caseSensitive": true,
"natural": true
}
],
"sort-vars": "error",
"space-in-parens": "error",
"strict": ["error", "global"],
"typescript-sort-keys/interface": ["warn", "asc", {"caseSensitive": false}],
"typescript-sort-keys/string-enum": ["warn", "asc", {"caseSensitive": false}]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"no-dupe-class-members": "off"
}
}
]
}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.env
*hot-update.js*
.cache
.DS_Store
.idea/
.nyc_output/
.vscode/
.yarnclean
config.json
coverage/
dist/
lerna-debug.log
node_modules/
npm-debug.log*
package-lock.json
yarn-error.log
5 changes: 5 additions & 0 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "pretty-quick --staged && lint-staged"
}
}
3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,jsx,ts,tsx}": ["yarn fix:code"]
}
13 changes: 13 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"jsxBracketSameLine": true,
"printWidth": 120,
"proseWrap": "never",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry "https://registry.npmjs.org/"
save-prefix ""
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Benny Neugebauer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# IG Trading API

Unofficial [IG Trading API](https://labs.ig.com/rest-trading-api-guide) for Node.js, written in TypeScript.

## Useful links

- [IG REST Trading API Reference](https://labs.ig.com/rest-trading-api-reference)
- [IG API Companion](https://labs.ig.com/sample-apps/api-companion/index.html)
20 changes: 20 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: '70...100'

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: 'reach,diff,flags,tree'
behavior: default
require_changes: no
Empty file added docs/.nojekyll
Empty file.
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Home](/)
- [API](/globals.md)
27 changes: 27 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>IG Trading API for Node.js, written in TypeScript.</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="IG Trading API for Node.js, written in TypeScript." />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<link rel="stylesheet" href="//unpkg.com/docsify@4.11.6/lib/themes/vue.css" />
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
basePath: 'https://bennycode.com/ig-trading-api',
loadSidebar: true,
name: 'IG Trading API',
relativePath: true,
repo: 'https://github.com/bennycode/ig-trading-api',
};
</script>
<script src="//unpkg.com/docsify@4.11.6/lib/docsify.min.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"helpers": ["test/helpers/**/*.ts"],
"random": true,
"spec_dir": "src",
"spec_files": ["**/*.test.ts", "**/*.test.node.ts"],
"stopSpecOnExpectationFailure": true
}
14 changes: 14 additions & 0 deletions nyc.config.coverage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"all": true,
"branches": 100,
"check-coverage": true,
"exclude": ["**/*.d.ts", "**/*.test*.ts", "**/index.ts", "**/demo/**/*"],
"extension": [".ts"],
"functions": 100,
"include": ["src/**/*.ts"],
"lines": 100,
"per-file": false,
"reporter": ["html", "lcov", "text"],
"require": ["ts-node/register"],
"statements": 100
}
10 changes: 10 additions & 0 deletions nyc.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"all": false,
"check-coverage": false,
"exclude": ["**/*.d.ts", "**/*.test*.ts", "**/index.ts", "**/demo/**/*"],
"extension": [".ts"],
"include": ["src/**/*.ts"],
"per-file": false,
"reporter": ["text-summary"],
"require": ["ts-node/register"]
}
88 changes: 88 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"bugs": {
"url": "https://github.com/bennycode/ig-trading-api/issues"
},
"dependencies": {
"@types/node": "14.14.10",
"axios": "0.21.0"
},
"description": "IG Trading API for Node.js, written in TypeScript.",
"devDependencies": {
"@types/jasmine": "3.6.2",
"@typescript-eslint/eslint-plugin": "4.9.0",
"@typescript-eslint/parser": "4.9.0",
"cross-env": "7.0.3",
"dotenv-defaults": "2.0.1",
"eslint": "7.14.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-prettier": "3.2.0",
"eslint-plugin-typescript-sort-keys": "1.5.0",
"generate-changelog": "1.8.0",
"husky": "4.3.0",
"jasmine": "3.6.3",
"lint-staged": "10.5.3",
"nock": "13.0.5",
"nyc": "15.1.0",
"prettier": "2.2.1",
"pretty-quick": "3.1.0",
"rimraf": "3.0.2",
"ts-node": "9.1.0",
"typedoc": "0.19.2",
"typedoc-plugin-markdown": "3.0.11",
"typescript": "4.1.2"
},
"engines": {
"node": ">= 10.9",
"yarn": ">= 1"
},
"files": [
"dist",
"!/dist/demo",
"!/dist/test"
],
"keywords": [
"API",
"CFD",
"finance",
"fintech",
"derivatives",
"IG",
"trading",
"TypeScript"
],
"license": "MIT",
"main": "dist/index.js",
"name": "ig-trading-api",
"private": false,
"repository": {
"type": "git",
"url": "git+https://github.com/bennycode/ig-trading-api.git"
},
"scripts": {
"build": "tsc",
"changelog:commit": "git add CHANGELOG.md && git commit -m \"docs: Updated changelog\"",
"clean": "rimraf .nyc_output coverage dist",
"demo:login": "ts-node ./src/demo/login.ts",
"docs": "yarn docs:build && yarn docs:start",
"docs:build": "yarn typedoc",
"docs:release": "yarn docs:build && git add docs/* && git commit -m \"docs: Updated API\"",
"docs:start": "docsify serve docs",
"dist": "yarn clean && yarn build",
"fix": "yarn fix:other && yarn fix:code",
"fix:code": "yarn lint:code --fix",
"fix:other": "yarn prettier --write",
"lint": "yarn lint:types && yarn lint:code && yarn lint:other",
"lint:code": "eslint --ignore-path .gitignore --ext .js,.jsx,.ts,.tsx .",
"lint:other": "yarn prettier --list-different",
"lint:types": "tsc --noEmit",
"postversion": "git push origin && git push origin --tags && npm publish",
"prettier": "prettier --ignore-path .gitignore --loglevel silent \"**/*.{html,json,scss,yml}\"",
"preversion": "git checkout main && git pull && yarn install && yarn lint && yarn test && yarn dist",
"release:major": "generate-changelog -M && yarn changelog:commit && yarn docs:release && npm version major",
"release:minor": "generate-changelog -m && yarn changelog:commit && yarn docs:release && npm version minor",
"release:patch": "generate-changelog -p && yarn changelog:commit && yarn docs:release && npm version patch",
"test": "exit 0 && nyc --nycrc-path=nyc.config.coverage.json jasmine --config=jasmine.json",
"test:dev": "exit 0 && nyc --nycrc-path=nyc.config.json jasmine --config=jasmine.json"
},
"version": "0.0.0"
}
10 changes: 10 additions & 0 deletions src/APIClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {RESTClient} from './client/RESTClient';

export class APIClient {
readonly rest: RESTClient;

constructor(apiKey: string) {
const url = 'https://api.ig.com/gateway/deal/';
this.rest = new RESTClient(url, apiKey);
}
}

0 comments on commit 27988ba

Please sign in to comment.