當前位置: 首頁>>代碼示例>>Python>>正文


Python strategy.Strategy方法代碼示例

本文整理匯總了Python中strategy.Strategy方法的典型用法代碼示例。如果您正苦於以下問題:Python strategy.Strategy方法的具體用法?Python strategy.Strategy怎麽用?Python strategy.Strategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在strategy的用法示例。


在下文中一共展示了strategy.Strategy方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def __init__(self, instance):
        strategy.Strategy.__init__(self, instance)
        self._waiting = False
        self.bid = 0
        self.ask = 0
        self.simulate = bool(conf['simulate'])
        self.simulate_or_live = 'SIMULATION - ' if self.simulate else 'LIVE - '
        self.base = self.instance.curr_base
        self.quote = self.instance.curr_quote
        self.wallet = False
        self.step_factor = 1 + DISTANCE / 100.0
        self.step_factor_sell = 1 + DISTANCE_SELL / 100.0
        self.temp_halt = False
        self.name = "%s.%s" % (__name__, self.__class__.__name__)
        self.debug("[s]%s%s loaded" % (self.simulate_or_live, self.name))
        self.help()

        # Simulation wallet
        if (self.simulate and not self.instance.wallet) or (self.simulate and self.wallet):
            self.init_simulation_wallet() 
開發者ID:caktux,項目名稱:pytrader,代碼行數:22,代碼來源:balancer.py

示例2: __init__

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def __init__(self, api):
        strategy.Strategy.__init__(self, api)
        self.signal_debug.connect(api.signal_debug)
        api.signal_keypress.connect(self.slot_keypress)
        # api.signal_strategy_unload.connect(self.slot_before_unload)
        api.signal_ticker.connect(self.slot_tick)
        api.signal_depth.connect(self.slot_depth)
        api.signal_trade.connect(self.slot_trade)
        api.signal_userorder.connect(self.slot_userorder)
        api.orderbook.signal_owns_changed.connect(self.slot_owns_changed)
        api.signal_wallet.connect(self.slot_wallet_changed)
        self.api = api
        self.name = "%s.%s" % (__name__, self.__class__.__name__)
        self.debug("[s]%s%s loaded" % (simulate_or_live, self.name))
        self.debug("[s]Press 'b' to see Buy objective")
        # get existing orders for later decision making
        self.existingorders = []
        for order in self.api.orderbook.owns:
            self.existingorders.append(order.oid) 
開發者ID:caktux,項目名稱:pytrader,代碼行數:21,代碼來源:buy.py

示例3: __init__

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def __init__(self, eventQueue, optCallDelta, maxCallDelta, optPutDelta, maxPutDelta, startTime, buyOrSell,
                 underlying, orderQuantity, daysBeforeClose, expCycle=None, optimalDTE=None,
                 minimumDTE=None, roc=None, minDaysToEarnings=None, minCredit=None, profitTargetPercent=None,
                 customManagement=None, maxBidAsk=None, maxMidDev=None, minDaysSinceEarnings=None, minIVR=None,
                 minBuyingPower=None):

        # For arguments that are not supported or don't have implementations, we return an exception to prevent
        # confusion.
        if not roc == None:
            raise NotImplementedError, "Specifying ROC currently not supported."

        if not minDaysToEarnings == None or not minDaysSinceEarnings == None:
            raise NotImplementedError, "Ability to filter out dates with respect to earnings currently not supported."

        if not minIVR == None:
            raise NotImplementedError, "Specifying implied volatility rank currently not implemented / supported."

        self.__eventQueue = eventQueue
        self.__strategy = "strangle"
        self.__optCallDelta = optCallDelta
        self.__maxCallDelta = maxCallDelta
        self.__optPutDelta = optPutDelta
        self.__maxPutDelta = maxPutDelta

        strategy.Strategy.__init__(self, startTime, self.__strategy, buyOrSell, underlying, orderQuantity,
                                   daysBeforeClose, expCycle, optimalDTE, minimumDTE, roc, minDaysToEarnings,
                                   minCredit, profitTargetPercent, customManagement, maxBidAsk, maxMidDev,
                                   minDaysSinceEarnings, minIVR, minBuyingPower) 
開發者ID:sirnfs,項目名稱:OptionSuite,代碼行數:30,代碼來源:StrangleStrat.py

示例4: test_default_strategy

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def test_default_strategy(self):
        self.assertEqual(Strategy().name, "Strategy_default") 
開發者ID:jackdbd,項目名稱:design-patterns,代碼行數:4,代碼來源:test_design_patterns.py

示例5: test_replacement_strategy_one

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def test_replacement_strategy_one(self):
        self.assertEqual(
            Strategy(execute_replacement1).name, "Strategy_execute_replacement1"
        ) 
開發者ID:jackdbd,項目名稱:design-patterns,代碼行數:6,代碼來源:test_design_patterns.py

示例6: test_replacement_strategy_two

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def test_replacement_strategy_two(self):
        self.assertEqual(
            Strategy(execute_replacement2).name, "Strategy_execute_replacement2"
        ) 
開發者ID:jackdbd,項目名稱:design-patterns,代碼行數:6,代碼來源:test_design_patterns.py

示例7: __init__

# 需要導入模塊: import strategy [as 別名]
# 或者: from strategy import Strategy [as 別名]
def __init__(self):

        # Set False for forward testing.
        self.live_trading = True

        self.log_level = logging.DEBUG
        self.logger = self.setup_logger()

        self.exchanges = self.load_exchanges(self.logger)

        self.db_client = MongoClient(
            self.DB_URL,
            serverSelectionTimeoutMS=self.DB_TIMEOUT_MS)
        self.db_prices = self.db_client[self.DB_PRICES]
        self.db_other = self.db_client[self.DB_OTHER]
        self.check_db_connection()

        # Main event queue.
        self.events = queue.Queue(0)

        # Producer/consumer worker classes.
        self.data = Datahandler(self.exchanges, self.logger, self.db_prices,
                                self.db_client)

        self.strategy = Strategy(self.exchanges, self.logger, self.db_prices,
                                 self.db_other, self.db_client)

        self.portfolio = Portfolio(self.exchanges, self.logger, self.db_other,
                                   self.db_client, self.strategy.models)

        self.broker = Broker(self.exchanges, self.logger, self.portfolio,
                             self.db_other, self.db_client, self.live_trading)

        # Processing performance tracking variables.
        self.start_processing = None
        self.end_processing = None
        self.cycle_count = 0

        self.run() 
開發者ID:s-brez,項目名稱:trading-server,代碼行數:41,代碼來源:server.py


注:本文中的strategy.Strategy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。