Пример #1
0
    def insertMasterEquities(count=1):
        """ TODO: describe the method here """
        index = 0
        total = count if (count < len(MASTER_BULLS)) else len(MASTER_BULLS)
        while index < total:
            bull = MASTER_BULLS[index]
            bear = MASTER_BEARS[index]
            etf = MASTER_ETFS[index]
            leverage = MASTER_LEVERAGE[index]
            owners = MASTER_OWNERS[index]
            name = MASTER_NAMES[index]
            top_15 = MASTER_TOP15[index]

            #Check if a bull/bear pair has already been uploaded.
            entry = RobotEquitySymbols.objects.filter(
                bullishSymbol=bull).filter(bearishSymbol=bear).filter(
                    symbol=etf)

            if (entry == None) or (len(entry) == 0):
                entry = RobotEquitySymbols.objects.create(name=name,
                                                          bullishSymbol=bull,
                                                          bearishSymbol=bear,
                                                          symbol=etf,
                                                          owners=owners,
                                                          top_15_stocks=top_15,
                                                          leverage=leverage)
            else:
                displayOutput(
                    str=
                    "Nothing was inserted because entry was already present. Bull={} Bear={}"
                    .format(bull, bear))
            index = index + 1

        return True
Пример #2
0
    def processJSONEntry(self):
        displayOutput("Processing Entry from DICT File. {}".format(
            self.json_content))
        try:
            self.config = json.loads(self.json_content)
        except:
            displayOutput(
                str="ERROR: There was an error reading the JSON File content. {}"
                .format(''))
            self.valid = False
            return

        self.valid = False if self.entries_key not in self.config else True
        if not self.valid:
            displayOutput(str="Invalid Config File. Missing key {}".format(
                self.entries_key))
            return

        self.validateConfig()
        if not self.valid:
            displayOutput(
                str="Invalid JSON Entry. {}".format(self.json_content))
            return

        self.matchWithAllowedSymbols()
        if not self.valid:
            displayOutput(
                "Invalid Bull/Bear/ETF Symbols. Some symbol(s) aren't allowed. Please review your config file. {}"
                .format(self.json_content))

        return

        self.valid = True
Пример #3
0
 def setUpTestData(self):
     displayOutput(str="Setting up {0}".format(self.testname))
     cb = CustomerBasic.objects.create(first_name='John',
                                       last_name='Doe',
                                       username='******',
                                       main_phone='919 111 2222',
                                       alternate_phone='800 123 4567',
                                       alternate_email='*****@*****.**',
                                       main_email='*****@*****.**')
     self.cb_id = cb.pk
Пример #4
0
 def setUpTestData(self):
     displayOutput(
         str="Setting up Test Data for test: {}".format(self.test_name))
     #Set up the Data to feed the Robot.
     RobotEquitySymbols.insertMasterEquities(count=self.number_entries)
     #Start Date on October 01
     start_date = datetime.datetime(2020, 10, 1,
                                    tzinfo=timezone.utc).isoformat()
     backtesting = BackTestInfrastructure(action='download',
                                          useMasterTable=True)
     response = backtesting.processTradeData(start_date=start_date)
     response0 = backtesting.downloadAndStore(target='both', update=False)
Пример #5
0
 def getBearStockQuote(self, index):
     try:
         value = self.bear_df.at[index - 1, 'open']
     except KeyError:
         value = -1
         if index > 1:
             displayOutput(
                 str=
                 "Accessing Bear Panda data has reached end of file. Index={0}"
                 .format(index - 1))
         else:
             displayError(
                 str="There was an error accessing Bear Panda data. Index={0}"
                 .format(index - 1))
     return value
Пример #6
0
  def setUpTestData(self):
    displayOutput("Setting up {0}".format(self.testname))
    
    #Create Portfolio against ETrade. Use 10% of the Portfolio Budget
    etrade = Portfolio.objects.create(name=self.port_name,description=self.port_description,
      initial_cash_funds=self.initial_cash_funds,current_cash_funds=self.current_cash_funds,max_robot_fraction='10%',
      cash_position_update_policy='immediate')
    self.p_id = etrade.pk

    self.robot = ETFAndReversePairRobot.objects.create(portfolio=etrade)

    budget = RobotBudgetManagement.objects.create(use_percentage_or_fixed_value='Number',add_taxes=False,
      max_budget_per_purchase_number=self.max_budget_per_purchase, add_commission=False,add_other_costs=False,
                                                  pair_robot_id=self.robot.id)
    self.budget_id = budget.pk
