Exemplo n.º 1
0
    def get_first_n_nanos(df: dd, nanos: int):
        start_time = df.iloc[0]['time']
        end_time = DataUtils.date_to_unix(start_time, 'ns') + nanos

        converted = df['time'].apply(lambda x: DataUtils.date_to_unix(x, 'ns'))

        return df[converted < end_time]
Exemplo n.º 2
0
    def get_last_n_nanos(df: dd, nanos: int):
        end_time = df.iloc[0]['time']
        start_time = DataUtils.date_to_unix(end_time, 'ns') + nanos

        converted = df['time'].apply(lambda x: DataUtils.date_to_unix(x, 'ns'))

        return df[start_time > converted]
Exemplo n.º 3
0
    def __graph_price_time_set(df: dd, marker: str):
        y = df['price'].astype('float64').fillna(method='ffill')

        times = df['time'].astype('datetime64[ns]').apply(lambda x: DataUtils.date_to_unix(x, 'ns'))
        start_time = times.min()
        x = times.apply(lambda z: (z - start_time) / 1e9)

        self.config.plt.plot(x, y, marker)
Exemplo n.º 4
0
 def graph_interval(self, orders_df: dd):
     order_time_delta_df = orders_df['time'].apply(lambda x: DataUtils.date_to_unix(x, 'ns') / 1e6).diff()
     self.logger.debug(order_time_delta_df)
     cleaned_df = order_time_delta_df[order_time_delta_df != 0]
     self.graph_distribution(cleaned_df, self.data_description + ' inter-order arrival times',
                             'inter order time (ms)', bins=100)
Exemplo n.º 5
0
 def get_time_intervals(df):
     intervals = df['time'].apply(
         lambda x: DataUtils.date_to_unix(x, 'ns') / 1e6).diff()
     cleaned_intervals = intervals[intervals != 0].dropna()
     return cleaned_intervals