Flash Sale! to get a free eCookbook with our top 25 recipes.

Python пример на библиотеки технического анализа jhTAlib. Установка jhTAlib

financial stock market graph on technology abstract background

Установка библиотеки jhTAlib (Technical Analysis Library Time-Series)

pip install jhtalib

Пример кода Python 3

import requests
import csv

import jhtalib as jhta
import matplotlib.pyplot as plt

# download csv content:
result = requests.get('https://raw.githubusercontent.com/joosthoeks/jhTAlib/master/example/data.csv')
decoded = result.content.decode('utf-8')
csv_reader = csv.reader(decoded.splitlines(), delimiter=',')

# save csv content to csv file:
with open('data.csv', 'w') as csv_file:
  csv_writer = csv.writer(csv_file)
  for row in csv_reader:
    csv_writer.writerow(row)

# start example:
df = jhta.CSV2DF('data.csv')
x = df['datetime']

plt.figure(1)

plt.subplot(211)
plt.title('Time / Price')
plt.xlabel('Time')
plt.ylabel('Price')
plt.grid(True)
plt.plot(x, df['Close'], color='blue')
plt.plot(x, jhta.SMA(df, 200), color='red')
plt.legend(['Close', 'SMA 200'], loc='upper left')

plt.show()
0 0 голоса
Рейтинг статьи
0
Оставьте комментарий! Напишите, что думаете по поводу статьи.x
()
x