Пример #7
0
    def buy(self):
        """
      TODO:
    """

        if self.acquisitionConditionMet():
            order_ids = self.robot.addNewRoundtripEntry(
                business_day=self.robot.current_timestamp)
            root_id = order_ids['bull_buy_order_client_id'].replace(
                '_buy_' + self.robot.getBullishSymbol(), '')
            rt = RoundTrip(robot=self.robot, root_id=root_id)
            self.robot.updateBudgetAfterPurchase(amount=rt.getBullCostBasis())
            self.robot.updateBudgetAfterPurchase(amount=rt.getBearCostBasis())
        else:
            displayOutput(str="Acquisition Condition is not met")
Пример #8
0
 def matchWithAllowedSymbols(self):
     entries = self.config['entries']
     for x in entries:
         valid_pair = RobotEquitySymbols.isValidPair(bull=x['bull'],
                                                     bear=x['bear'],
                                                     etf=x['etf'])
         if not valid_pair:
             data = "Data: Bull={} Bear={} Etf={}".format(
                 x['bull'], x['bear'], x['etf'])
             displayOutput(
                 str=
                 "ERROR: Invalid Config File Entry. Bull/Bear entry is not in list of approved Bull/Bear ETFs. {}"
                 .format(data))
             self.valid = False
             break
     return
Пример #9
0
    def testBabadjouStrategyCreation(self):
        #Find the Robot to carry the Execution
        displayOutput(str="Testing the Babadjou Strategy Scenario")
        robot_0 = ETFAndReversePairRobot.objects.get(pk=self.robot_id)
        strategy_instance = EquityStrategy.objects.get(pk=self.entry_id)

        strategy_imple = BabadjouStrategy(robot=robot_0)

        self.assertEqual(strategy_imple.isValid(), True)
        self.assertEqual(strategy_imple.isBabadjouStrategy(), True)

        self.assertEqual(strategy_imple.isBatchamStrategy(), False)
        self.assertEqual(strategy_imple.isBalatchiStrategy(), False)

        self.assertEqual(strategy_imple.hasTransitionStep(), True)
        self.assertEqual(strategy_imple.hasBalancedTransition(), True)

        self.assertEqual(strategy_instance.isBabadjouStrategy(), True)
Пример #10
0
    def downloadBullToFile(self):
        #Download the Bull
        payload_data = self.payload
        symbol = payload_data['bull']
        force = payload_data['force']
        data_root_folder = payload_data['data_folder_root']

        file_name = self.generateFileName(source='bull')

        if (force == True) or (not os.path.exists(file_name)):
            alpaca = AlpacaPolygon(payload=payload_data)
            bull_data_frame = alpaca.quotesToSave(symbol=symbol)
            time.sleep(5)
            #print("The output goes here {}".format(file_name))
            bull_data_frame.to_csv(file_name)
        else:
            displayOutput(
                str="Bull File already exist. No need to recreate it.")
Пример #11
0
    def setUpTestData(self):
        displayOutput(
            str="Setting up the test cases for  {} ".format(self.test_name))
        sentiment_0 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Automatic',
            external_sentiment=self.s_bull_bear_0[0],
            market_sentiment=self.s_bull_bear_0[1],
            sector_sentiment=self.s_bull_bear_0[2],
            equity_sentiment=self.s_bull_bear_0[3],
            external_sentiment_weight=self.s_bull_bear_weight_0[0],
            market_sentiment_weight=self.s_bull_bear_weight_0[1],
            sector_sentiment_weight=self.s_bull_bear_weight_0[2],
            equity_sentiment_weight=self.s_bull_bear_weight_0[3])

        self.s0_id = sentiment_0.pk
Пример #12
0
 def getTimestamp(self, index):
     try:
         value = self.bear_df.at[index - 1, 'timestamp']
         parsed = dateutil.parser.parse(value)
         #strToDatetime
         return parsed
     except KeyError:
         value = -1
         if index > 1:
             displayOutput(
                 str=
                 "Accessing Timestamp Panda data has reached end of file. Index={0}"
                 .format(index - 1))
         else:
             displayError(
                 str="There was an error accessing Bear Panda data. Index={0}"
                 .format(index - 1))
     return value
