#50: create invest-signal indicators and signal

(ACCEPTED)

--HG--
branch : sandbox
This commit is contained in:
Andreas
2010-04-26 20:17:06 +00:00
parent 4f9469e222
commit db7b0646b7
2 changed files with 63 additions and 1 deletions

62
src/misc/dukas2ticks.py Normal file
View File

@@ -0,0 +1,62 @@
# Copyright (c) 2009 Andreas Balogh
# See LICENSE for details.
''' flatex broker server '''
import getopt
import sys
import os
import re
import datetime as dt
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
datefmt='%H:%M:%S')
LOG = logging.getLogger()
re_line = r'(\d+)-(\d+)-(\d+);(\d+):(\d+):(\d+);(\d+);(.+);(.+);(.+);(.+)'
MDF_REO = re.compile(re_line)
def dukas2ticks(ifn, odir):
ifh = open(ifn, "r")
# ofh = open(argv[2], "w")
ofh = None
tdate = None
tz = 1
for raw_line in ifh:
line = raw_line.strip('\n\r')
mobj = MDF_REO.match(line)
if mobj is None:
LOG.info('skipped [%s]', line)
continue
(dd, mm, yy, hh, mi, ss, vol, p_open, p_cls, p_low, p_high) = mobj.groups()
iyy = int(yy)
imm = int(mm)
idd = int(dd)
if tdate is None or tdate != dt.date(iyy, imm, idd):
tdate = dt.date(iyy, imm, idd)
if idd == 8:
tz = 2
if ofh is not None:
ofh.close()
ofn = '846900-%s%s%s.csv' % (yy, mm, dd)
ofp = os.path.join(odir, ofn)
ofh = open(ofp, 'w')
lhh = int(hh) + tz
print >>ofh, '%.02i:%02s:%02i,846900,LAST,%s,0.0' % (lhh, mi, 0, p_open)
print >>ofh, '%.02i:%02s:%s,846900,LAST,%s,0.0' % (lhh, mi, 15, p_low)
print >>ofh, '%.02i:%02s:%s,846900,LAST,%s,0.0' % (lhh, mi, 30, p_high)
print >>ofh, '%.02i:%02s:%s,846900,LAST,%s,0.0' % (lhh, mi, 45, p_cls)
ifh.close()
ofh.close()
# throw away first line of file (close price from previous day)
return
if __name__ == '__main__':
# dukas2ticks(r'E:\rttrd-dev-var\dukascopy\DAX 06-04 bis 09-04.csv', r'E:\rttrd-dev-var\dukascopy')
dukas2ticks(r'E:\rttrd-dev-var\dukascopy\DAX 29-03 bis 01-04.csv', r'E:\rttrd-dev-var\dukascopy')

View File

@@ -32,7 +32,7 @@ class Usage(Exception):
class Error(Exception):
pass
def main(argv = [__name__]):
def main(argv = [__file__]):
try:
# check for parameters
LOG.debug("starting '%s %s'", argv[0], " ".join(argv[1:]))