diff --git a/README.md b/README.md index d99f961..6e902c2 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ Please use [pastebin](http://pastebin.com/) for uploading the logs. - This is a early release of the plugin so **don't expect it to be bug free!** - You WILL need to update the AssetsFix with Symbol names. For instance the EUR/USD name is CS.D.EURUSD.CFD.IP -- Prefer running your strategies with [Weekend = 7](http://www.zorro-trader.com/manual/en/weekend.htm) as the broker API tends to crash when IGs server goes offline for the weekend - The default allowance for IG historic prices is 10 000 quotes per week. If your allowance goes to zero, you won't even be able to download quotes for the lookback period. This means it is not a good idea to use IG as a source for downloading long periods of historic data. - Keep your historic data as up to date as possible and prefer using the [PRELOAD-flag](http://www.zorro-trader.com/manual/en/mode.htm) in you scripts. Even just filling the lookback will get rate limited if you have many assets and are too far behind on historic data. - The default quotas for IG Streaming API connections is 40 concurrent connections. The plugin currently uses 2 streams per asset, which means so can at a maximum trade 20 assets at the same time. Contact IG if you need to raise your limit. diff --git a/c++/src/DllCallHandler.cpp b/c++/src/DllCallHandler.cpp index 83190f8..3e618b9 100644 --- a/c++/src/DllCallHandler.cpp +++ b/c++/src/DllCallHandler.cpp @@ -199,11 +199,13 @@ DllCallHandler::BrokerAccount(const char *Account, double *pTradeVal, double *pMarginVal) { + /* Account parameter not used for now, just ignore it rather than return an error if (Account) { BrokerError("Multiple accounts are not yet supported!"); return 0; } + */ jdoubleArray jAccountParamsArray = env->NewDoubleArray(3); jint res = (jlong)env->CallObjectMethod(JData::JIgZorroBridgeObject, diff --git a/src/main/java/com/danlind/igz/ZorroBridge.java b/src/main/java/com/danlind/igz/ZorroBridge.java index a5efe06..939e0f3 100644 --- a/src/main/java/com/danlind/igz/ZorroBridge.java +++ b/src/main/java/com/danlind/igz/ZorroBridge.java @@ -43,6 +43,7 @@ private void initComponents() { accountHandler.startAccountSubscription(); tradeHandler = context.getBean(TradeHandler.class); tradeHandler.checkTradesValid(); + historyHandler.startTimeZoneOffsetSubscription(); if (!isFirstLogin) { logger.debug("Zorro requested new login, resubscribing to all assets"); @@ -71,6 +72,7 @@ public int doLogin(final String User, public int doLogout() { logger.debug("Broker Logout called"); + historyHandler.cancelSubscription(); return loginHandler.disconnect(); } diff --git a/src/main/java/com/danlind/igz/brokerapi/BrokerAsset.java b/src/main/java/com/danlind/igz/brokerapi/BrokerAsset.java index 6d4f8ca..c5e698c 100644 --- a/src/main/java/com/danlind/igz/brokerapi/BrokerAsset.java +++ b/src/main/java/com/danlind/igz/brokerapi/BrokerAsset.java @@ -48,7 +48,7 @@ public BrokerAsset(MarketDataProvider marketDataProvider, VolumeProvider volumeP */ public void reconnectAll() { marketDataProvider.getAllSubscribedEpics().stream().forEach(epic -> { - LOG.debug("Subscribing for epic {}", epic.getName()); + LOG.debug("Re-subscribing for epic {}", epic.getName()); subscribeToLighstreamerTickUpdates(epic); }); } @@ -67,7 +67,6 @@ public int subscribeToLighstreamerTickUpdates(Epic epic) { //TODO: How to handle close of stream on weekends? (Weekend = 7 is the obvious option for now) LOG.info("Received complete signal from TickObservable for epic {}", epic.getName()); marketDataProvider.cancelSubscription(epic); - historyHandler.cancelSubscription(); } ); @@ -82,8 +81,6 @@ public int subscribeToLighstreamerTickUpdates(Epic epic) { () -> LOG.info("Received complete signal from VolumeObservable for epic {}", epic.getName()) ); - historyHandler.getTimeZoneOffsetObservable(); - //Init volume from historic data List pricesItems = historyHandler.getPriceHistory(epic, VOLUME_WINDOW_LENGTH); pricesItems.stream().forEach(pricesItem -> volumeProvider.updateRollingVolume(epic, new Volume(pricesItem.getLastTradedVolume().intValue()))); diff --git a/src/main/java/com/danlind/igz/brokerapi/BrokerHistory.java b/src/main/java/com/danlind/igz/brokerapi/BrokerHistory.java index 2b14fd2..5c02b45 100644 --- a/src/main/java/com/danlind/igz/brokerapi/BrokerHistory.java +++ b/src/main/java/com/danlind/igz/brokerapi/BrokerHistory.java @@ -53,7 +53,7 @@ public int getPriceHistory(final Epic epic, } } - public void getTimeZoneOffsetObservable() { + public void startTimeZoneOffsetSubscription() { if (Objects.nonNull(timeZoneOffsetSubscription)) { logger.debug("Disposing of existing time offset subscription"); timeZoneOffsetSubscription.dispose(); @@ -67,7 +67,8 @@ public void getTimeZoneOffsetObservable() { ); } - public void cancelTimeOffsetSubscription() { + public void cancelTimeZoneOffsetSubscription() { + logger.debug("Canceling time offset subscription"); timeZoneOffsetSubscription.dispose(); } diff --git a/src/main/java/com/danlind/igz/handler/HistoryHandler.java b/src/main/java/com/danlind/igz/handler/HistoryHandler.java index c22d505..8f9de47 100644 --- a/src/main/java/com/danlind/igz/handler/HistoryHandler.java +++ b/src/main/java/com/danlind/igz/handler/HistoryHandler.java @@ -34,11 +34,11 @@ public List getPriceHistory(final Epic epic, return brokerHistory.getPriceHistory(epic, ticks); } - public void getTimeZoneOffsetObservable() { - brokerHistory.getTimeZoneOffsetObservable(); + public void startTimeZoneOffsetSubscription() { + brokerHistory.startTimeZoneOffsetSubscription(); } public void cancelSubscription() { - brokerHistory.cancelTimeOffsetSubscription(); + brokerHistory.cancelTimeZoneOffsetSubscription(); } }