Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
54 lines (42 loc) · 1.25 KB

File metadata and controls

54 lines (42 loc) · 1.25 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from __future__ import print_function
import time
import threading
import numpy
import copy
from talib.abstract import RSI
import sys
import pandas as pd
TEST_LEN_SHORT = int(sys.argv[1]) if len(sys.argv) > 1 else 999
TEST_LEN_LONG = int(sys.argv[1]) if len(sys.argv) > 1 else 4005
LOOPS = int(sys.argv[2]) if len(sys.argv) > 2 else 1000
data_short = numpy.random.rand(TEST_LEN_SHORT, 5)
data_long = numpy.random.rand(TEST_LEN_LONG, 5)
df_short = pd.DataFrame(data_short, columns={
'open', 'high', 'low', 'close', 'volume'})
df_long = pd.DataFrame(data_long, columns={
'open', 'high', 'low', 'close', 'volume'})
total = 0
def loop():
global total
if threading.get_native_id() % 2 == 0:
df = copy.deepcopy(df_short)
else:
df = copy.deepcopy(df_long)
while total < LOOPS:
total += 1
try:
df['RSI'] = RSI(df)
except ValueError as msg:
raise ValueError(msg)
t0 = time.time()
threads = []
for i in range(4):
t = threading.Thread(target=loop)
threads.append(t)
t.start()
for t in threads:
t.join()
t1 = time.time()
print('test_len: %d, loops: %d' % (TEST_LEN_LONG, LOOPS))
print('%.6f' % (t1 - t0))
print('%.6f' % ((t1 - t0) / LOOPS))
Morty Proxy This is a proxified and sanitized view of the page, visit original site.