From 6194018dbb4c8a7a555fe8caf7aab6d3d92af1e3 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiil.ru> Date: Fri, 21 Dec 2018 23:48:03 +0100 Subject: [PATCH] asset_pairs = HashMap for TradingAPI --- src/opensesim/world/Exchange.java | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/opensesim/world/Exchange.java b/src/opensesim/world/Exchange.java index 10f6f71..302bbb9 100644 --- a/src/opensesim/world/Exchange.java +++ b/src/opensesim/world/Exchange.java @@ -50,8 +50,7 @@ public class Exchange implements Configurable, GetJson { this.name = name; } - //private final HashMap asset_pairs; - private final HashMap asset_pairs = new HashMap<>(); + private final HashMap asset_pairs = new HashMap<>(); Exchange(World world, String symbol) { @@ -88,12 +87,6 @@ public class Exchange implements Configurable, GetJson { return null; } - public Collection getOrderBook(AssetPair a) { - TradingEnv e = asset_pairs.get(a); - SortedSet ob = e.order_books.get(Order.Type.BUYLIMIT); - return Collections.unmodifiableCollection(ob); - } - @Override public JSONObject getConfig() { JSONObject cfg = new JSONObject(); @@ -116,7 +109,7 @@ public class Exchange implements Configurable, GetJson { return cfg; } - class TradingEnv implements TradingAPI{ + class TradingEnv implements TradingAPI { protected HashMap> order_books; @@ -142,19 +135,17 @@ public class Exchange implements Configurable, GetJson { return null; } - - } - - private TradingAPI add(AssetPair p){ + + private TradingAPI add(AssetPair p) { TradingEnv e = new TradingEnv(); asset_pairs.put(p, e); return e; } - public TradingAPI getAPI(AssetPair pair){ + public TradingAPI getAPI(AssetPair pair) { TradingAPI a = asset_pairs.get(pair); - if (a==null){ + if (a == null) { return add(pair); } return a;