Skip to content

Commit 323ebdf

Browse files
committed
Update README.md
1 parent 1a26ffd commit 323ebdf

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

README.md

+28-27
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,40 @@ Numerical trendline Python algorithms for technical analysis of financial securi
55

66
Installation
77
------------
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.
1619

1720
Examples
1821
--------
1922
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']
2027

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
3430

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

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
3838

39-
import numpy as np
40-
import pandas.io.data as pd
41-
lnkd = np.array(pd.DataReader('lnkd', 'yahoo')['Adj Close'])
42-
minitrends(x = lnkd, window = 30)
39+
# Generate smaller support/resistance trendlines to frame price over smaller periods
40+
trendy.minitrends(x, window = 30, charts = True)
4341

42+
# Iteratively generate trading signals based on maxima/minima in given window
43+
trendy.iterlines(x, window = 30, charts = True) # buy at green dots, sell at red dots
44+
```

0 commit comments

Comments
 (0)