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
+28-27
Original file line number
Diff line number
Diff line change
@@ -5,39 +5,40 @@ Numerical trendline Python algorithms for technical analysis of financial securi
5
5
6
6
Installation
7
7
------------
8
-
1. Clone or download the ZIP file.
9
-
2. Unpack the zip file.
10
-
3. Find the unpacked directory and copy the files to your Python path. Otherwise, you can place them in an easily reachable directory and import any of the files individually into your current working Python environment with
11
-
12
-
13
-
execfile('/path/to/trendy-master/file.py')
14
-
15
-
I am working on getting this project hosted on the Python Package Index, but for now this at least enables you to start using and gaining familiarity with the algorithms.
8
+
1. Clone or download the ZIP file and unpack.
9
+
2. Go to the unpacked directory and copy to your Python path. Alternatively, you can place the trendy.py file in an easily reachable directory and import into your current working Python environment with
10
+
```python
11
+
execfile('/path/to/trendy.py')
12
+
```
13
+
or
14
+
```python
15
+
import trendy
16
+
```
17
+
18
+
I am still working on getting this project hosted on the Python Package Index, but for now this at least enables you to start using and gaining familiarity with the algorithms.
16
19
17
20
Examples
18
21
--------
19
22
Once the files have been imported, you can implement them with simple function calls. Here are some examples.
23
+
```python
24
+
# Download Apple price history and save adjusted close prices to numpy array
25
+
import pandas.io.data as pd
26
+
x = pd.DataReader("AAPL", "yahoo")['Adj Close']
20
27
21
-
This example places general trendlines framing the entire price history of Facebook (ticker: FB).
22
-
23
-
gentrends(x = 'fb')
24
-
25
-
You can change the window period to alter the sensitivity and flexibility of the general trendline function. This example applies the function to LinkedIn (ticker: LNKD) with a window period of 1/2 (half of the length of the price history). Keep in mind that if using a version before Python 3, you will need to specify that the window period is a float with decimals.
26
-
27
-
gentrends(x = 'lnkd', window = 1.0/2.0)
28
-
29
-
You can also specify window periods of integer values. For example, if LinkedIn has been on the market for 730 trading days, the above example is equivalent to:
30
-
31
-
gentrends(x = 'lnkd', window = 365)
32
-
33
-
If you want trendlines that provide a description of the price movement over smaller timeframes, it may be more useful to use the 'minitrends' function, where smaller window periods may prove more useful.
28
+
# Make some trendlines
29
+
import trendy
34
30
35
-
minitrends(x = 'lnkd', window = 30)
31
+
# Generate general support/resistance trendlines and show the chart
32
+
# winow < 1 is considered a fraction of the length of the data set
33
+
trendy.gentrends(x, window=1.0/3, charts=True)
36
34
37
-
It is also possible to feed it raw data as a NumPy array instead of a ticker symbol.
35
+
# Generate a series of support/resistance lines by segmenting the price history
36
+
trendy.segtrends(x, segments=2, charts=True) # equivalent to gentrends with window of 1/2
37
+
trendy.segtrends(x, segments=5, charts=True) # plots several S/R lines
0 commit comments