Beispiel #1
0
    def GetDataMarket(self, market_obj, path, date, scrip, windowInterval):
        common_functions_obj = CCommonFunctions()
        filename = path + '/' + common_functions_obj.FormatDate(
            date) + '/' + scrip.replace(
                ':', '') + '_' + common_functions_obj.FormatDate(
                    date) + '_trades.csv'
        with open(filename, 'rb') as marketTrade_file_obj:
            marketTrade_file_contents = csv.reader(marketTrade_file_obj)
            market_obj.m_strScripName = scrip

            for row in marketTrade_file_contents:
                if row[0].strip() == scrip:
                    market_obj.m_nCountOfRows += 1
                    market_obj.m_DatetimeList.append(
                        common_functions_obj.GetDateTime(
                            row[2].strip(), row[3].strip()))
                    market_obj.m_fPriceList.append(float(row[4].strip()))
                    market_obj.m_nSizeList.append(int(row[5].strip()))
            market_obj.m_strTimeWindowList = common_functions_obj.GetDateTimeList(
                date,
                common_functions_obj.GetWindowList(windowInterval)[0])
            market_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(
                date,
                common_functions_obj.GetWindowList(windowInterval)[1])
            CCommonFunctions.total_daily_market_volume = sum(
                market_obj.m_nSizeList)
        return True
Beispiel #2
0
    def GetDataTwapPortfolio(self, portfolio_twap_obj, path, input_date,
                             filename, scrip, windowInterval):
        common_functions_obj = CCommonFunctions()
        filename = path + '/' + common_functions_obj.FormatDate(
            input_date) + '/' + filename
        with open(filename, 'rb') as portfolio_file_obj:
            portfolio_file_contents = csv.reader(portfolio_file_obj)
            portfolio_twap_obj.m_strScripName = scrip

            for row in portfolio_file_contents:
                if row[1].strip() == scrip:
                    temp_datetime = row[0].strip().split(' ')
                    date = temp_datetime[0]
                    time = temp_datetime[1]
                    portfolio_twap_obj.m_nCountOfRows += 1
                    portfolio_twap_obj.m_DatetimeList.append(
                        common_functions_obj.GetDateTimePortfolio(date, time))
                    portfolio_twap_obj.m_strOrderIDList.append(row[2].strip())
                    portfolio_twap_obj.m_strStatusList.append(row[3].strip())
                    portfolio_twap_obj.m_nOrderQtyList.append(
                        int(row[4].strip()))
                    portfolio_twap_obj.m_fOrderPriceList.append(
                        float(row[5].strip()))
                    portfolio_twap_obj.m_strSideList.append(row[6].strip())
                    portfolio_twap_obj.m_nFilledSizeList.append(row[7].strip())
                    portfolio_twap_obj.m_fAvgPriceList.append(row[8].strip())
                    portfolio_twap_obj.m_fPriceList.append(row[9].strip())
                    portfolio_twap_obj.m_nSizeList.append(row[10].strip())
                    portfolio_twap_obj.m_FillDateTimeList.append(
                        common_functions_obj.GetDateTimePortfolio(date, time))

                    if row[3].strip().upper() == 'COMPLETE':
                        portfolio_twap_obj.m_OrderCompleteDatetimeList.append(
                            common_functions_obj.GetDateTimePortfolio(
                                date, time))
                        portfolio_twap_obj.m_fOrderCompleteAvgPriceList.append(
                            row[8].strip())

                    if not row[9].strip().upper() == 'NONE':
                        portfolio_twap_obj.m_OrderExecutionDatetimeList.append(
                            common_functions_obj.GetDateTimePortfolio(
                                date, time))
                        portfolio_twap_obj.m_fOrderExecutionFillPriceList.append(
                            row[9].strip())

            portfolio_twap_obj.m_strTimeWindowList = common_functions_obj.GetDateTimeList(
                input_date,
                common_functions_obj.GetWindowList(windowInterval)[0])
            portfolio_twap_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(
                input_date,
                common_functions_obj.GetWindowList(windowInterval)[1])
        return True
    def FormatDataTwapPortfolio(self, portfolio_obj, portfolio_data_list):
        common_functions_obj = CCommonFunctions()
        portfolio_obj.m_strScripName = portfolio_data_list[0]['ScripName']
        temp_date = portfolio_data_list[0]['DateTime'].date()
        temp_date = str(temp_date.day) + '-' + str(temp_date.month) + '-' + str(temp_date.year)
        print "temp date :" + str(temp_date)
        for portfolio_data in portfolio_data_list:
            portfolio_obj.m_nCountOfRows += 1
            portfolio_obj.m_DatetimeList.append(portfolio_data['DateTime'])
            portfolio_obj.m_strOrderIDList.append(portfolio_data['OrderID'])
            portfolio_obj.m_strStatusList.append(portfolio_data['Status'])
            portfolio_obj.m_nOrderQtyList.append(portfolio_data['OrderQty'])
            portfolio_obj.m_fOrderPriceList.append(portfolio_data['OrderPrice'])
            portfolio_obj.m_strSideList.append(portfolio_data['Side'])
            portfolio_obj.m_nFilledSizeList.append(portfolio_data['FilledSize'])
            portfolio_obj.m_fAvgPriceList.append(portfolio_data['AvgPrice'])
            portfolio_obj.m_fPriceList.append(portfolio_data['Price'])
            portfolio_obj.m_nSizeList.append(portfolio_data['Size'])
            
            if portfolio_data['Status'].upper() == 'COMPLETE':
                portfolio_obj.m_OrderCompleteDatetimeList.append(portfolio_data['DateTime'])
                portfolio_obj.m_fOrderCompleteAvgPriceList.append(portfolio_data['AvgPrice'])
            
            if not (portfolio_data['Price'].upper() == 'NULL' or portfolio_data['Price'].upper() == 'NONE'):
                portfolio_obj.m_OrderExecutionDatetimeList.append(portfolio_data['DateTime'])
                portfolio_obj.m_fOrderExecutionFillPriceList.append(portfolio_data['Price'])
        
        portfolio_obj.m_strTimeWindowList     = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[0])
        portfolio_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[1])
        print "displaying portfolio timw window list"
        for iter in range(0, len(portfolio_obj.m_strTimeWindowList)):
            print str(portfolio_obj.m_strTimeWindowList[iter])  +"\t" + str(portfolio_obj.m_strTimeWindowPlotList[iter])
        print "end of display"

        return True
 def FormatDataPredicted(self, predicted_obj, predicted_data_list): 
     common_functions_obj = CCommonFunctions()
     temp_date = predicted_data_list[0]['DateTime'].date()
     temp_date = str(temp_date.day) + '-' + str(temp_date.month) + '-' + str(temp_date.year)
     
     for predicted_data in predicted_data_list:
         predicted_obj.m_nCountOfRows += 1
         predicted_obj.m_DatetimeList.append(predicted_data['DateTime'])
         predicted_obj.m_nSizeList.append(predicted_data['Size'])
     predicted_obj.m_strTimeWindowList     = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[0])
     predicted_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[1])
     return True
 def FormatDataFuture(self, future_obj, future_data_list):
     common_functions_obj = CCommonFunctions()
     temp_date = future_data_list[0]['DateTime'].date()
     temp_date = str(temp_date.day) + '-' + str(temp_date.month) + '-' + str(temp_date.year)
     future_obj.m_strScripName = future_data_list[0]['ScripName']
     
     for future_data in future_data_list:
         future_obj.m_nCountOfRows += 1
         future_obj.m_DatetimeList.append(future_data['DateTime'])
         future_obj.m_fPriceList.append(future_data['Price'])
     future_obj.m_strTimeWindowList     = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[0])
     future_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[1])
     return True
