Exemplo n.º 1
0
# -*- coding: utf-8 -*-
"""
1) Testing TA-Lib and it's cpython wraper

Created on Fri Jun 27 23:09:39 2014
@author: chew-z
"""
#import numpy as np
import matplotlib.pyplot
import read_mql as mql
import formulas as formulas

d_mat = mql.convert_cells_to_floats(
    mql.csv_to_list('./data/USDJPY1440_01.csv'), 1, 3)
close = d_mat[:, 3]
high = d_mat[:, 1]
low = d_mat[:, 2]
del d_mat

f_l = formulas.f_lookbackdays(close, EMA=60)
hh, ll = formulas.f_hh_ll(f_l, high, low)
is_recentHigh, is_recentLow = formulas.is_recent_HL(high, low, hh, ll, K=5)
is_pullbackH, is_pullbackL = formulas.is_pullback(high, low, K=5)

# wektorówki isPullback()

# Plot close i stddev
# matplotlib.pyplot.subplot(221)
# matplotlib.pyplot.plot(stdev)
#matplotlib.pyplot.title('std dev (close)')
#
Exemplo n.º 2
0
2) find recent H/L
3) find isPullback - on D1 or better H1
4) play with parameters
5) is signal significant?
6) visualize results (with different script)
@author: chew-z
"""

import read_mql as read_mql
import formulas as formulas

# 1 import data, sync H1 with D1
csv_listH1 = read_mql.csv_to_list('./data/EURUSD60_01.csv')
csv_listD1 = read_mql.csv_to_list('./data/EURUSD1440_01.csv')

d_mat = read_mql.convert_cells_to_floats(csv_listH1, 1, 3)
closeH1 = d_mat[:, 3]
highH1 = d_mat[:, 1]
lowH1 = d_mat[:, 2]

d_mat = read_mql.convert_cells_to_floats(csv_listD1, 1, 3)
closeD1 = d_mat[:, 3]
highD1 = d_mat[:, 1]
lowD1 = d_mat[:, 2]

D1, H1, s = read_mql.sync(csv_listH1, csv_listD1)

del d_mat, csv_listD1, csv_listH1

# 2 find recent H/L
f_l = formulas.f_lookbackdays(closeD1, EMA=60)
Exemplo n.º 3
0
"""
Created on Tue Aug  19 09:16:52 2015
1) import data from Equity.csv
2) plot equity graph
TODO - merge various ranges, plot date

@author: chew-z
"""

import read_mql as read_mql
import matplotlib.pyplot


# 1 import data and select range
csv_listEq = read_mql.csv_to_list('./data/Equity.csv', ',')
eq_mat = read_mql.convert_cells_to_floats(csv_listEq, 0, 1)
eq_t = read_mql.extract_timestamp_as_dt(csv_listEq, 0)

t = range(2250, 2450) + range(3000, 3250)
y = eq_mat[t, 1]
x = eq_t[t]

# 2 plot equity graph
fig = matplotlib.pyplot
# There is a tricky issue here
# - if you plot with x (dates) the gaps in range are filled in automatically
# - simple plot of y omits gaps in the range
#fig.plot(x, y)
fig.plot(y)
# beautify the x-labels
fig.gcf().autofmt_xdate()
Exemplo n.º 4
0
2) find recent H/L
3) find isPullback - on D1 or better H1
4) play with parameters
5) is signal significant?
6) visualize results (with different script)
@author: chew-z
"""

import read_mql as read_mql
import formulas as formulas

# 1 import data, sync H1 with D1
csv_listH1 = read_mql.csv_to_list('./data/EURUSD60_01.csv')
csv_listD1 = read_mql.csv_to_list('./data/EURUSD1440_01.csv')

d_mat = read_mql.convert_cells_to_floats(csv_listH1, 1, 3)
closeH1 = d_mat[:, 3]
highH1 = d_mat[:, 1]
lowH1 = d_mat[:, 2]

d_mat = read_mql.convert_cells_to_floats(csv_listD1, 1, 3)
closeD1 = d_mat[:, 3]
highD1 = d_mat[:, 1]
lowD1 = d_mat[:, 2]

D1, H1, s = read_mql.sync(csv_listH1, csv_listD1)

del d_mat, csv_listD1, csv_listH1

# 2 find recent H/L
f_l = formulas.f_lookbackdays(closeD1, EMA=60)
Exemplo n.º 5
0
# -*- coding: utf-8 -*-
"""
1) Testing TA-Lib and it's cpython wraper

Created on Fri Jun 27 23:09:39 2014
@author: chew-z
"""
import numpy as np
import scipy.io as scio
import matplotlib.pyplot
import talib
import read_mql as mql

d_mat = mql.convert_cells_to_floats(mql.csv_to_list('./data/EURUSD60_01.csv'), 1, 3)
close = d_mat[:, 3]
del d_mat

sma = talib.SMA(close)
mx = talib.MAX(close, 1000)
mn = talib.MIN(close, 1000)

# Plot close i sma
matplotlib.pyplot.plot(close)
matplotlib.pyplot.plot(sma)
matplotlib.pyplot.plot(mx)
matplotlib.pyplot.plot(mn)
matplotlib.pyplot.show()