Skip to content

Commit 0a83f8a

Browse files
committed
add markdown documentation and an html generator to convert the docs into the website
1 parent d15da63 commit 0a83f8a

18 files changed

+2058
-284
lines changed

README.md

Lines changed: 204 additions & 284 deletions
Large diffs are not rendered by default.

docs/abstract.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Abstract API Quick Start
2+
3+
If you're already familiar with using the function API, you should feel right
4+
at home using the abstract API. Every function takes the same input, passed
5+
as a dictionary of Numpy arrays:
6+
7+
```python
8+
import numpy as np
9+
# note that all ndarrays must be the same length!
10+
inputs = {
11+
'open': np.random.random(100),
12+
'high': np.random.random(100),
13+
'low': np.random.random(100),
14+
'close': np.random.random(100),
15+
'volume': np.random.random(100)
16+
}
17+
```
18+
19+
Functions can either be imported directly or instantiated by name:
20+
21+
```python
22+
from talib import abstract
23+
sma = abstract.SMA
24+
sma = abstract.Function('sma')
25+
```
26+
27+
From there, calling functions is basically the same as the function API:
28+
29+
```python
30+
from talib.abstract import *
31+
output = SMA(input_arrays, timeperiod=25) # calculate on close prices by default
32+
output = SMA(input_arrays, timeperiod=25, price='open') # calculate on opens
33+
upper, middle, lower = BBANDS(input_arrays, 20, 2, 2)
34+
slowk, slowd = STOCH(input_arrays, 5, 3, 0, 3, 0) # uses high, low, close by default
35+
slowk, slowd = STOCH(input_arrays, 5, 3, 0, 3, 0, prices=['high', 'low', 'open'])
36+
```
37+
38+
## Advanced Usage
39+
40+
For more advanced use cases of TA-Lib, the Abstract API also offers much more
41+
flexibility. You can even subclass ``abstract.Function`` and override
42+
``set_input_arrays`` to customize the type of input data Function accepts
43+
(e.g. a pandas DataFrame).
44+
45+
Details about every function can be accessed via the info property:
46+
47+
```python
48+
print Function('stoch').info
49+
{
50+
'name': 'STOCH',
51+
'display_name': 'Stochastic',
52+
'group': 'Momentum Indicators',
53+
'input_names': OrderedDict([
54+
('prices', ['high', 'low', 'close']),
55+
]),
56+
'parameters': OrderedDict([
57+
('fastk_period', 5),
58+
('slowk_period', 3),
59+
('slowk_matype', 0),
60+
('slowd_period', 3),
61+
('slowd_matype', 0),
62+
]),
63+
'output_names': ['slowk', 'slowd'],
64+
}
65+
66+
```
67+
Or in human-readable format:
68+
```python
69+
help(STOCH)
70+
str(STOCH)
71+
```
72+
73+
Other useful properties of ``Function``:
74+
75+
```python
76+
Function('x').function_flags
77+
Function('x').input_names
78+
Function('x').input_arrays
79+
Function('x').parameters
80+
Function('x').lookback
81+
Function('x').output_names
82+
Function('x').output_flags
83+
Function('x').outputs
84+
```
85+
86+
Aside from calling the function directly, Functions maintain state and will
87+
remember their parameters/input_arrays after they've been set. You can set
88+
parameters and recalculate with new input data using run():
89+
```python
90+
SMA.parameters = {'timeperiod': 15}
91+
result1 = SMA.run(input_arrays1)
92+
result2 = SMA.run(input_arrays2)
93+
94+
# Or set input_arrays and change the parameters:
95+
SMA.input_arrays = input_arrays1
96+
ma10 = SMA(timeperiod=10)
97+
ma20 = SMA(20)
98+
```
99+
100+
For more details, take a look at the
101+
[code](https://github.com/mrjbq7/ta-lib/blob/master/talib/abstract.pyx#L46).
102+
103+
[Documentation Index](doc_index.html)

docs/doc_index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Documentation
2+
3+
* [Installation and Troubleshooting](install.html)
4+
* [Using the Function API](func.html)
5+
* [Using the Abstract API](abstract.html)
6+
* [All Functions](funcs.html)
7+
* [Overlap Studies](func_groups/overlap_studies.html)
8+
* [Momentum Indicators](func_groups/momentum_indicators.html)
9+
* [Volume Indicators](func_groups/volume_indicators.html)
10+
* [Volatility Indicators](func_groups/volatility_indicators.html)
11+
* [Price Transform](func_groups/price_transform.html)
12+
* [Cycle Indicators](func_groups/cycle_indicators.html)
13+
* [Pattern Recognition](func_groups/pattern_recognition.html)
14+
* [Statistic Functions](func_groups/statistic_functions.html)
15+
* [Math Transform](func_groups/math_transform.html)
16+
* [Math Operators](func_groups/math_operators.html)

docs/func.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Function API Examples
2+
3+
Similar to TA-Lib, the function interface provides a lightweight wrapper of
4+
the exposed TA-Lib indicators.
5+
6+
Each function returns an output array and have default values for their
7+
parameters, unless specified as keyword arguments. Typically, these functions
8+
will have an initial "lookback" period (a required number of observations
9+
before an output is generated) set to ``NaN``.
10+
11+
All of the following examples use the function API:
12+
13+
```python
14+
import numpy
15+
import talib
16+
17+
close = numpy.random.random(100)
18+
```
19+
20+
Calculate a simple moving average of the close prices:
21+
22+
```python
23+
output = talib.SMA(close)
24+
```
25+
26+
Calculating bollinger bands, with triple exponential moving average:
27+
28+
```python
29+
from talib import MA_Type
30+
31+
upper, middle, lower = talib.BBANDS(close, matype=MA_Type.T3)
32+
```
33+
34+
Calculating momentum of the close prices, with a time period of 5:
35+
36+
```python
37+
output = talib.MOM(close, timeperiod=5)
38+
```
39+
40+
Documentation for all functions:
41+
42+
* [Overlap Studies](func_groups/overlap_studies.html)
43+
* [Momentum Indicators](func_groups/momentum_indicators.html)
44+
* [Volume Indicators](func_groups/volume_indicators.html)
45+
* [Volatility Indicators](func_groups/volatility_indicators.html)
46+
* [Pattern Recognition](func_groups/pattern_recognition.html)
47+
* [Cycle Indicators](func_groups/cycle_indicators.html)
48+
* [Statistic Functions](func_groups/statistic_functions.html)
49+
* [Price Transform](func_groups/price_transform.html)
50+
* [Math Transform](func_groups/math_transform.html)
51+
* [Math Operators](func_groups/math_operators.html)
52+
53+
[Documentation Index](doc_index.html)
54+
[FLOAT_RIGHTNext: Using the Abstract API](abstract.html)

docs/func_groups/cycle_indicators.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Cycle Indicator Functions
2+
### HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period
3+
```
4+
real = HT_DCPERIOD(close)
5+
```
6+
7+
Learn more about the Hilbert Transform - Dominant Cycle Period at [tadoc.org](http://www.tadoc.org/indicator/HT_DCPERIOD.htm).
8+
### HT_DCPHASE - Hilbert Transform - Dominant Cycle Phase
9+
```
10+
real = HT_DCPHASE(close)
11+
```
12+
13+
Learn more about the Hilbert Transform - Dominant Cycle Phase at [tadoc.org](http://www.tadoc.org/indicator/HT_DCPHASE.htm).
14+
### HT_PHASOR - Hilbert Transform - Phasor Components
15+
```
16+
inphase, quadrature = HT_PHASOR(close)
17+
```
18+
19+
Learn more about the Hilbert Transform - Phasor Components at [tadoc.org](http://www.tadoc.org/indicator/HT_PHASOR.htm).
20+
### HT_SINE - Hilbert Transform - SineWave
21+
```
22+
sine, leadsine = HT_SINE(close)
23+
```
24+
25+
Learn more about the Hilbert Transform - SineWave at [tadoc.org](http://www.tadoc.org/indicator/HT_SINE.htm).
26+
### HT_TRENDMODE - Hilbert Transform - Trend vs Cycle Mode
27+
```
28+
integer = HT_TRENDMODE(close)
29+
```
30+
31+
Learn more about the Hilbert Transform - Trend vs Cycle Mode at [tadoc.org](http://www.tadoc.org/indicator/HT_TRENDMODE.htm).
32+
33+
[Documentation Index](../doc_index.html)
34+
[FLOAT_RIGHTAll Function Groups](../funcs.html)

docs/func_groups/math_operators.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Math Operator Functions
2+
### ADD - Vector Arithmetic Add
3+
```
4+
real = ADD(high, low)
5+
```
6+
7+
### DIV - Vector Arithmetic Div
8+
```
9+
real = DIV(high, low)
10+
```
11+
12+
### MAX - Highest value over a specified period
13+
```
14+
real = MAX(close, timeperiod=30)
15+
```
16+
17+
### MAXINDEX - Index of highest value over a specified period
18+
```
19+
integer = MAXINDEX(close, timeperiod=30)
20+
```
21+
22+
### MIN - Lowest value over a specified period
23+
```
24+
real = MIN(close, timeperiod=30)
25+
```
26+
27+
### MININDEX - Index of lowest value over a specified period
28+
```
29+
integer = MININDEX(close, timeperiod=30)
30+
```
31+
32+
### MINMAX - Lowest and highest values over a specified period
33+
```
34+
min, max = MINMAX(close, timeperiod=30)
35+
```
36+
37+
### MINMAXINDEX - Indexes of lowest and highest values over a specified period
38+
```
39+
minidx, maxidx = MINMAXINDEX(close, timeperiod=30)
40+
```
41+
42+
### MULT - Vector Arithmetic Mult
43+
```
44+
real = MULT(high, low)
45+
```
46+
47+
### SUB - Vector Arithmetic Substraction
48+
```
49+
real = SUB(high, low)
50+
```
51+
52+
### SUM - Summation
53+
```
54+
real = SUM(close, timeperiod=30)
55+
```
56+
57+
58+
[Documentation Index](../doc_index.html)
59+
[FLOAT_RIGHTAll Function Groups](../funcs.html)

docs/func_groups/math_transform.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Math Transform Functions
2+
### ACOS - Vector Trigonometric ACos
3+
```
4+
real = ACOS(close)
5+
```
6+
7+
### ASIN - Vector Trigonometric ASin
8+
```
9+
real = ASIN(close)
10+
```
11+
12+
### ATAN - Vector Trigonometric ATan
13+
```
14+
real = ATAN(close)
15+
```
16+
17+
### CEIL - Vector Ceil
18+
```
19+
real = CEIL(close)
20+
```
21+
22+
### COS - Vector Trigonometric Cos
23+
```
24+
real = COS(close)
25+
```
26+
27+
### COSH - Vector Trigonometric Cosh
28+
```
29+
real = COSH(close)
30+
```
31+
32+
### EXP - Vector Arithmetic Exp
33+
```
34+
real = EXP(close)
35+
```
36+
37+
### FLOOR - Vector Floor
38+
```
39+
real = FLOOR(close)
40+
```
41+
42+
### LN - Vector Log Natural
43+
```
44+
real = LN(close)
45+
```
46+
47+
### LOG10 - Vector Log10
48+
```
49+
real = LOG10(close)
50+
```
51+
52+
### SIN - Vector Trigonometric Sin
53+
```
54+
real = SIN(close)
55+
```
56+
57+
### SINH - Vector Trigonometric Sinh
58+
```
59+
real = SINH(close)
60+
```
61+
62+
### SQRT - Vector Square Root
63+
```
64+
real = SQRT(close)
65+
```
66+
67+
### TAN - Vector Trigonometric Tan
68+
```
69+
real = TAN(close)
70+
```
71+
72+
### TANH - Vector Trigonometric Tanh
73+
```
74+
real = TANH(close)
75+
```
76+
77+
78+
[Documentation Index](../doc_index.html)
79+
[FLOAT_RIGHTAll Function Groups](../funcs.html)

0 commit comments

Comments
 (0)