Пример #13
0
    def matchWithAllowedSymbols(self):
        entries = self.config['entries']
        for x in entries:
            if not x['bull'] in master_bulls:
                displayOutput(
                    str=
                    "ERROR: Invalid Config File Entry. Bull entry is not in list of approved Bull ETFs. {}"
                    .format(x['bull']))
                self.valid = False
            elif not x['bear'] in master_bears:
                displayOutput(
                    str=
                    "ERROR: Invalid Config File Entry. Bear entry is not in list of approved Bear ETFs. {}"
                    .format(x['bear']))
                self.valid = False
            elif not x['etf'] in master_etfs:
                displayOutput(
                    str=
                    "ERROR: Invalid Config File Entry. ETF entry is not in list of approved ETFs. {}"
                    .format(x['etf']))
                self.valid = False

            if not self.valid:
                break
        return
Пример #14
0
    def processTradeData(self, start_date=None, end_date=None, pairs=None):
        if not self.isValid():
            return False

        if shouldUsePrint():
            print(self.config)

        default_start_date = datetime.datetime(
            2020, 10, 1, tzinfo=timezone.utc).isoformat()
        default_end_date = default_start_date
        default_pairs = self.config[self.entries_key]
        self.start_date = start_date if not (start_date
                                             == None) else default_start_date
        self.end_date = end_date if not (end_date
                                         == None) else default_end_date
        self.pairs = pairs if not (pairs == None) else default_pairs

        alpaca = AlpacaMarketClock()
        trading_dates = alpaca.getTradingCalendar(start_date=self.start_date,
                                                  end_date=end_date)

        entries = []
        for pair in self.pairs:
            displayOutput(str="Pair={}".format(pair))
            #for day in trading_dates:
            config_dict = dict()
            entry = [{
                'bull': pair['bull'],
                'bear': pair['bear'],
                'etf': pair['etf'],
                'start_date': day['start_date'],
                'end_date': day['start_date']
            } for day in trading_dates]
            config_dict['entries'] = entry
            entries.append(config_dict.copy())

        self.config = entries
        return entries
Пример #15
0
    def __init__(self,
                 config_file=None,
                 config_file_folder=None,
                 start_date=None,
                 action=None,
                 useMasterTable=False):
        #Not used.
        #self.tests_root_folder_key='EGGHEAD_TESTS_FOLDER'
        self.config_folder_key = 'EGGHEAD_CONFIG_FOLDER'
        self.config_file_key = 'EGGHEAD_CONFIG_FILE'
        self.data_folder_root_key = 'EGGHEAD_DATA_FOLDER'
        self.default_config_file = 'config_egghead.json'
        # Keys
        self.bullish_key = 'bull'
        self.bearish_key = 'bear'
        self.etf_key = 'etf'
        self.entries_key = 'entries'

        self.valid = True
        self.config = None
        #datetime.datetime(2020,10,1,tzinfo=timezone.utc).isoformat()
        self.default_start_date = (date.today() +
                                   datetime.timedelta(days=-1)).isoformat()
        self.default_end_date = (date.today() +
                                 datetime.timedelta(days=-1)).isoformat()

        if (useMasterTable):
            displayOutput(str="Loading all ETFs from Master File")
            entries = dict()
            self.config = RobotEquitySymbols.getMasterEntriesAsJSON()
        elif (action == 'download' or (action == None)):
            self.config_file = config_file
            self.config_file_folder = config_file_folder
            self.processConfigEntries()

        self.default_trading_unit = 5  #5 minutes interval of data
        self.default_trading_unit_etf = 60  #For ETFs, we use 60 minutes intervals
        self.default_resolution = 'minute'  # We use Minute units
Пример #16
0
    def sell(self):
        """
      The Batcham Strategy does not have any intermediate steps.
      Therefore assets will be moved from Stable to Completion.

      During the Disposition step, two things are checked.
      0. Generic checks will be done to see if this is a good time to sell. This involves things like:
        A. Market Trading Window is Opened for sale?
        B. Infrastructure condition (enough space on the assembly line in the right section?)
        C. Disposition policy
        D. Catastrophic external Condition.

      
      1. Assets in Stable will be moved to Completion, if they meet the Completion criteria.
    """
        #print("Running Sell on the Batcham Strategy")

        #Is it a good time to sell?
        if not self.dispositionConditionMet():
            return

        completed = self.robot.getCompletedRoundTrips()
        completed.printCompletionReport()

        #Process Completion Candidates
        completion_candidates = BatchamCompletionCandidates(robot=self.robot)
        if not completion_candidates.isEmpty():
            winner = completion_candidates.getCompletionWinner()
            if self.matchesBatchamCompletionTarget(winner=winner):
                displayOutput(str="Found a winner. {}".format(
                    completion_candidates.getCompletionCandidateReportData()))
                self.moveToCompletion(winner=winner)
            else:
                displayOutput(
                    str="Completion Winner is not yet good enough: {}".format(
                        completion_candidates.getCompletionCandidateReportData(
                        )))
        else:
            displayOutput(
                str=" The Transition to Completion List is empty. ".format())
