()
| 8 | |
| 9 | # prepare data |
| 10 | def get_stock_signal_data(): |
| 11 | fname = os.path.join(home, 'stock_data', '_IF000.csv') |
| 12 | price_data = csv2frame(fname) |
| 13 | from matplotlib.colors import colorConverter |
| 14 | info = load_tradeinfo("_djtrend2_IF000") |
| 15 | entry_x = [] |
| 16 | entry_y = info['entry_price'].tolist() |
| 17 | exit_x = [] |
| 18 | exit_y = info['exit_price'].tolist() |
| 19 | colors = [] |
| 20 | for t in info.index: |
| 21 | entry_x.append(price_data.index.searchsorted(t)) |
| 22 | for t in info['exit_datetime'].values: |
| 23 | exit_x.append(price_data.index.searchsorted(t)) |
| 24 | for i in range(len(info)): |
| 25 | tr = info.ix[i] |
| 26 | if tr['islong']: |
| 27 | c = 'r' if tr['exit_price']>tr['entry_price'] else 'b' |
| 28 | else: |
| 29 | c = 'r' if tr['exit_price']<tr['entry_price'] else 'b' |
| 30 | r,g,b = colorConverter.to_rgb(c) |
| 31 | colors.append((r,g,b,1)) |
| 32 | return price_data, entry_x, entry_y, exit_x, exit_y, colors |
| 33 | |
| 34 | |
| 35 |
no test coverage detected