Skip to content

Commit dfaff51

Browse files
committed
Move from kerasjs to tensorflowjs
1 parent 8acaa9c commit dfaff51

16 files changed

+7773
-376
lines changed

README.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# TechnicalIndicators
44

5-
A javascript technical indicators written in javascript.
5+
A javascript technical indicators written in typescript.
66

77

88
# Installation
99

10-
## Node.js versions >= 6.4
10+
## Node.js versions >= 10
1111

1212
``` bash
1313
npm install --save technicalindicators
@@ -17,17 +17,9 @@ npm install --save technicalindicators
1717
const SMA = require('technicalindicators').SMA;
1818
```
1919

20-
## Node.js versions < 6.4
20+
## Node.js versions < 10
2121

22-
``` bash
23-
npm install --save babel-polyfill
24-
npm install --save technicalindicators
25-
```
26-
27-
``` javascript
28-
require('babel-polyfill');
29-
const SMA = require('technicalindicators/dist/browser').SMA;
30-
```
22+
For nodejs version below 10 use 1.x versions of this library.
3123

3224
## Webpack
3325

@@ -44,17 +36,47 @@ module.exports = {
4436

4537
## Browser
4638

47-
For browser install using bower or npm, but it is necessary to include the babel-polyfill otherwise you will get an error. For example see [index.html](https://github.com/anandanand84/technicalindicators/blob/master/index.html "index.html")
39+
For browsers install using npm,
40+
41+
For ES6 browsers use
42+
43+
``` bash
44+
npm install --save technicalindicators
45+
```
46+
47+
```html
48+
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
49+
```
50+
51+
For ES5 support it is necessary to include the babel-polyfill and respective file browser.js otherwise you will get an error. For example see [index.html](https://github.com/anandanand84/technicalindicators/blob/master/index.html "index.html")
4852

4953
``` bash
5054
npm install --save technicalindicators
5155
npm install --save babel-polyfill
52-
bower install --save technicalindicators
5356
```
5457

5558
``` html
5659
<script src="node_modules/babel-polyfill/browser.js"></script>
57-
<script src="bower_components/technicalindicators/browser.js"></script>
60+
<script src="node_modules/technicalindicators/dist/browser.js"></script>
61+
```
62+
63+
### Pattern detection
64+
65+
If using pattern detection it is necessary to include the tensorflowjs library before this library is loaded and the model files present in tf_model dir in this repository should be accessible at location /tf_model/ in server.
66+
67+
For ES6
68+
69+
``` html
70+
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.0"></script>
71+
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
72+
```
73+
74+
For ES5
75+
76+
``` html
77+
<script src="node_modules/babel-polyfill/browser.js"></script>
78+
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.0"></script>
79+
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
5880
```
5981

6082
All indicators will be available in window object. So you can just use
@@ -140,7 +162,7 @@ Finds pattern in the given set of data, patterns include, DB, DT, HS, IHS, TU, T
140162
```
141163

142164

143-
When running in browser the file model.bin present in dist/model.bin in the respository should be accessible on your server at the location at /dist/model.bin.
165+
When running in browser the dir /tf_model/ present in this respository should be accessible on your server at the location at /tf_model/.
144166
The model is trained using 400 count of values, so try to provide values close to 400 for a reliable prediction of DB, DT, HS, IHS
145167
TD(Trending Down) and TU(Trending up) works fine even with lower values.
146168

declarations/patterndetection/patterndetection.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ export declare class PatternDetectorInput extends IndicatorInput {
44
constructor(values: number[]);
55
}
66
export declare enum AvailablePatterns {
7-
'TD' = 0,
8-
'IHS' = 1,
9-
'HS' = 2,
10-
'TU' = 3,
11-
'DT' = 4,
12-
'DB' = 5,
7+
'IHS' = 0,
8+
'TU' = 1,
9+
'DB' = 2,
10+
'HS' = 3,
11+
'TD' = 4,
12+
'DT' = 5,
1313
}
1414
export declare class PatternDetectorOutput {
1515
patternId: AvailablePatterns;

dist/browser.es6.js

Lines changed: 1 addition & 224 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser.es6.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/browser.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/index.js

Lines changed: 61 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
<div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
1010
<input type="button" onclick="executeCode()" value="Execute"></input>
11+
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.0"></script>
1112
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js"></script>
1213
<script src="dist/browser.js"></script>
1314
<script src="https://unpkg.com/monaco-editor@0.8.3/min/vs/loader.js"></script>
1415
<script>
1516
var editor;
16-
require.config({ paths: { 'vs': 'http://unpkg.com/monaco-editor@0.8.3//min/vs' }});
17+
require.config({ paths: { 'vs': 'http://unpkg.com/monaco-editor@0.8.3/min/vs' }});
1718
require(['vs/editor/editor.main'], function() {
1819
fetch('/node_modules/technicalindicators/declarations/generated.d.ts', { method: 'get'}).then(function(response) { return response.text() }).then(function(content) {
1920
var technicalIndicators = content.replace(new RegExp('default ', 'g'), '').split('export').join('declare');

0 commit comments

Comments
 (0)