From 69bd47be41ac35b6fd051a828fe0c6679d91dce1 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiol.ru> Date: Mon, 20 Feb 2017 18:37:44 +0100 Subject: [PATCH] Testing a money injector --- src/main/java/sesim/Exchange.java | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/sesim/Exchange.java b/src/main/java/sesim/Exchange.java index 40cfde6..81b99d4 100644 --- a/src/main/java/sesim/Exchange.java +++ b/src/main/java/sesim/Exchange.java @@ -3,6 +3,7 @@ package sesim; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.BiConsumer; import org.json.JSONArray; import org.json.JSONObject; @@ -86,14 +87,35 @@ public class Exchange { 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) { OHLCData data; //=new OHLCData(timeFrame); data = ohlc_data.get(timeFrame); if (data == null){ - // data = new OHLCData(timeFrame); + + this.tradelock.lock(); data = this.buildOHLCData(timeFrame); ohlc_data.put(timeFrame, data); + this.tradelock.unlock(); } return data; @@ -807,6 +829,9 @@ public class Exchange { //System.out.print("binweg\n"); return -1; } + + //System.out.printf("Creating Order width Volume %f %f \n",o.volume,o.limit); + tradelock.lock(); num_orders++;