Пример #17
0
    def validateConfig(self):
        entries = self.config['entries']
        for x in entries:
            if not self.bullish_key in x:
                displayOutput(
                    str=
                    "ERROR: Invalid Config File Entry. Missing Required Bull Symbol in entry. {}"
                    .format(x))
                self.valid = False
            elif not self.bearish_key in x:
                displayOutput(
                    str=
                    "ERROR: Invalid Config File Entry. Missing Required Bear Symbol in entry. {}"
                    .format(x))
                self.valid = False
            elif not self.etf_key in x:
                displayOutput(
                    str=
                    "ERROR: Invalid Config File Entry. Missing Required ETF Symbol in entry. {}"
                    .format(x))
                self.valid = False

            if not self.valid:
                break
Пример #18
0
  def executeBackTest(self):
    user_name = 'Dummy User' if self.request==None else self.request.user.get_username()
    displayOutput("{} is executing Backtest with data:{}".format(user_name,self.executor_id))

    executor = ETFPairRobotExecution.objects.get(pk=self.executor_id)
    
    #Delete all entries made by this executor. 
    #Clear the Data from own executiondata class
    #clear data from TradeDataHolder class
    ETFPairRobotExecutionData.deleteExecutionRecords(robot_execution=executor)
    
    #Associate Executor to the Robot, Remove any data that might have been created prior by Execution Engine
    self.robot.setExecutionEngine(execution_engine=executor,purge_previous=True) 

    payload = self.robot.getSymbolsPairAsPayload()
    logger.info("Payload: {0}".format(payload))
  
    serialized = self.robot.getSerializedRobotObject()

    if isinstance(self.datasource,BackTestArrayInfrastructure):
      #Update the Executor Status to 'in progress', save the config_parameters
      executor.config_params = serialized
      executor.start_date=None 
      executor.end_date = None 
      executor.execution_status='in progress'
      executor.save()
     
      #Initialize the Datafeed Infrastructure
      backtest_data = self.datasource.getFeedData()

      #Launch the Run ...
      for feed in backtest_data:
        self.robot.prepareTrades(key=feed)
      
      #Upon completion, mark it as completed.
      executor.result_data = 'TODO: results go here.'
      executor.execution_status='completed'
      executor.save()

    elif isinstance(self.datasource,BackTestFileInfrastructure):
      #Update the Executor 
      executor.config_params = serialized
      executor.start_date=None 
      executor.end_date = None 
      executor.execution_status='in progress'
      executor.save()
     
      #Initialize the Datafeed Infrastructure
      backtest_data = self.datasource.getFeedData()
      #Launch the Run ...
      for feed in backtest_data:
        self.robot.prepareTrades(key=feed)
      
      #Upon completion, mark it as completed.
      executor.result_data = 'TODO: results go here.'
      executor.execution_status='completed'
      executor.save()

    elif isinstance(self.datasource,BackTestDatabaseInfrastructure):
      #Update the Executor 
      executor.config_params = serialized
      executor.execution_status='in progress'
      executor.save()
     
      #
      backtest_data = self.datasource.getFeedData(start_date=executor.exec_start_date,end_date=executor.exec_end_date)
      data_amount = len(backtest_data)
      logger.info("Test Data Size={}".format(data_amount))

      #Launch the Run ...
      for feed in backtest_data:
        payload=feed.getBasicInformation()
        self.robot.prepareTrades(key=payload)

      #Upon completion, mark it as completed.
      executor.result_data = 'TODO: results go here.'
      executor.execution_status='completed'
      executor.save()
    else:
      print("Executor type not found.... try again")

    return True 
