Ejemplo n.º 1
0
 def __init__(self, dbconn, TData=None):
     self.db = dbconn
     tt = lb.timer()
     if TData == None:
         self.TData = lb.TradeData(self.db)
     else:
         self.TData = TData
import lib.strategy_lib as sl
import lib.tracking as tl
import lib.analytics as an

import numpy as np
import pylab as pl
import scipy as sc
import matplotlib.pyplot as plt

Market = 'TX00'
DorN = 'N'
dbt = dl.DBConn(host="192.168.1.102",
                uid="sa",
                pwd="geniustom",
                cata="FutureData")
tdt = dl.TradeData(dbt.conn, Market, DorN)
dayindi = il.indicatorGroup()

#=========================================================================
#dayindi=tdt.FetchDateByDB("20/03/13")  #D:
#dayindi=tdt.FetchDateByDB("20/03/16")  #D:
#dayindi=tdt.FetchDateByDB("20/03/17")  #D:
#dayindi=tdt.FetchDateByDB("20/03/18")  #D:
#dayindi=tdt.FetchDateByDB("20/03/20")  #D:
#dayindi=tdt.FetchDateByDB("20/03/23")  #D:
#dayindi=tdt.FetchDateByDB("20/03/24")  #D:
#dayindi=tdt.FetchDateByDB("20/03/25")  #D:
#dayindi=tdt.FetchDateByDB("20/03/26")  #D:
#dayindi=tdt.FetchDateByDB("20/03/27")  #D:
#dayindi=tdt.FetchDateByDB("20/03/30")  #D:
#dayindi=tdt.FetchDateByDB("20/04/01")  #D:
Ejemplo n.º 3
0
import os, imp
import common as cm
imp.reload(cm)
import lib.dblib as dl
imp.reload(dl)
import s01
imp.reload(s01)

try:
    dbstr = db.connstr
    datecount = td.DateCount
except:
    db = dl.DBConn(host="127.0.0.1",
                   uid="sa",
                   pwd="geniustom",
                   cata="FutureHis")
    td = dl.TradeData(db.conn)


def daytrade(s):
    return cm.runDayTrade(db,
                          td,
                          fName=s.FName,
                          cName=__name__,
                          sName=s.s1,
                          sTittle=s.STittle)


daytrade(s01)
Ejemplo n.º 4
0
import lib.strategy_lib as sl
import lib.tracking as tl
import lib.analytics as an

import numpy as np
import pylab as pl
import scipy as sc
import matplotlib.pyplot as plt






dbc = dl.DBConn(host="127.0.0.1",uid="sa",pwd="geniustom",cata="FutureHis")
tdc=dl.TradeData(dbc.conn)
dayindi=il.indicatorGroup()


def getIndiInRange(tag_name,start,end):
    d=[]
    for i in range(start,end,1):
        dayindi=tdc.FetchDateByDB(tdc.DateList[i])
        il.GetSpecialIndicator(dayindi)
        t=np.array(dayindi.get(tag_name))
        d.extend(t)
    return d

def seq_intg(x):
    y=x     #np.zeros(x.shape,dtype=x.dtype)
    y[0]=0
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
import imp
import numpy as np
import common    as cm;             imp.reload(cm);
import lib.dblib as dl;             imp.reload(dl);
import lib.indicator as ind;        imp.reload(ind);

try:
	dbstr = db.connstr
	datecount = td.DateCount
except:
	db = dl.DBConn(host="127.0.0.1",uid="sa",pwd="geniustom",cata="FutureData")
	print(Market,DorN)
	td=dl.TradeData(db.conn,Market,DorN)


BackTestDays=60  #need >40
PC=np.array(cm.runDayTrade(db,td,fName=FName,cName="Track all",sName=s1,sTittle=STittle,Days=BackTestDays))

'''
TrainTag=np.zeros(PC.shape,dtype=PC.dtype)
for i in range(0,len(PC)):
	if PC[i]>0: TrainTag[i]=1
	else: TrainTag[i]=0
'''