Nocx

calc

Nov 2nd, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. package fr.src.trade;
  2.  
  3. public class Main {
  4.      
  5.     public static void main(String[]args)
  6.     {
  7.         new Main();
  8.     }
  9.  
  10.     public Main()
  11.     {
  12.         Algorithm(0.007, 262*3);// pourcentage / jours
  13.     }
  14.     /*
  15.      * 0.011 et 730 jours pour les cryptos, c'est cool
  16.      * FX :
  17.      * 22 pips pour 0.007 et base de 500
  18.      * 30 pips pour 0.01 et base de 500
  19.      * 3 pips pour 0.01 et base de 50 (test)
  20.      * 15 pips 0.02 et base de 50
  21.      */
  22.    
  23.     public void Algorithm(double percentage_per_day, int period)
  24.     {
  25.         double base = 250.0;
  26.         double inv = base;
  27.         int days = period;
  28.         double percentage = percentage_per_day;
  29.         double benefs = 0.0;
  30.         boolean isforex = true;
  31.         long order_forex_basis = 10000;
  32.         double per_million = 4.0;
  33.         boolean hasfees = false;
  34.         double defined_fees = 0.003;
  35.         double fee;
  36.         double objective = 0.0; // 0.0 = no objective
  37.         if(hasfees)
  38.         {
  39.             fee = defined_fees;
  40.         }else {
  41.             fee = 0;
  42.         }
  43.        
  44.        
  45.         while(days>1)
  46.         {
  47.             if(isforex)
  48.             {
  49.                 System.out.println("Size forex position for today : "+order_forex_basis);
  50.                 order_forex_basis += rounder(order_forex_basis*percentage, 1);
  51.             }
  52.                 System.out.println("Todo today : "+rounder(((inv+benefs)*percentage), 100.0)+" € (fees of "+rounder((((inv+benefs))*fee), 100.0)+" € included | FX : "+(per_million*order_forex_basis/100000.0)+"");
  53.                 benefs += !isforex ? ((inv+benefs)*percentage) - (((inv+benefs))*fee) : ((inv+benefs)*percentage) - (per_million*order_forex_basis/100000.0);
  54.            
  55.             System.out.println("Day : "+(period-days)+" | total since day 0 : "+rounder(benefs, 100.0)+" € \n-- -- -- -- -- -- -- --");
  56.             days--;
  57.             if((period-days)%30==0)
  58.             {
  59.                 inv+=100;
  60.                 System.out.println("-------------------- \n 100.0 eur added to inv \n --------------------");
  61.             }
  62.             if(benefs >= objective && objective > 0.0)
  63.             {
  64.                 period-=days;
  65.                 break;
  66.             }
  67.         }
  68.         System.out.println("Total in "+period+" days (~"+(period/30)+" months), with an investment of "+base+" € and objective of "+rounder(percentage*100, 100)+" % per day \n"+
  69.         "> "+rounder(benefs, 100.0)+" €");
  70.     }
  71.    
  72.     public double rounder(double entry, double rounding)
  73.     {
  74.         return Double.valueOf(Math.round(entry*rounding)/rounding);
  75.     }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment