Beispiel #1
0
    def test_something(self):
        db = MySQLUtils('root', '1988', 'test', 'stock')
        data = db.get_array('sh600741', begin='2015-01-01', end='2016-01-01')
        ohlc = OHLCVD(data)
        ohlc.add_macd()
        ohlc.add_ma(10)
        ohlc.add_rsi_feature()
        ohlc.add_raise_day(5)
        ohlc.add_raise_day(10)
        ohlc.add_recent_down_v_turn()
        data = ohlc.get_array()

        print data.shape[1]
Beispiel #2
0
def prepare_data(db, stock_list, begin, end):
    results = []
    labels = []
    for stock in stock_list:
        tmp_result = db.get_array(stock, begin=begin, end=end)
        print stock
        if tmp_result.shape[0] > 100:
            ohlc = OHLCVD(data=tmp_result)
            ohlc.add_macd()
            ohlc.add_fall_days(5)
            ohlc.add_raise_day(5)
            ohlc.add_raise_day(3)
            ohlc.add_ma(60)
            # ohlc.add_rsi_feature()
            ohlc.add_jump_empty_down()
            ohlc.normalize()
            results.append(ohlc.data)
            label = ohlc.future_return(5)
            labels.append(label)
        print len(results)
        print len(labels)
    return results
Beispiel #3
0
def prepare_data(db, stock_list, begin, end):
    results = []
    labels = []
    for stock in stock_list:
        tmp_result = db.get_array(stock, begin=begin, end=end)
        print stock
        if tmp_result.shape[0] > 100:
            ohlc = OHLCVD(data=tmp_result)
            ohlc.add_macd()
            ohlc.add_fall_days(5)
            ohlc.add_raise_day(5)
            ohlc.add_raise_day(3)
            ohlc.add_ma(60)
            # ohlc.add_rsi_feature()
            ohlc.add_jump_empty_down()
            ohlc.normalize()
            results.append(ohlc.data)
            label = ohlc.future_return(5)
            labels.append(label)
        print len(results)
        print len(labels)
    return results
Beispiel #4
0
# coding=utf-8
__author__ = 'squall'
import numpy as np

from backtest.utils.mysql import MySQLUtils
from data.ohlc import OHLCVD

if __name__ == '__main__':
    db = MySQLUtils('root', '1988', 'stock', 'stock')
    result = db.get_array('sh600741', begin='2007-10-10', end='2015-12-12')
    ohlc = OHLCVD(data=result)
    print result
    print ohlc.get_dataframe()
    ohlc.add_macd()
    ohlc.add_ma(60)
    print ohlc.get_array().shape
    print ohlc.get_dataframe()
    vol_values = ohlc.data_frame.volume.values
    kernel = np.ones(20)*0.05
    result = np.convolve(kernel, vol_values, mode='valid')
    # plt.plot(result)
    # plt.show()