Guest User

Untitled

a guest
Dec 5th, 2019
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numerapi
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5.  
  6. napi = numerapi.NumerAPI()
  7.  
  8. df_lb = pd.io.json.json_normalize(napi.get_leaderboard(limit=300))
  9. rep_stack = np.zeros((len(df_lb.date.values),0))
  10. for uu in df_lb.username.values:
  11.     df = pd.io.json.json_normalize(napi.daily_user_performances(uu), sep="-")
  12.     if not len(df.reputation.values) == rep_stack.shape[0]:
  13.         print('Skipping',uu,'|',len(df.reputation.values),'-',rep_stack.shape[0])
  14.     else:
  15.         rep_stack = np.column_stack((rep_stack,df.reputation.values))
  16.  
  17. plt.plot(df.date.values,np.mean(rep_stack,axis=1),'-',label='top300')
  18. plt.xlim(pd.Timestamp.today()-pd.Timedelta(days=100),pd.Timestamp.today())
  19. plt.legend(loc='upper left')
  20. plt.gcf().autofmt_xdate()
  21. plt.show()
RAW Paste Data