From 5515dddb30a482a6b60ad98922c934fffcf40ffb Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiol.ru> Date: Mon, 26 Dec 2016 10:11:40 +0100 Subject: [PATCH] Source reformatted --- src/SeSim/MTrader.java | 147 ++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 76 deletions(-) diff --git a/src/SeSim/MTrader.java b/src/SeSim/MTrader.java index e9e4a9e..083a30f 100644 --- a/src/SeSim/MTrader.java +++ b/src/SeSim/MTrader.java @@ -3,86 +3,81 @@ package SeSim; import java.util.Random; public class MTrader implements Trader { - Exchange ex; - Random rand; - - public MTrader (Exchange ex1, long shares, double money){ - account.money=money; - account.shares=shares; - this.ex=ex; - rand = new Random(); - } - public void DoBuy() - { - // System.out.println("AAA"); - - if (account.orderpending) - return; - - if (account.money <= 0) - return; - - double perc = rand.nextDouble() * 1.0; - double lp = ex.lastprice; - double limit = lp/100 * perc + lp; - + Exchange ex; + Random rand; + + public MTrader(Exchange ex1, long shares, double money) { + account.money = money; + account.shares = shares; + this.ex = ex; + rand = new Random(); + } + + public void DoBuy() { + // System.out.println("AAA"); + + if (account.orderpending) { + return; + } + + if (account.money <= 0) { + return; + } + + double perc = rand.nextDouble() * 1.0; + double lp = ex.lastprice; + double limit = lp / 100 * perc + lp; + // System.out.println("HW"); - long size = (int)(account.money/limit); - - - account.Buy(size, limit, ex); - return; - } + long size = (int) (account.money / limit); - public void DoSell() - { + account.Buy(size, limit, ex); + return; + } + + public void DoSell() { // System.out.println("SoSell"); - - if (account.orderpending) - return; - - if (account.shares<=0) - return; - - double perc = rand.nextDouble() * 1.0; - double lp = ex.lastprice; - double limit = lp - lp/100 * perc; - - long size = (int)(account.shares); - - - account.Sell(size, limit, ex); - return; - } - - - public void trade(){ - - - // What to do? - int action = rand.nextInt(3); - // System.out.print("Action"); - // System.out.println(action); - if (action==0) - return; - - if (action == 1) - { - DoBuy(); - return; - } + if (account.orderpending) { + return; + } + + if (account.shares <= 0) { + return; + } + + double perc = rand.nextDouble() * 1.0; + double lp = ex.lastprice; + double limit = lp - lp / 100 * perc; + + long size = (int) (account.shares); + + account.Sell(size, limit, ex); + return; + } + + public void trade() { + + // What to do? + int action = rand.nextInt(3); + // System.out.print("Action"); + // System.out.println(action); + if (action == 0) { + return; + } + + if (action == 1) { + DoBuy(); + return; + } + + if (action == 2) { + DoSell(); + return; + } + + //System.out.printf("MyPrice: %.2f\n",price); + } - if (action == 2) - { - DoSell(); - return; - } - - - //System.out.printf("MyPrice: %.2f\n",price); - - } - }