Added a method for default exchange

This commit is contained in:
7u83 2018-12-21 10:45:29 +01:00
parent 01a5551e69
commit d127b99372
3 changed files with 23 additions and 3 deletions

View File

@ -211,12 +211,27 @@ public class GodWorld implements GetJson, World {
return a; return a;
} }
HashMap<String, Exchange> exchanges = new HashMap<>(); // --------------------------------------------------------------------
// Exchanges in our world
// --------------------------------------------------------------------
private final HashMap<String, Exchange> exchanges = new HashMap<>();
private Exchange default_exchange = null;
public void createExchange(JSONObject cfg) { public void createExchange(JSONObject cfg) {
Exchange ex = new Exchange(this.getWorld(), cfg); Exchange ex = new Exchange(this.getWorld(), cfg);
exchanges.put(ex.getSymbol(), ex); exchanges.put(ex.getSymbol(), ex);
if (default_exchange == null) {
default_exchange = ex;
}
} }
public Exchange getDefaultExchange(){
return default_exchange;
}
@Override @Override
public Collection<Exchange> getExchangeCollection() { public Collection<Exchange> getExchangeCollection() {
@ -366,8 +381,6 @@ public class GodWorld implements GetJson, World {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Stuff belonging to accounts // Stuff belonging to accounts
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Pseudo random generator stuff // Pseudo random generator stuff
// -------------------------------------------------------------------- // --------------------------------------------------------------------

View File

@ -75,4 +75,9 @@ public class RealWorld implements World {
return godworld.currentTimeMillis(); return godworld.currentTimeMillis();
} }
@Override
public Exchange getDefaultExchange() {
return godworld.getDefaultExchange();
}
} }

View File

@ -40,6 +40,8 @@ public interface World {
public AbstractAsset getAssetBySymbol(String symbol); public AbstractAsset getAssetBySymbol(String symbol);
Collection<Exchange> getExchangeCollection(); Collection<Exchange> getExchangeCollection();
public Exchange getDefaultExchange();
Collection<Trader> getTradersCollection(); Collection<Trader> getTradersCollection();