"""

import loadStock as ls
import PairTrading as pairTrading
import tushare as ts
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

sz50s = ts.get_sz50s()
#sz50s=sz50s[0:2]

Close = pd.DataFrame()
#Close.index=c000001.index
for index, row in sz50s.iterrows():
    data = ls.read_hit_data(row['code'])
    #Close.index=data.index
    Close[row['code']] = data['close']

#Close=Close.dropna(axis=0)

#formPeriod='2017-01-03:2017-08-25'
formPeriod = '2016-06-01:2017-01-01'
#tradePeriod='2016-06-01:2017-01-01'
tradePeriod = '2017-01-03:2017-08-25'

Close = Close.loc[:, ['601288', '601398']]
Close = Close.dropna(axis=0)

priceA = Close.iloc[:, 0]
priceB = Close.iloc[:, 1]
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  1 16:24:32 2017

@author: 53771
"""

import loadStock as ls
import tushare as ts
from datetime import datetime
import matplotlib.pyplot as plt
import pandas_candlestick_ohlc as pohlc
import pandas as pd

ssec = ls.read_hit_data('sh')
ssec2011 = ssec['2012']

Close11 = ssec2011.close
Open11 = ssec2011.open

lagClose11 = Close11.shift(1)
lagOpen11 = Open11.shift(1)
Cloud = pd.Series(0, index=Close11.index)
for i in range(1, len(Close11)):
    if all([
            Close11[i] < Open11[i],  #当时收盘价小于开盘价(当日跌)
            lagClose11[i] > lagOpen11[i],  #昨日收盘价大于昨天开盘价(昨日涨)
            Open11[i] > lagClose11[i],  #今天开盘价高于昨天收盘价
            Close11[i] < 0.5 *
        (lagClose11[i] + lagOpen11[i]),  #今天收盘价低于昨日开盘介与收盘价的中线
            Close11[i] > lagOpen11[i]  #当日收盘价大于昨日开盘价       
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  1 18:05:30 2017

@author: 53771
"""
import loadStock as ls
import tushare as ts
from datetime import datetime
import matplotlib.pyplot as plt
import pandas_candlestick_ohlc as pohlc
import pandas as pd

Vanke = ls.read_hit_data('000001')
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  1 10:20:29 2017

@author: 53771
"""

import loadStock as ls
import tushare as ts
from matplotlib.dates import DateFormatter, WeekdayLocator, DayLocator, MONDAY, date2num
from matplotlib.finance import candlestick_ohlc
from datetime import datetime
import matplotlib.pyplot as plt
import pandas_candlestick_ohlc as pohlc

df = ls.read_hit_data('sh')
df2015 = df['2012-09']

plotdat = pohlc.pandas_candlestick_ohlc(df2015)

df2012 = df['2012']
Close = df2012.close
Open = df2012.open
C10p = Close - Open

Shape = [0, 0, 0]

lag1C10p = C10p.shift(1)
lag2C10p = C10p.shift(2)

for i in range(3, len(C10p)):