Пример #1
0
def getMa5AndCloseAndFatherMa5Slope():
    kLine = client.get('/market/history/kline',symbol=symbolValue,period='15min',size='5')
    '''五日均线'''
    ma5 = misc.getMALine(kLine,5)
    last = kLine[0]['close']
    
    fatherKLine = client.get('/market/history/kline',symbol=symbolValue,period='60min',size='6')
    fatherMa5 = misc.getMALine(fatherKLine,5)
    fatherMa5Slope = misc.getSlope(fatherMa5)
    return ma5[0], last, fatherMa5Slope[0]
Пример #2
0
def getLastMASlope(periodStr,dayStr):
    kLine = client.get('/market/history/kline',symbol=symbolValue,period=periodStr,size=str(int(dayStr)+1))
    '''均线'''
    ma = misc.getMALine(kLine,dayStr)
    '''均线斜率'''
    maSlope = misc.getSlope(ma)
    return maSlope
Пример #3
0
def getMA5SlopeList():
    kLine = client.get('/market/history/kline',
                       symbol=symbolValue,
                       period='60min',
                       size='9')
    '''五日均线'''
    ma5 = misc.getMALine(kLine, 5)
    '''五日均线斜率'''
    ma5Slope = misc.getSlope(ma5)
    return ma5Slope
Пример #4
0
def base_fun(symbol_value, period_value='1day', n=20, j=100):
    k_line = api.get_k_line(symbol_value, period_value, 200)

    roc_list = []
    time_list = []
    close_list = []
    ma_list = []

    for index in np.arange(0, len(k_line) - n):
        roc = (k_line[index].close -
               k_line[index + n].close) / k_line[index + n].close * 100
        roc_list.append(roc * j)

    # print(roc_list[::-1])

    for index in np.arange(0, len(k_line) - n):
        timestamp = k_line[index].id
        temp = datetime.datetime.fromtimestamp(timestamp + 8 * 3600)
        # time_list.append(time.strftime("%Y-%m-%d %H:%M:%S", temp))
        time_list.append(temp)

    # print(time_list[::-1])

    for index in np.arange(0, len(k_line) - n):
        close_list.append(k_line[index].close)

    # print(close_list)

    for index in np.arange(0, len(k_line) - n):
        ma_list.append(misc.getMALine(k_line, n)[index])
    # 收盘价
    close = Scatter(x=time_list[::-1], y=close_list[::-1], name="收盘价")
    # 均线
    ma = Scatter(x=time_list[::-1], y=ma_list[::-1], name="均线({})".format(n))
    # roc线
    roc = Scatter(x=time_list[::-1],
                  y=roc_list[::-1],
                  name="roc({})".format(n))

    layout = Layout(xaxis=dict(range=[
        time_list[-1].timestamp() * 1000, time_list[0].timestamp() * 1000
    ]),
                    title=symbol_value)

    return Figure(data=[close, ma, roc], layout=layout)
Пример #5
0
def getMa(kLine, dayStr):
    ma = misc.getMALine(kLine, dayStr)
    return ma
Пример #6
0
def getLastMASlop(kLine,dayStr):
    '''均线'''
    ma = misc.getMALine(kLine,dayStr)
    '''均线斜率'''
    maSlope = misc.getSlope(ma)
    return maSlope[0]
Пример #7
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov  7 11:04:21 2017

@author: Marco
"""

from okexSpotAPI import OkexSpot
from person import apikey, secretkey, mailPass
import misc

okexSpot = OkexSpot(apikey, secretkey)
symbol = 'btc_usdt'
typeStr = '1hour'
size = 24

kLine = okexSpot.kLine(symbol, typeStr, size)
ma5 = misc.getMALine(kLine)
ma5Slope = misc.getSlope(ma5)

print('MA5:', ma5)
print('MA5 slope:', ma5Slope)
print(len(ma5))
print(len(ma5Slope))
Пример #8
0
for index in np.arange(0, len(k_line) - n):
    timestamp = k_line[index].id
    temp = datetime.datetime.fromtimestamp(timestamp + 8 * 3600)
    #time_list.append(time.strftime("%Y-%m-%d %H:%M:%S", temp))
    time_list.append(temp)

#print(time_list[::-1])

for index in np.arange(0, len(k_line) - n):
    close_list.append(k_line[index].close / j)

#print(close_list)

for index in np.arange(0, len(k_line) - n):
    ma_list.append(misc.getMALine(k_line, n)[index] / j)

#绘制
import plotly
import plotly.graph_objs as go
#roc线
roc = go.Scatter(x=time_list[::-1], y=roc_list[::-1], name="roc({})".format(n))
#收盘价
close = go.Scatter(x=time_list[::-1], y=close_list[::-1], name="收盘价")
#均线
ma = go.Scatter(x=time_list[::-1], y=ma_list[::-1], name="均线({})".format(n))

data = [close, roc, ma]
layout = go.Layout(xaxis=dict(
    range=[time_list[-1].timestamp() * 1000, time_list[0].timestamp() * 1000]),
                   title=symbol_value)
Пример #9
0
        lowValue = low
        misc.setConfigKeyValue('config.ini', 'global', 'low', low)
        content += '<p style="font-weight: bold; color: green;">最低价:%s</p>' % low
        subject += '“最低价”'
        isSend = True
    if abs(change) > thresholdValue:
        if not change == changeValue:
            changeValue = change
            if change > 0:
                value = '+' + str(round(change * 100, 4)) + '%'
            else:
                value = str(round(change * 100, 4)) + '%'
            content += '<p>一小时内涨跌幅度:%s</p>' % value
            subject += '“涨跌幅”'
            isSend = True
            ma5ValueList = misc.getMALine(kLine, 5)
            if ma5ValueList:
                ma5Value = ma5ValueList[-1]
                if float(kLine[-1][4]) > ma5Value:
                    content += '<p>当前价格%s > 五日均线(%s周期)%s</p>' % (
                        priceLast, typeStr, ma5Value)
                if float(kLine[-1][4]) < ma5Value:
                    content += '<p>当前价格%s < 五日均线(%s周期)%s</p>' % (
                        priceLast, typeStr, ma5Value)
                if float(kLine[-1][4]) == ma5Value:
                    content += '<p>当前价格%s = 五日均线(%s周期)%s</p>' % (
                        priceLast, typeStr, ma5Value)
    content += '</html>'
    subject += '报告'

    if isSend: