예제 #1
0
 def __init__(self, barFeed, cash=1000000):
     broker_ = BacktestingFuturesBroker(cash, barFeed)
     Strategy.__init__(self, barFeed, cash, broker_)
     self._position = None
     self._started = False
     self._db = InstrumentDb.Instance()
     self._riskfactor = 0.002
예제 #2
0
 def __init__(self, barFeed, cash=1000000):
     broker_ = BacktestingFuturesBroker(cash, barFeed)
     Strategy.__init__(self, barFeed, cash, broker_)
     self._position = None
     self._started = False
     self._db = InstrumentDb.Instance()
     self._riskfactor = 0.002
예제 #3
0
    def __init__(self, barFeed, symbols = None, broker = None, cash = 1000000,\
                 compounding = True, parms = None):
        self._parms = self.defaultParms()
        if parms:
            self._parms.update(parms)

        if broker is None:
            broker = BacktestingFuturesBroker(
                cash, barFeed, commission=FuturesCommission(2.50))
        Strategy.__init__(self, barFeed, cash, broker)
        if symbols is None:
            self._symbols = barFeed.symbols()
        else:
            self._symbols = symbols
        self._barFeed = barFeed
        self._longpositions = {}
        self._shortpositions = {}
        self._started = {}
        for sym in self._symbols:
            feed = self._barFeed.get_feed(sym)
            self._started[sym] = False
            feed.insert(ATR(name='atr', period=self._parms['atrPeriod']))

        self._db = InstrumentDb.Instance()

        self._riskfactor = self._parms['riskFactor']

        self._tradeHigh = {}
        self._tradeLow = {}

        self.prep_bar_feed()
        self._startingCash = cash
        self._compounding = compounding
        self._stop = self._parms['stop']
        self._limit = self._parms['limit']
        self._intraday = self._parms['intradayStop']
        self._dynamic = self._parms['dynamicStop']
예제 #4
0
    def __init__(self, barFeed, symbols = None, broker = None, cash = 1000000,\
                 compounding = True, parms = None):
        self._parms = self.defaultParms()
        if parms:
            self._parms.update(parms)          
          
        if broker is None:
            broker = BacktestingFuturesBroker(cash, barFeed, commission=FuturesCommission(2.50))
        Strategy.__init__(self, barFeed, cash, broker)
        if symbols is None:
            self._symbols = barFeed.symbols()
        else:
            self._symbols = symbols
        self._barFeed = barFeed
        self._longpositions = {}
        self._shortpositions = {}
        self._started = {}
        for sym in self._symbols:
            feed = self._barFeed.get_feed(sym)
            self._started[sym] = False
            feed.insert( ATR( name='atr', period=self._parms['atrPeriod'] ) )            
            
        self._db = InstrumentDb.Instance()
        
        self._riskfactor = self._parms['riskFactor']

        self._tradeHigh = {}
        self._tradeLow = {}
            
        self.prep_bar_feed()
        self._startingCash = cash
        self._compounding = compounding
        self._stop = self._parms['stop']
        self._limit = self._parms['limit']
        self._intraday = self._parms['intradayStop']
        self._dynamic = self._parms['dynamicStop']
예제 #5
0
 def __init__(self, barFeed, cash=1000000, broker_=None):
     Strategy.__init__(self, barFeed, cash, broker_)
     self._position = None
     self._started = False
예제 #6
0
 def __init__(self, barFeed, cash = 1000000, broker_ = None):
     Strategy.__init__(self, barFeed, cash, broker_)
     self._position = None
     self._started = False