Skip to main content

金融技术分析指标库。https://github.com/TulipCharts/tulipindicators 的 Python 绑定

项目描述

郁金香

由 Drakkar-Software 分叉,唯一的目的是使依赖项版本保持最新。

郁金香指标的 Python 绑定

Tulipy 需要numpy,因为所有输入和输出都是 numpy 数组 ( dtype=np.float64)。

安装

您可以通过pip install tulipy. 如果您的系统没有可用的轮子,您将需要pip install Cython numpy从源代码分发中构建。在 Windows 上从源代码构建时,您需要安装 Microsoft Visual C++ Build Tools。

用法

import numpy as np
import tulipy as ti
ti.TI_VERSION
'0.8.4'
DATA = np.array([81.59, 81.06, 82.87, 83,    83.61,
                 83.15, 82.84, 83.99, 84.55, 84.36,
                 85.53, 86.54, 86.89, 87.77, 87.29])

有关指标的信息作为属性公开:

def print_info(indicator):
    print("Type:", indicator.type)
    print("Full Name:", indicator.full_name)
    print("Inputs:", indicator.inputs)
    print("Options:", indicator.options)
    print("Outputs:", indicator.outputs)
print_info(ti.sqrt)
Type: simple
Full Name: Vector Square Root
Inputs: ['real']
Options: []
Outputs: ['sqrt']

直接返回单个输出。outputs返回多个输出的指标按照属性指示的顺序使用元组。

ti.sqrt(DATA)
array([ 9.03271831,  9.00333272,  9.10329611,  9.11043358,  9.14385039,
        9.11866218,  9.1016482 ,  9.16460583,  9.19510739,  9.18477   ,
        9.24824308,  9.30268778,  9.32148057,  9.36856446,  9.34291175])
print_info(ti.sma)
Type: overlay
Full Name: Simple Moving Average
Inputs: ['real']
Options: ['period']
Outputs: ['sma']
ti.sma(DATA, period=5)
array([ 82.426,  82.738,  83.094,  83.318,  83.628,  83.778,  84.254,
        84.994,  85.574,  86.218,  86.804])

无效的选项会抛出InvalidOptionError

try:
    ti.sma(DATA, period=-5)
except ti.InvalidOptionError:
    print("Invalid Option!")
Invalid Option!
print_info(ti.bbands)
Type: overlay
Full Name: Bollinger Bands
Inputs: ['real']
Options: ['period', 'stddev']
Outputs: ['bbands_lower', 'bbands_middle', 'bbands_upper']
ti.bbands(DATA, period=5, stddev=2)
(array([ 80.53004219,  80.98714192,  82.53334324,  82.47198345,
         82.41775044,  82.43520292,  82.51133078,  83.14261781,
         83.53648779,  83.8703237 ,  85.28887096]),
 array([ 82.426,  82.738,  83.094,  83.318,  83.628,  83.778,  84.254,
         84.994,  85.574,  86.218,  86.804]),
 array([ 84.32195781,  84.48885808,  83.65465676,  84.16401655,
         84.83824956,  85.12079708,  85.99666922,  86.84538219,
         87.61151221,  88.5656763 ,  88.31912904]))

如果提供了不同大小的输入,它们将右对齐并从左侧修剪:

DATA2 = np.array([83.15, 82.84, 83.99, 84.55, 84.36])
# 'high' trimmed to DATA[-5:] == array([ 85.53,  86.54,  86.89,  87.77,  87.29])
ti.aroonosc(high=DATA, low=DATA2, period=2)
array([  50.,  100.,   50.])

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

OctoBot-Tulipy-0.4.2.tar.gz (38.2 kB 查看哈希

已上传 source

内置发行版

OctoBot_Tulipy-0.4.2-cp38-cp38-win_amd64.whl (98.5 kB 查看哈希

已上传 cp38

OctoBot_Tulipy-0.4.2-cp38-cp38-macosx_10_14_x86_64.whl (90.8 kB 查看哈希

已上传 cp38