Пример #19
0
    def processConfigEntries(self):

        if self.config_file_folder == None:
            if not self.config_folder_key in os.environ:
                displayOutput(
                    str="No Folder provided and No Default folder specified. {}"
                    .format(self.config_folder_key))
                self.valid = False
                return
            else:
                displayOutput(
                    str="No Parent folder provided. Using default Folder {}".
                    format(os.environ[self.config_folder_key]))
                self.config_file_folder = os.environ[self.config_folder_key]

        if self.config_file == None:
            if not self.config_file_key in os.environ:
                displayOutput(
                    str=
                    "No file specified and no CONFIG_FILE specified. {0}. Will try default config file {0}"
                    .format(self.default_config_file))
                self.config_file = self.default_config_file
            else:
                self.config_file = os.environ[self.config_file_key]

        #Add trailing '/', if none exist
        temp_folder = self.config_file_folder
        self.config_file_folder = temp_folder if temp_folder.endswith(
            '/') else temp_folder + '/'

        #Remove leading '/' from the filename, if one exists
        temp_file = self.config_file
        self.config_file = temp_file if not temp_file.startswith(
            '/') else temp_file.strip('/')

        file_path = self.config_file_folder + self.config_file
        if not os.path.isfile(file_path):
            displayOutput(
                str="ERROR: Folder+File does not exist. {}".format(file_path))
            self.valid = False
            return

        #Load the Config File
        with open(file_path) as file:
            try:
                self.config = json.load(file)
            except:
                self.valid = False
                displayOutput(
                    str="Error Reading JSON File.  {0}.".format(file_path))
            file.close()

        if not self.valid:
            return

        self.valid = False if self.entries_key not in self.config else True
        if not self.valid:
            displayOutput(str="Invalid Config File. Missing key {}".format(
                self.entries_key))
            return

        self.validateConfig()
        if not self.valid:
            displayOutput(str="Invalid Config File. {}".format(file_path))
            return

        self.matchWithAllowedSymbols()
        if not self.valid:
            displayOutput(
                "Invalid Bull/Bear/ETF Symbols. Some symbol(s) aren't allowed. Please review your config file. {}"
                .format(file_path))

        return
