コード例 #1
0
ファイル: test_strategy3.py プロジェクト: ongbe/hedgeit
 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
ファイル: test_strategy3.py プロジェクト: raka747/hedgeit
 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
ファイル: msymfut.py プロジェクト: Johnx123z/hedgeit
    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
ファイル: test_strategy2.py プロジェクト: raka747/hedgeit
 def __init__(self, barFeed, cash=1000000, broker_=None):
     Strategy.__init__(self, barFeed, cash, broker_)
     self._position = None
     self._started = False
コード例 #6
0
ファイル: test_strategy2.py プロジェクト: Johnx123z/hedgeit
 def __init__(self, barFeed, cash = 1000000, broker_ = None):
     Strategy.__init__(self, barFeed, cash, broker_)
     self._position = None
     self._started = False