Source reformatted

This commit is contained in:
7u83 2016-12-26 10:11:40 +01:00
parent 354f739f83
commit 5515dddb30

View File

@ -3,6 +3,7 @@ package SeSim;
import java.util.Random; import java.util.Random;
public class MTrader implements Trader { public class MTrader implements Trader {
Exchange ex; Exchange ex;
Random rand; Random rand;
@ -13,15 +14,16 @@ public class MTrader implements Trader {
rand = new Random(); rand = new Random();
} }
public void DoBuy() public void DoBuy() {
{
// System.out.println("AAA"); // System.out.println("AAA");
if (account.orderpending) if (account.orderpending) {
return; return;
}
if (account.money <= 0) if (account.money <= 0) {
return; return;
}
double perc = rand.nextDouble() * 1.0; double perc = rand.nextDouble() * 1.0;
double lp = ex.lastprice; double lp = ex.lastprice;
@ -30,20 +32,20 @@ public class MTrader implements Trader {
// System.out.println("HW"); // System.out.println("HW");
long size = (int) (account.money / limit); long size = (int) (account.money / limit);
account.Buy(size, limit, ex); account.Buy(size, limit, ex);
return; return;
} }
public void DoSell() public void DoSell() {
{
// System.out.println("SoSell"); // System.out.println("SoSell");
if (account.orderpending) if (account.orderpending) {
return; return;
}
if (account.shares<=0) if (account.shares <= 0) {
return; return;
}
double perc = rand.nextDouble() * 1.0; double perc = rand.nextDouble() * 1.0;
double lp = ex.lastprice; double lp = ex.lastprice;
@ -51,38 +53,31 @@ public class MTrader implements Trader {
long size = (int) (account.shares); long size = (int) (account.shares);
account.Sell(size, limit, ex); account.Sell(size, limit, ex);
return; return;
} }
public void trade() { public void trade() {
// What to do? // What to do?
int action = rand.nextInt(3); int action = rand.nextInt(3);
// System.out.print("Action"); // System.out.print("Action");
// System.out.println(action); // System.out.println(action);
if (action==0) if (action == 0) {
return; return;
}
if (action == 1) if (action == 1) {
{
DoBuy(); DoBuy();
return; return;
} }
if (action == 2) if (action == 2) {
{
DoSell(); DoSell();
return; return;
} }
//System.out.printf("MyPrice: %.2f\n",price); //System.out.printf("MyPrice: %.2f\n",price);
} }
} }