Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //PRIMERO SE TRAE DE LA BD LOS PRECIOS FIJOS (SI QUERES TE MUESTRO COMO LOS CALCULA)
  2.  
  3. one_month_price_ib = {{ one_month_price_ib }}
  4. three_months_price_ib = {{ three_months_price_ib }}
  5. six_months_price_ib = {{ six_months_price_ib }}
  6.  
  7. ytd_price_ib = {{ ytd_price_ib }};
  8. one_years_price_ib = {{ one_years_price_ib }};
  9. three_years_price_ib = {{ three_years_price_ib }};
  10. five_years_price_ib = {{ five_years_price_ib }};
  11. eight_years_price_ib = {{ eight_years_price_ib }};
  12.  
  13. all_price_ib = 1000;
  14.  
  15. one_month_price_spy = {{ one_month_price_spy }}
  16. three_months_price_spy = {{ three_months_price_spy }}
  17. six_months_price_spy = {{ six_months_price_spy }}
  18.  
  19. ytd_price_spy = {{ ytd_price_spy }};
  20. one_years_price_spy = {{ one_years_price_spy }};
  21. three_years_price_spy = {{ three_years_price_spy }};
  22. five_years_price_spy = {{ five_years_price_spy }};
  23. eight_years_price_spy = {{ eight_years_price_spy }};
  24.  
  25. //DESPUES SE TRAE EL BILLION Y SYP POR EL API
  26.  
  27.  $.get('/realtimewithpath/?tickers=^BILLION,^GSPC&callback=?', function(data){
  28.  
  29. //Y POR ULTIMO HACE LOS CALCULOS
  30.  
  31. price_spy = data[1].price; //ESE DATA ES EL DATA QUE AGARRA DEL GET ARRIBA EN EL 1 VIENE EL S&P EN EL 0 VIENE EL BILON COMO HACE ABAJO
  32.   //price_spy = parseFloat(price_spy.replace(',', ''));
  33.   ytd_perf_spy =  ( ( price_spy / ytd_price_spy ) -1 ) * 100;
  34.  
  35.   one_month_perf_spy =  ( ( price_spy / one_month_price_spy ) -1 ) * 100;
  36.   three_months_perf_spy =  ( ( price_spy / three_months_price_spy ) -1 ) * 100;
  37.   six_months_perf_spy =  ( ( price_spy / six_months_price_spy ) -1 ) * 100;
  38.  
  39.   one_years_perf_spy =  ( ( price_spy / one_years_price_spy ) -1 ) * 100;
  40.   three_years_perf_spy =  ( Math.pow( ( price_spy / three_years_price_spy ) , (1/3) ) -1 ) * 100;
  41.   five_years_perf_spy =  ( Math.pow( ( price_spy / five_years_price_spy ) , (1/5) ) -1 ) * 100;
  42.   eight_years_perf_spy =  ( Math.pow( ( price_spy / eight_years_price_spy ) , (1/8) ) -1 ) * 100;
  43.  
  44.   all_perf_spy =  ( ( price_spy / all_price_spy ) -1 ) * 100;
  45.  
  46.   //IB
  47.   price = data[0].price;
  48.   //price = parseFloat(price.replace(',', ''));
  49.   ytd_perf_ib =  ( ( price / ytd_price_ib ) -1 ) * 100;
  50.  
  51.   one_month_perf_ib =  ( ( price / one_month_price_ib ) -1 ) * 100;
  52.   three_months_perf_ib =  ( ( price / three_months_price_ib ) -1 ) * 100;
  53.   six_months_perf_ib =  ( ( price / six_months_price_ib ) -1 ) * 100;
  54.  
  55.   one_years_perf_ib =  ( ( price / one_years_price_ib ) -1 ) * 100;
  56.   three_years_perf_ib =  ( Math.pow( ( price / three_years_price_ib ) , (1/3) ) -1 ) * 100;
  57.   five_years_perf_ib =  ( Math.pow( ( price / five_years_price_ib ) , (1/5) )  -1 ) * 100;
  58.   eight_years_perf_ib =  ( Math.pow( ( price / eight_years_price_ib ) , (1/8) ) -1 ) * 100;
  59.  
  60.   all_perf_ib =  ( ( price / all_price_ib ) -1 ) * 100;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement