Skip to content

Commit 9fb165a

Browse files
committed
(PARTIAL) Technical Analysis functionality
Changes to be committed:
1 parent 1f7453d commit 9fb165a

13 files changed

Lines changed: 2111 additions & 158 deletions

File tree

Base/Library/JRRtechnical.py

Lines changed: 927 additions & 0 deletions
Large diffs are not rendered by default.

Extras/CodeProofs/jrrTA/ADAUSD.txt

Lines changed: 721 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
def main():
21+
ohlcv=[]
22+
23+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
24+
25+
# Build my own candles. No live candles. A candle is returned only after it
26+
# is closed.
27+
28+
c=0
29+
while c<10:
30+
ohlcv=ta.MakeOHLCV(seconds=60)
31+
print(ohlcv)
32+
c+=1
33+
34+
if __name__=='__main__':
35+
main()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
def main():
21+
ohlcv=[]
22+
23+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
24+
25+
# Live display of candles
26+
c=0
27+
while c<10:
28+
# Automaricalling adds to rolling window
29+
ta.UpdateOHLCV()
30+
ta.Display(-1)
31+
c+=1
32+
time.sleep(60) # for 1 minute candles
33+
34+
if __name__=='__main__':
35+
main()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
def main():
21+
ohlcv=[]
22+
23+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
24+
25+
# Read data file and process it
26+
27+
ohlcv=ta.ReadOHLCV('ADAUSD.txt')
28+
29+
print(f"Candles read: {len(ohlcv)}")
30+
31+
# Build the rolling window. This IS required to any technical analysis
32+
33+
for s in ohlcv:
34+
ta.Rolling(s)
35+
36+
# Display the window, last 10
37+
for s in range(len(ta.window)-10,len(ta.window)):
38+
ta.Display(s)
39+
40+
if __name__=='__main__':
41+
main()

Extras/CodeProofs/jrrTA/demo.adx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
# Example output:
21+
22+
# Header is NOT inclused in output, I added it here to demonstrate the way the
23+
# code works as you build the rolling window. This CAN and WILL get very
24+
# complicated as you add indicators and layers to your analysis.
25+
26+
# 9/Crossing distance is the distance between the first value and the second value.
27+
# 10/Crossing, 1 fast (first value) crosses over slow (second value), bullish.
28+
# -1, Bearish, opposite of bullish, 0 no crossing.
29+
30+
# 0/Date and Time 1/Open 2/High 3/Low 4/Close 5/Volume 6/+DI 7/-DI 8/ADX 9/Cross Dist 10/Crossing
31+
# 2025-09-20 11:38:00 0.88973000 0.89000000 0.88970000 0.89000000 868.53787000 ---------------- ---------------- ---------------- ---------------- ----------------
32+
# 2025-09-20 11:39:00 0.89056000 0.89060000 0.89056000 0.89060000 73747.03466000 42.12806933 45.97977853 4.37158470 ---------------- ----------------
33+
# 2025-09-20 11:40:00 0.89060000 0.89092000 0.89060000 0.89092000 36793.91174000 46.29913221 41.09239408 5.95794393 5.20673813 1.00000000
34+
# 2025-09-20 11:41:00 0.89092000 0.89110000 0.89092000 0.89110000 19803.87053000 45.71723426 41.53766770 1.07580130 4.17956656 0.00000000
35+
# 2025-09-20 11:42:00 0.89143000 0.89183000 0.89143000 0.89183000 263069.34027000 47.00251889 40.55415617 0.14729574 6.44836272 0.00000000
36+
37+
def main():
38+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
39+
ohlcv=ta.ReadOHLCV('ADAUSD.txt')
40+
41+
Period=14
42+
43+
Opening=1
44+
HighIDX=2
45+
LowIDX=3
46+
Closing=4
47+
Volume=5
48+
49+
# Colums representing +DI and -DI
50+
51+
diP=6 # +DI
52+
diM=7 # -DI
53+
54+
for slice in ohlcv:
55+
ta.Rolling(slice)
56+
57+
ta.ADX(HighIDX,LowIDX,Closing,Period)
58+
ta.Cross(diP,diM) # +DI>-DI bullish, +DI<-DI bearish, these as crossings
59+
60+
ta.Display(-1)
61+
62+
if __name__=='__main__':
63+
main()
64+
65+
###
66+
### End demo
67+
###
68+
69+

Extras/CodeProofs/jrrTA/demo.atr

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
def main():
21+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
22+
ohlcv=ta.ReadOHLCV('ADAUSD.txt')
23+
24+
Period=14
25+
26+
Opening=1
27+
HighIDX=2
28+
LowIDX=3
29+
Closing=4
30+
Volume=5
31+
32+
for slice in ohlcv:
33+
ta.Rolling(slice)
34+
35+
# Example custom smoothing, default is RMA
36+
# ta.ATR(HighIDX,LowIDX,Closing,Period,smooth_func=ta.SMA)
37+
ta.ATR(HighIDX,LowIDX,Closing,Period)
38+
39+
ta.Display(-1)
40+
41+
if __name__=='__main__':
42+
main()
43+
44+
###
45+
### End demo
46+
###
47+
48+

Extras/CodeProofs/jrrTA/demo.bb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
def main():
21+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
22+
ohlcv=ta.ReadOHLCV('ADAUSD.txt')
23+
24+
SlowLength=197
25+
26+
Opening=1
27+
HighIDX=2
28+
LowIDX=3
29+
Closing=4
30+
Volume=5
31+
32+
for slice in ohlcv:
33+
ta.Rolling(slice)
34+
35+
# Create an EMA, column 6
36+
emaIDX=6
37+
ta.EMA(Closing,SlowLength)
38+
39+
# Create a Bollingers Band using a previous EMA, upper boundary will be
40+
# column 7, lower boundary will be collumn 8
41+
42+
bbU=7
43+
bbL=8
44+
ta.BollingerBands(emaIDX,20,2)
45+
46+
ta.Display(-1)
47+
48+
if __name__=='__main__':
49+
main()
50+
51+
###
52+
### End demo
53+
###
54+

Extras/CodeProofs/jrrTA/demo.macd

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Jackrabbit Relay Technical Analysis example
5+
6+
# 2021-2025 Copyright © Robert APM Darin
7+
# All rights reserved unconditionally.
8+
9+
import sys
10+
sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library')
11+
import os
12+
import math
13+
import json
14+
import datetime
15+
import time
16+
17+
import JackrabbitRelay as JRR
18+
import JRRtechnical as jrTA
19+
20+
def main():
21+
ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197)
22+
ohlcv=ta.ReadOHLCV('ADAUSD.txt')
23+
24+
FastLength=12
25+
SlowLength=26
26+
27+
Opening=1
28+
HighIDX=2
29+
LowIDX=3
30+
Closing=4
31+
Volume=5
32+
33+
for slice in ohlcv:
34+
ta.Rolling(slice)
35+
36+
# Create an EMA, column 6
37+
emaFAST=6
38+
ta.EMA(Closing,FastLength)
39+
40+
# Create an EMA, column 6
41+
emaSLOW=7
42+
ta.EMA(Closing,SlowLength)
43+
44+
# Create MACD, default values
45+
46+
macdIDX=8
47+
sigIDX=9
48+
histIDX=10
49+
ta.MACD(emaFAST,emaSLOW,9)
50+
51+
# Create crossings
52+
53+
ta.Cross(macdIDX,sigIDX)
54+
55+
# Display last row
56+
57+
ta.Display(-1)
58+
59+
if __name__=='__main__':
60+
main()
61+
62+
###
63+
### End demo
64+
###
65+

0 commit comments

Comments
 (0)