Testing a money injector

This commit is contained in:
7u83 2017-02-20 18:37:44 +01:00
parent 97ef96ace1
commit 69bd47be41

View File

@ -3,6 +3,7 @@ package sesim;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.BiConsumer;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -87,13 +88,34 @@ public class Exchange {
return data; return data;
} }
public void injectMoney(){
accounts.forEach(new BiConsumer(){
@Override
public void accept(Object t, Object u) {
Account a = (Account)u;
a.money+=2000.0;
}
});
}
public OHLCData getOHLCdata(Integer timeFrame) { public OHLCData getOHLCdata(Integer timeFrame) {
OHLCData data; //=new OHLCData(timeFrame); OHLCData data; //=new OHLCData(timeFrame);
data = ohlc_data.get(timeFrame); data = ohlc_data.get(timeFrame);
if (data == null){ if (data == null){
// data = new OHLCData(timeFrame);
this.tradelock.lock();
data = this.buildOHLCData(timeFrame); data = this.buildOHLCData(timeFrame);
ohlc_data.put(timeFrame, data); ohlc_data.put(timeFrame, data);
this.tradelock.unlock();
} }
return data; return data;
@ -807,6 +829,9 @@ public class Exchange {
//System.out.print("binweg\n"); //System.out.print("binweg\n");
return -1; return -1;
} }
//System.out.printf("Creating Order width Volume %f %f \n",o.volume,o.limit);
tradelock.lock(); tradelock.lock();
num_orders++; num_orders++;