python 炒股公式_计算股票公式

import Tkinter as tk

from Tkinter import *

import ttk

import matplotlib.pyplot as plt

import numpy as np

import talib as ta

series = np.random.choice([1, -1], size=200)

close = np.cumsum(series).astype(float)

# 重叠指标

def overlap_process(event):

print(event.widget.get())

overlap = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)

fig, axes = plt.subplots(2, 1, sharex=True)

ax1, ax2 = axes[0], axes[1]

axes[0].plot(close, '', markersize=3)

axes[0].plot(upperband, '')

axes[0].plot(middleband, '')

axes[0].plot(lowerband, '')

axes[0].set_title(overlap, fontproperties="SimHei")

if overlap == '布林线':

pass

elif overlap == '双指数移动平均线':

real = ta.DEMA(close, timeperiod=30)

axes[1].plot(real, '')

elif overlap == '指数移动平均线 ':

real = ta.EMA(close, timeperiod=30)

axes[1].plot(real, '')

elif overlap == '希尔伯特变换——瞬时趋势线':

real = ta.HT_TRENDLINE(close)

axes[1].plot(real, '')

elif overlap == '考夫曼自适应移动平均线':

real = ta.KAMA(close, timeperiod=30)

axes[1].plot(real, '')

elif overlap == '移动平均线':

real = ta.MA(close, timeperiod=30, matype=0)

axes[1].plot(real, '')

elif overlap == 'MESA自适应移动平均':

mama, fama = ta.MAMA(close, fastlimit=0, slowlimit=0)

axes[1].plot(mama, '')

axes[1].plot(fama, '')

elif overlap == '变周期移动平均线':

real = ta.MAVP(close, periods, minperiod=2, maxperiod=30, matype=0)

axes[1].plot(real, '')

elif overlap == '简单移动平均线':

real = ta.SMA(close, timeperiod=30)

axes[1].plot(real, '')

elif overlap == '三指数移动平均线(T3)':

real = ta.T3(close, timeperiod=5, vfactor=0)

axes[1].plot(real, '')

elif overlap == '三指数移动平均线':

real = ta.TEMA(close, timeperiod=30)

axes[1].plot(real, '')

elif overlap == '三角形加权法 ':

real = ta.TRIMA(close, timeperiod=30)

axes[1].plot(real, '')

elif overlap == '加权移动平均数':

real = ta.WMA(close, timeperiod=30)

axes[1].plot(real, '')

plt.show()

# 动量指标

def momentum_process(event):

print(event.widget.get())

momentum = event.widget.get()

upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)

fig, axes = plt.subplots(2, 1, sharex=True)

ax1, ax2 = axes[0], axes[1]

axes[0].plot(close, '', markersize=3)

axes[0].plot(upperband, '')

axes[0].plot(middleband, '')

axes[0].plot(lowerband, '')

axes[0].set_title(momentum, fontproperties="SimHei")

if momentum == '绝对价格振荡器':

real = ta.APO(close, fastperiod=12, slowp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值