Пример #20
0
    def setUpTestData(self):
        displayOutput(str="Setting up {0}".format(self.testname))
        alpacaBrokerage = BrokerageInformation.objects.create(
            brokerage_type='Alpaca',
            name='Alpaca Brokerage',
            website='https://alpaca.markets/')

        alpacaPortfolio = Portfolio.objects.create(
            name='Alpaca Portfolio',
            initial_cash_funds=100000,
            current_cash_funds=100000,
            brokerage_id=alpacaBrokerage.id,
            max_robot_fraction=.10,
            cash_position_update_policy='immediate',
            description='Alpaca Portfolio description')

        nasdaq = RobotEquitySymbols.objects.create(name='Nasdaq',
                                                   symbol=self.etf,
                                                   bullishSymbol=self.bullish,
                                                   bearishSymbol=self.bearish)
        now = datetime.datetime.now(getTimeZoneInfo())

        strategy = EquityStrategy.objects.create(
            name='My Best Equity Strategy So Far',
            description='This is just a test',
            creation_date=now,
            modify_date=now,
            strategy_class='Bullish Bearish Pair',
            strategy_category='Babadjou',
            visibility=False,
            minimum_entries_before_trading=2,
            trade_only_after_fully_loaded=False,
            manual_asset_composition_policy=True,
            automatic_generation_client_order_id=True)
        self.entry_id = strategy.pk

        acquisition = AcquisitionPolicy.objects.create(
            strategy=strategy,
            acquisition_time_proximity=False,
            min_time_between_purchases=60,
            and_or_1='AND',
            acquisition_volume_proximity=False,
            min_volume_between_purchases='15M',
            volume_fraction_to_average=3,
            and_or_2='AND',
            acquisition_price_proximity=True,
            acquisition_price_factor='Bull',
            bear_acquisition_volatility_factor='.01',
            number_or_percentage='Stock Price by Number',
            proximity_calculation_automatic=True,
            bull_acquisition_volatility_factor='.10',
            simultaneous_bull_bear_acquisitions=True)
        self.acq_entry = acquisition.pk

        disposition = DispositionPolicy.objects.create(
            strategy=strategy,
            in_transition_profit_policy=True,
            in_transition_profit_target_ratio='.15',
            completion_profit_policy=True,
            completion_complete_target_ratio='.40',
            in_transition_asset_composition='2Bull x 1Bear',
            in_transition_entry_strategy='bestbull_and_worstbear')
        self.disposition_id = disposition.pk

        robot = ETFAndReversePairRobot.objects.create(
            name=self.base_name,
            description=self.description,
            portfolio=alpacaPortfolio,
            strategy=strategy,
            symbols=nasdaq,
            enabled=True,
            owner=None,
            visibility=True,
            version='1.0.0',
            max_hold_time='14',
            minimum_hold_time='1',
            hold_time_includes_holiday=True,
            sell_remaining_before_buy=False,
            liquidate_on_next_opportunity=False,
            internal_name=self.internal_name,
            max_roundtrips=self.max_roundtrips,
            cost_basis_per_roundtrip=self.cost_basis_per_roundtrip,
            profit_target_per_roundtrip=self.profit_basis_per_roundtrip)
        self.robot_id = robot.pk

        sentiment = EquityAndMarketSentiment.objects.create(
            pair_robot=robot,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Automatic')

        self.sentiment_id = sentiment.pk
        self.budget_management = RobotBudgetManagement.objects.create(
            pair_robot=robot,
            max_budget_per_purchase_number=self.cost_basis_per_roundtrip,
            use_percentage_or_fixed_value='Number')

        activities = RobotActivityWindow.objects.create(
            pair_robot=robot,
            trade_before_open=True,
            trade_after_close=False,
            trade_during_extended_opening_hours=False,
            offset_after_open='0',
            offset_before_close='0',
            blackout_midday_from='10:00am',
            blackout_midday_time_interval='0')
Пример #21
0
 def testRandomComposition(self):
   displayOutput(str="Testing Random composition")
   self.assertEqual(True,True)
Пример #22
0
 def setUpTestData(self):
     displayOutput(str="Setting up {0}".format(CustomerProfileTestCase))
     cp = CustomerProfile.objects.create()
     self.cp_id = cp.pk
Пример #23
0
 def testReportGeneration(self):
     displayOutput(str="Testing the Report Generation Scenario")
     self.assertEqual(True, True)
Пример #24
0
 def setUpTestData(self):
   #Parameters to validate: regular market, market closed, pre-market, post-market, extended pre market, trade all markets combined,
   # Midday Black out. With pre-market, with post market, with extended, combined all
   displayOutput(str=" Setting up Tests for {}".format(self.test_name)) 
Пример #25
0
 def testChecklist1(self):
     displayOutput(str="Testing the checklist1")
     self.assertEqual(True, True)
Пример #26
0
    def setUpTestData(self):
        displayOutput(
            str=
            "Setting up the test cases for  EquityAndMarketSentimentClassBasicTestCase ... "
        )
        sentiment_0 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_0[0],
            market_sentiment=self.s_bull_bear_0[1],
            sector_sentiment=self.s_bull_bear_0[2],
            equity_sentiment=self.s_bull_bear_0[3],
            external_sentiment_weight=self.s_bull_bear_weight_0[0],
            market_sentiment_weight=self.s_bull_bear_weight_0[1],
            sector_sentiment_weight=self.s_bull_bear_weight_0[2],
            equity_sentiment_weight=self.s_bull_bear_weight_0[3])

        self.s0_id = sentiment_0.pk

        sentiment_1 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_1[0],
            market_sentiment=self.s_bull_bear_1[1],
            sector_sentiment=self.s_bull_bear_1[2],
            equity_sentiment=self.s_bull_bear_1[3],
            external_sentiment_weight=self.s_bull_bear_weight_1[0],
            market_sentiment_weight=self.s_bull_bear_weight_1[1],
            sector_sentiment_weight=self.s_bull_bear_weight_1[2],
            equity_sentiment_weight=self.s_bull_bear_weight_1[3])

        self.s1_id = sentiment_1.pk

        sentiment_2 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_2[0],
            market_sentiment=self.s_bull_bear_2[1],
            sector_sentiment=self.s_bull_bear_2[2],
            equity_sentiment=self.s_bull_bear_2[3],
            external_sentiment_weight=self.s_bull_bear_weight_2[0],
            market_sentiment_weight=self.s_bull_bear_weight_2[1],
            sector_sentiment_weight=self.s_bull_bear_weight_2[2],
            equity_sentiment_weight=self.s_bull_bear_weight_2[3])

        self.s2_id = sentiment_2.pk

        sentiment_3 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_3[0],
            market_sentiment=self.s_bull_bear_3[1],
            sector_sentiment=self.s_bull_bear_3[2],
            equity_sentiment=self.s_bull_bear_3[3],
            external_sentiment_weight=self.s_bull_bear_weight_3[0],
            market_sentiment_weight=self.s_bull_bear_weight_3[1],
            sector_sentiment_weight=self.s_bull_bear_weight_3[2],
            equity_sentiment_weight=self.s_bull_bear_weight_3[3])

        self.s3_id = sentiment_3.pk

        sentiment_4 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_4[0],
            market_sentiment=self.s_bull_bear_4[1],
            sector_sentiment=self.s_bull_bear_4[2],
            equity_sentiment=self.s_bull_bear_4[3],
            external_sentiment_weight=self.s_bull_bear_weight_4[0],
            market_sentiment_weight=self.s_bull_bear_weight_4[1],
            sector_sentiment_weight=self.s_bull_bear_weight_4[2],
            equity_sentiment_weight=self.s_bull_bear_weight_4[3])

        self.s4_id = sentiment_4.pk

        sentiment_5 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_5[0],
            market_sentiment=self.s_bull_bear_5[1],
            sector_sentiment=self.s_bull_bear_5[2],
            equity_sentiment=self.s_bull_bear_5[3],
            external_sentiment_weight=self.s_bull_bear_weight_5[0],
            market_sentiment_weight=self.s_bull_bear_weight_5[1],
            sector_sentiment_weight=self.s_bull_bear_weight_5[2],
            equity_sentiment_weight=self.s_bull_bear_weight_5[3])

        self.s5_id = sentiment_5.pk

        sentiment_6 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_bull_bear_6[0],
            market_sentiment=self.s_bull_bear_6[1],
            sector_sentiment=self.s_bull_bear_6[2],
            equity_sentiment=self.s_bull_bear_6[3],
            external_sentiment_weight=self.s_bull_bear_weight_6[0],
            market_sentiment_weight=self.s_bull_bear_weight_6[1],
            sector_sentiment_weight=self.s_bull_bear_weight_6[2],
            equity_sentiment_weight=self.s_bull_bear_weight_6[3])

        self.s6_id = sentiment_6.pk

        ####### All Bear, All Bulls, All Neutrals below
        sentiment_7 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_all_bearish[0],
            market_sentiment=self.s_all_bearish[1],
            sector_sentiment=self.s_all_bearish[2],
            equity_sentiment=self.s_all_bearish[3],
            external_sentiment_weight=self.s_all_bearish_weight[0],
            market_sentiment_weight=self.s_all_bearish_weight[1],
            sector_sentiment_weight=self.s_all_bearish_weight[2],
            equity_sentiment_weight=self.s_all_bearish_weight[3])

        self.s7_id = sentiment_7.pk

        sentiment_8 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_all_bullish[0],
            market_sentiment=self.s_all_bullish[1],
            sector_sentiment=self.s_all_bullish[2],
            equity_sentiment=self.s_all_bullish[3],
            external_sentiment_weight=self.s_all_bullish_weight[0],
            market_sentiment_weight=self.s_all_bullish_weight[1],
            sector_sentiment_weight=self.s_all_bullish_weight[2],
            equity_sentiment_weight=self.s_all_bullish_weight[3])

        self.s8_id = sentiment_8.pk

        sentiment_9 = EquityAndMarketSentiment.objects.create(
            pair_robot=None,
            influences_acquisition=True,
            circuit_breaker=False,
            sentiment_feed='Manual',
            external_sentiment=self.s_all_neutral[0],
            market_sentiment=self.s_all_neutral[1],
            sector_sentiment=self.s_all_neutral[2],
            equity_sentiment=self.s_all_neutral[3],
            external_sentiment_weight=self.s_all_neutral_weight[0],
            market_sentiment_weight=self.s_all_neutral_weight[1],
            sector_sentiment_weight=self.s_all_neutral_weight[2],
            equity_sentiment_weight=self.s_all_neutral_weight[3])

        self.s9_id = sentiment_9.pk
Пример #27
0
def test_robots_activity_window_dummy(request):
  displayOutput(str=" This is just a dummy function ")
Пример #28
0
 def setUpTestData(self):
   displayOutput(str="Setting up {0}".format(self.testname))
Пример #29
0
 def setUpTestData(self):
   displayOutput("Setting up Test: {}".format(self.test_name))
   today = datetime.now(getTimeZoneInfo())
Пример #30
0
 def downloadTop15ToFile(self):
     displayOutput(str="Not yet implemented.")