This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fraud_rate(df, agg, cols=None, threshold=None, limit=None, days=None): | |
| if isinstance(cols, str): | |
| groupcols = [cols] | |
| elif cols is None: | |
| groupcols = [] | |
| else: | |
| try: | |
| groupcols = list(cols) | |
| except: | |
| raise TypeError('Unable to convert cols to a list.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def multiple_defect(nds, agg, cols, n, minrate=0.05): | |
| import itertools | |
| combos = list(itertools.combinations(cols, n)) | |
| num_cols = ['col' + str(i) for i in range(1, n + 1)] | |
| res = [] | |
| for combo in combos: | |
| fr = fraud_rate(nds, agg, combo) | |
| fr = fr.reset_index() | |
| fr.columns = num_cols + ['fraud', 'nonfraud', 'fraudrate','fpr'] | |
| fr = fr.assign(groupcols = ', '.join(combo)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #random pivot df for a plot | |
| create_date_df = df[['Microsoft Account Created Date', 'fraud']] | |
| create_date_df = pd.pivot_table(create_date_df | |
| , index=['Microsoft Account Created Date'] | |
| , columns = 'fraud' | |
| , aggfunc=len | |
| ).reset_index() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dirpath = '/Users/max.bade/Downloads/pancakeswap/' | |
| output = '/Users/max.bade/Downloads/pancakeswap/output/pancakeswap.csv' | |
| csvout_lst = [] | |
| files = [os.path.join(dirpath, fname) for fname in os.listdir(dirpath)] | |
| # for filename in sorted(files): | |
| for filename in cakes: | |
| def cross_join(left, right): | |
| new_rows = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cake_4_1 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_1.txt')) | |
| cake_4_2 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_2.txt')) | |
| cake_4_3 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_3.txt')) | |
| cake_4_4 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_4.txt')) | |
| cake_4_5 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_5.txt')) | |
| cake_4_6 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_6.txt')) | |
| cake_4_7 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_7.txt')) | |
| cake_4_8 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_8.txt')) | |
| cake_4_9 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_9.txt')) | |
| cake_4_10 = json.load(open('/Users/max.bade/Downloads/pancakeswap/4_10.txt')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = pd.read_csv(output,) | |
| df.columns = ['index_duplicate','buy_symbol','sell_symbol','#_trades','trade_amount_$'] | |
| del df['index_duplicate'] | |
| df['num_trades_x_tradeamount'] = df['#_trades'] * df['trade_amount_$'] | |
| # df = df.sort_values(by='num_trades_x_tradeamount',ascending=False).reset_index() | |
| # del df['index'] | |
| start = pd.to_datetime("4/1/2021") | |
| df['trade_date'] = pd.Series(np.arange(len(df)) // 1000) \ | |
| .apply(lambda x: pd.Timedelta(days=x)) + start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filtered_coins = df.groupby(['Week_Number','pair'])['pct_ch'].agg('sum').reset_index() | |
| filtered_coins.columns = ['Week_Number','pair','total_weekly_pct_ch'] | |
| filtered_coins = filtered_coins[filtered_coins['Week_Number'] == 18][['Week_Number','pair','total_weekly_pct_ch']].sort_values(by='total_weekly_pct_ch',ascending=False).reset_index() | |
| filtered_coins = filtered_coins[filtered_coins['total_weekly_pct_ch']>=50] | |
| print(filtered_coins.shape) | |
| print(filtered_coins.pair.nunique()) | |
| filtered_coins.head(10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fig = px.bar(filtered_coins | |
| ,x='pair' | |
| ,y='total_weekly_pct_ch' | |
| ,color='pair' | |
| # ,size='total_weekly_pct_ch' | |
| # ,facet_row='pair' | |
| # ,facet_row_spacing=.005 | |
| # ,facet_col='Week_Number' | |
| # ,facet_col_wrap=2 | |
| # ,log_y=True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fig = px.line(df2 | |
| ,x='trade_date' | |
| ,y='pct_ch' | |
| ,color='pair' | |
| ,facet_row='pair' | |
| ,facet_row_spacing=.005 | |
| # ,facet_col='Week_Number' | |
| # ,facet_col_wrap=2 | |
| # ,log_y=True | |
| ,range_y=[0, 8000] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| coins_to_remove = ['BUSD','WBNB','ETH','USDT','USDC','BTC','Cake'] | |
| df = df[~df.buy_symbol.isin(coins_to_remove)] | |
| print(df.shape) | |
| print('unique pairs: ',df.pair.nunique()) | |
| df.head(20) | |
| df2 = df | |
| df2 = df2[df2['sum_pct_change'] >= 500] | |
| print(df2.pair.nunique()) | |
| df2.head() |
OlderNewer