Work on first trades

This commit is contained in:
7u83 2018-12-23 13:12:36 +01:00
parent 9009b8fd54
commit e2c15eff1c
2 changed files with 8 additions and 9 deletions

View File

@ -607,26 +607,26 @@ public class SeSimApplication extends javax.swing.JFrame {
void startSim() { void startSim() {
godworld.addAssetPair("AAPL", "EUR");
JSONObject cfg = new JSONObject("{" JSONObject cfg = new JSONObject("{"
+ "strategy: opensesim.trader.SimpleTrader" + "strategy: opensesim.trader.SimpleTrader"
+ "}"); + "}");
Trader t = godworld.createTrader(cfg); Trader t = godworld.createTrader(cfg);
t.start(); t.start();
TradingAPI api;
AbstractAsset c,a; AssetPair p = godworld.getDefaultAssetPair();
c=godworld.getAssetBySymbol("EUR");
a=godworld.getAssetBySymbol("AAPL");
AssetPair p = new AssetPair(c,a);
opensesim.world.Exchange ex = godworld.getDefaultExchange(); opensesim.world.Exchange ex = godworld.getDefaultExchange();
api = ex.getAPI(p); TradingAPI api = ex.getAPI(p);
Set<Order> ob; Set<Order> ob;
ob = api.getOrderBook(Order.Type.BUY); ob = api.getOrderBook(Order.Type.BUY);
for (Order o: ob){ for (Order o: ob){
double v = o.getVolume();
System.out.printf("Volume: %d\n",o.getVolume()); System.out.printf("Volume: %d\n",o.getVolume());
} }

View File

@ -98,9 +98,8 @@ public class SimpleTrader extends AbstractTrader implements EventListener {
return; return;
} }
AbstractAsset c,a; AbstractAsset c,a;
c=getWorld().getAssetBySymbol("EUR");
a=getWorld().getAssetBySymbol("AAPL"); AssetPair p = getWorld().getDefaultAssetPair();
AssetPair p = new AssetPair(c,a);
ex = getWorld().getDefaultExchange(); ex = getWorld().getDefaultExchange();
api = ex.getAPI(p); api = ex.getAPI(p);