def __init__(self, maxLen=None): super(SequenceDataSeries, self).__init__() maxLen = get_checked_max_len(maxLen) self.__newValueEvent = observer.Event() self.__values = collections.ListDeque(maxLen) self.__dateTimes = collections.ListDeque(maxLen)
def __init__(self, consumerKey, consumerSecret, accessToken, accessTokenSecret, track=[], follow=[], languages=[]): assert isinstance(track, list), "track must be a list" assert isinstance(follow, list), "follow must be a list" assert isinstance(languages, list), "languages must be a list" super(TwitterFeed, self).__init__() self.__event = observer.Event() self.__queue = Queue.Queue() self.__thread = None self.__running = False listener = Listener(self.__queue) auth = tweepy.OAuthHandler(consumerKey, consumerSecret) auth.set_access_token(accessToken, accessTokenSecret) self.__stream = tweepy.Stream(auth, listener) self.__track = track self.__follow = follow self.__languages = languages
def __init__(self, maxLen): super(BaseFeed, self).__init__() maxLen = dataseries.get_checked_max_len(maxLen) self.__ds = {} self.__event = observer.Event() self.__maxLen = maxLen
def __init__(self, maxLen=None): super(LiveTradeFeed, self).__init__(bar.Frequency.TRADE, maxLen) self.__barDicts = [] self.registerInstrument(common.btc_symbol) self.__prevTradeDateTime = None self.__thread = None self.__initializationOk = None self.__enableReconnection = True self.__stopped = False self.__orderBookUpdateEvent = observer.Event()
def __init__(self, cash, barFeed, commission=None): super(Broker, self).__init__() assert (cash >= 0) self.__cash = cash if commission is None: self.__commission = NoCommission() else: self.__commission = commission self.__shares = {} self.__activeOrders = {} self.__useAdjustedValues = False self.__fillStrategy = fillstrategy.DefaultStrategy() self.__logger = logger.getLogger(Broker.LOGGER_NAME) # It is VERY important that the broker subscribes to barfeed events before the strategy. barFeed.getNewValuesEvent().subscribe(self.onBars) self.__barFeed = barFeed self.__allowNegativeCash = False self.__nextOrderId = 1 self.__equityEvent = observer.Event() self.__equityEvent.subscribe(self.__fixPostionsAndCash)
def __init__(self, barFeed, broker): self.__barFeed = barFeed self.__broker = broker self.__activePositions = set() self.__orderToPosition = {} self.__barsProcessedEvent = observer.Event() self.__analyzers = [] self.__namedAnalyzers = {} self.__resampledBarFeeds = [] self.__dispatcher = dispatcher.Dispatcher() self.__broker.getOrderUpdatedEvent().subscribe(self.__onOrderEvent) self.__barFeed.getNewValuesEvent().subscribe(self.__onBars) self.__dispatcher.getStartEvent().subscribe(self.onStart) self.__dispatcher.getIdleEvent().subscribe(self.__onIdle) # It is important to dispatch broker events before feed events, specially if we're backtesting. self.__dispatcher.addSubject(self.__broker) self.__dispatcher.addSubject(self.__barFeed) # Initialize logging. self.__logger = logger.getLogger(BaseStrategy.LOGGER_NAME) self.__count = 0
def __init__(self): super(Broker, self).__init__() self.__orderEvent = observer.Event()
def __init__(self): super(ReturnsAnalyzerBase, self).__init__() self.__event = observer.Event() self.__portfolioReturns = None
def __init__(self): self.__subjects = [] self.__stop = False self.__startEvent = observer.Event() self.__idleEvent = observer.Event() self.__currDateTime = None