You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-65Lines changed: 60 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# talib-binding
2
2
3
-
The [TA-Lib](http://ta-lib.org/)sync bindings.
3
+
A synchronous [TA-Lib](http://ta-lib.org/) bindings for Node.js & TypeScript.
4
4
5
5
## Install
6
6
@@ -10,73 +10,68 @@ yarn add talib-binding
10
10
11
11
## Usage
12
12
13
-
All the functions are exported, you can call it in the same form to [c api](https://ta-lib.org/d_api/d_api.html), but
14
-
there are some difference:
15
-
16
-
- the `startIdx` and `endIdx` is placed at the end of the function signature, and is optional.
17
-
- the return value is the computed result, if result is one array, will be it, else will be a nested array to contains all output arrays.
18
-
- if the ta-lib function returns a error code, will throw a error.
19
-
20
-
Additionally, you can pass a `Record[]` to extract its fields rather than input double array such as `inHigh`, `inLow`, etc.
21
-
And if the input field is a implicit field of the records, you need to input a string to specifying which one field will be extract
22
-
as it.
13
+
1. All the functions are exported, you can call it in the same form to [c api](https://ta-lib.org/d_api/d_api.html), but there are some difference:
14
+
- the `startIdx` and `endIdx` is placed at the end of the function signature, and is optional.
15
+
- the return value is the computed result, if result is one array, will be it, else will be a nested array to contains all output arrays.
16
+
- if the ta-lib function returns a error code, will throw a error.
17
+
2. Additionally, you can pass a `Record[]` to extract its fields rather than input double array such as `inHigh`, `inLow`, etc. And if the input field is a implicit field of the records, you need to input a string to specifying which one field will be extract as it.
18
+
3. The types for TypeScript is generated, you can use this it in TypeScript projects.
23
19
24
20
## Example
25
21
26
-
```typescript
27
-
import*astalibfrom'./src/talib-binding.generated'
28
-
29
-
// Input double array directly:
30
-
let output =talib.SAR(
31
-
[2, 3, 4, 5], /* inHigh */
32
-
[1, 2, 3, 4], /* inLow */
33
-
0.02, /* optAcceleration_Factor, optional */
34
-
0.2, /* optAF_Maximum, optional */
35
-
0, /* startIdx, optional */
36
-
3/* endIdx, optional */
37
-
)
38
-
console.log(output)
39
-
40
-
// Input a records array:
41
-
output=talib.SAR([
42
-
{
43
-
Time: 0,
44
-
Open: 1,
45
-
High: 2,
46
-
Low: 1,
47
-
Close: 2,
48
-
Volume: 1,
49
-
},
50
-
{
51
-
Time: 0,
52
-
Open: 2,
53
-
High: 3,
54
-
Low: 2,
55
-
Close: 3,
56
-
Volume: 1,
57
-
},
58
-
])
59
-
60
-
// Input implicit field name with Record[]
61
-
output=talib.COS([
62
-
{
63
-
Time: 0,
64
-
Open: 1,
65
-
High: 2,
66
-
Low: 1,
67
-
Close: 2,
68
-
Volume: 1,
69
-
},
70
-
{
71
-
Time: 0,
72
-
Open: 2,
73
-
High: 3,
74
-
Low: 2,
75
-
Close: 3,
76
-
Volume: 1,
77
-
},
78
-
], 'Volume')
79
-
```
22
+
- call in the same form of `TA-Lib`:
23
+
```typescript
24
+
// import * as talib from 'talib-binding'
25
+
import*astalibfrom'./src/talib-binding.generated'
26
+
27
+
talib.SAR(
28
+
[2, 3, 4, 5], /* inHigh */
29
+
[1, 2, 3, 4], /* inLow */
30
+
0.02, /* optAcceleration_Factor, optional */
31
+
0.2, /* optAF_Maximum, optional */
32
+
0, /* startIdx, optional */
33
+
3/* endIdx, optional */
34
+
)
35
+
```
36
+
-passa`Record`arrayasthefirstparameter, thelibrarywillextractthefieldvalueautomatically, ifthefunction contains some implicit parameter name, you need to pass the name string to extract it. The implicit parameter means that the param is not one of `High`, `Low`, `Open`, `Close`, and `Volume`, just like `inReal`, more detailed information could be found in the TypeScript function signatures.
0 commit comments