Beispiel #6
0
 def GetDataCash(self, cash_obj, path, date, scrip, windowInterval):
     common_functions_obj = CCommonFunctions()
     filename = path + '/' + common_functions_obj.FormatDate(
         date) + '/' + scrip + '_' + common_functions_obj.FormatDate(
             date) + '_trades.csv'
     with open(filename, 'rb') as cash_file_obj:
         cash_file_contents = csv.reader(cash_file_obj)
         cash_obj.m_strScripName = scrip
         for row in cash_file_contents:
             if row[0].strip() == scrip:
                 cash_obj.m_nCountOfRows += 1
                 cash_obj.m_DatetimeList.append(
                     common_functions_obj.GetDateTime(
                         row[2].strip(), row[3].strip()))
                 cash_obj.m_fPriceList.append(float(row[4].strip()))
         cash_obj.m_strTimeWindowList = common_functions_obj.GetDateTimeList(
             date,
             common_functions_obj.GetWindowList(windowInterval)[0])
         cash_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(
             date,
             common_functions_obj.GetWindowList(windowInterval)[1])
     return True
Beispiel #7
0
    def GetDataPredicted(self, predicted_obj, path, date, scrip,
                         windowInterval):
        common_functions_obj = CCommonFunctions()
        filename = path + '/' + common_functions_obj.FormatDate(
            date) + '/' + scrip.replace(':', '') + '.csv'
        with open(filename, 'rb') as predicted_file_obj:
            predicted_file_contents = csv.reader(predicted_file_obj)
            predicted_obj.m_strScripName = scrip

            for row in predicted_file_contents:
                predicted_obj.m_nCountOfRows += 1
                predicted_obj.m_DatetimeList.append(
                    common_functions_obj.GetDateTime(
                        date, common_functions_obj.FormatTime(row[0].strip())))
                predicted_obj.m_nSizeList.append(float(row[1].strip()))
            predicted_obj.m_strTimeWindowList = common_functions_obj.GetDateTimeList(
                date,
                common_functions_obj.GetWindowList(windowInterval)[0])
            predicted_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(
                date,
                common_functions_obj.GetWindowList(windowInterval)[1])
        return True
 def FormatDataMarket(self, market_obj, market_data_list):
     common_functions_obj = CCommonFunctions()
     market_obj.m_strScripName = market_data_list[0]['ScripName']
     temp_date = market_data_list[0]['DateTime'].date()
     temp_date = str(temp_date.day) + '-' + str(temp_date.month) + '-' + str(temp_date.year)
     for market_data in market_data_list:
         market_obj.m_nCountOfRows += 1
         market_obj.m_DatetimeList.append(market_data['DateTime'])
         market_obj.m_fPriceList.append(market_data['Price'])
         market_obj.m_nSizeList.append(market_data['Size'])
     market_obj.m_strTimeWindowList     = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[0])
     market_obj.m_strTimeWindowPlotList = common_functions_obj.GetDateTimeList(temp_date, common_functions_obj.GetWindowList(self.m_nWindowSize)[1])
     CCommonFunctions.total_daily_market_volume = sum(market_obj.m_nSizeList)
     return True