当前位置: 首页>>代码示例>>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;未经允许,请勿转载。