Skip to content

Commit

Permalink
Move from kerasjs to tensorflowjs
Browse files Browse the repository at this point in the history
  • Loading branch information
anandanand84 committed Sep 26, 2018
1 parent 8acaa9c commit dfaff51
Show file tree
Hide file tree
Showing 16 changed files with 7,773 additions and 376 deletions.
54 changes: 38 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# TechnicalIndicators

A javascript technical indicators written in javascript.
A javascript technical indicators written in typescript.


# Installation

## Node.js versions >= 6.4
## Node.js versions >= 10

``` bash
npm install --save technicalindicators
Expand All @@ -17,17 +17,9 @@ npm install --save technicalindicators
const SMA = require('technicalindicators').SMA;
```

## Node.js versions < 6.4
## Node.js versions < 10

``` bash
npm install --save babel-polyfill
npm install --save technicalindicators
```

``` javascript
require('babel-polyfill');
const SMA = require('technicalindicators/dist/browser').SMA;
```
For nodejs version below 10 use 1.x versions of this library.

## Webpack

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

## Browser

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")
For browsers install using npm,

For ES6 browsers use

``` bash
npm install --save technicalindicators
```

```html
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
```

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")

``` bash
npm install --save technicalindicators
npm install --save babel-polyfill
bower install --save technicalindicators
```

``` html
<script src="node_modules/babel-polyfill/browser.js"></script>
<script src="bower_components/technicalindicators/browser.js"></script>
<script src="node_modules/technicalindicators/dist/browser.js"></script>
```

### Pattern detection

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.

For ES6

``` html
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
```

For ES5

``` html
<script src="node_modules/babel-polyfill/browser.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>
<script src="node_modules/technicalindicators/dist/browser.es6.js"></script>
```

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


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.
When running in browser the dir /tf_model/ present in this respository should be accessible on your server at the location at /tf_model/.
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
TD(Trending Down) and TU(Trending up) works fine even with lower values.

Expand Down
12 changes: 6 additions & 6 deletions declarations/patterndetection/patterndetection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export declare class PatternDetectorInput extends IndicatorInput {
constructor(values: number[]);
}
export declare enum AvailablePatterns {
'TD' = 0,
'IHS' = 1,
'HS' = 2,
'TU' = 3,
'DT' = 4,
'DB' = 5,
'IHS' = 0,
'TU' = 1,
'DB' = 2,
'HS' = 3,
'TD' = 4,
'DT' = 5,
}
export declare class PatternDetectorOutput {
patternId: AvailablePatterns;
Expand Down
225 changes: 1 addition & 224 deletions dist/browser.es6.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/browser.es6.js.map

This file was deleted.

3 changes: 1 addition & 2 deletions dist/browser.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/browser.js.map

This file was deleted.

96 changes: 61 additions & 35 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

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

0 comments on commit dfaff51

Please sign in to comment.