(column)
| 167 | return ((df['Size'].abs() * df['ReturnPct']) / df['Size'].abs().sum()).sum() |
| 168 | |
| 169 | def _group_trades(column): |
| 170 | def f(s, new_index=pd.Index(df.index.astype(np.int64)), bars=trades[column]): |
| 171 | if s.size: |
| 172 | # Via int64 because on pandas recently broken datetime |
| 173 | mean_time = int(bars.loc[s.index].astype(np.int64).mean()) |
| 174 | new_bar_idx = new_index.get_indexer([mean_time], method='nearest')[0] |
| 175 | return new_bar_idx |
| 176 | return f |
| 177 | |
| 178 | if len(trades): # Avoid pandas "resampling on Int64 index" error |
| 179 | trades = trades.assign(count=1).resample(freq, on='ExitTime', label='right').agg(dict( |
no outgoing calls
no test coverage detected