Added some comments

This commit is contained in:
7u83 2017-02-03 18:46:39 +01:00
parent 2800dd7145
commit 4a01d8f1f6

View File

@ -7,18 +7,29 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* * @desc Echchange class
* @author tube * @author 7u83
*/ */
public class Exchange { //extends Thread { public class Exchange {
private double money_df = 10000; private double money_df = 10000;
private double shares_df = 1;
/**
* Set the number of decimals used with money
*
* @param n number of decimals
*/
public void setMoneyDecimals(int n) { public void setMoneyDecimals(int n) {
money_df = Math.pow(10, n); money_df = Math.pow(10, n);
} }
private double shares_df = 1;
/**
* Set the number of decimals for shares
*
* @param n number of decimals
*/
public void setSharesDecimals(int n) { public void setSharesDecimals(int n) {
shares_df = Math.pow(10, n); shares_df = Math.pow(10, n);
} }
@ -35,6 +46,9 @@ public class Exchange { //extends Thread {
return roundToDecimals(money, money_df); return roundToDecimals(money, money_df);
} }
/**
* Definition of order types
*/
public enum OrderType { public enum OrderType {
BID, ASK BID, ASK
} }
@ -43,7 +57,10 @@ public class Exchange { //extends Thread {
//public static Timer timer = new Timer(); //public static Timer timer = new Timer();
public Scheduler timer = new Scheduler(); public Scheduler timer = new Scheduler();
//public AutoTraderList traders = new AutoTraderList();
public ArrayList<AutoTrader> traders = new ArrayList(); public ArrayList<AutoTrader> traders = new ArrayList();
/** /**
@ -198,6 +215,10 @@ public class Exchange { //extends Thread {
return initial_volume; return initial_volume;
} }
public Account getAccount(){
return account;
}
} }
/** /**
@ -221,25 +242,26 @@ public class Exchange { //extends Thread {
} }
public class Statistics {
public class Statistics{
public long trades; public long trades;
public long orders; public long orders;
} };
Statistics statistics;
long num_trades = 0; long num_trades = 0;
long num_orders=0; long num_orders = 0;
public Statistics getStatistics(){ public Statistics getStatistics() {
Statistics s = new Statistics(); Statistics s = new Statistics();
s.trades=num_trades; s.trades = num_trades;
s.orders=num_orders; s.orders = num_orders;
return s; return s;
} }
void start() { void start() {
timer.start(); timer.start();
} }
@ -254,7 +276,6 @@ public class Exchange { //extends Thread {
} }
} }
public SortedSet<Quote> getQuoteHistory(long start) { public SortedSet<Quote> getQuoteHistory(long start) {
Quote s = new Quote(); Quote s = new Quote();
@ -442,7 +463,7 @@ public class Exchange { //extends Thread {
} }
public int randNextInt(int bounds) { public int randNextInt(int bounds) {
System.out.printf("Next doub: %f\n",random.nextDouble()); System.out.printf("Next doub: %f\n", random.nextDouble());
return random.nextInt(bounds); return random.nextInt(bounds);
} }