// THIS BLOCK CONTAINS JAVA CODE. private long removeRefMarketData(long lIndex) { // // loop through the elements in the actual container, in order to find the one // at lIndex. Once it is found, then loop through the reference list and remove // the corresponding reference for that element. // MarketData refActualElement = GetMarketData(lIndex); if (refActualElement == null) return lIndex; // oh well. // Loop through the reference list and remove the corresponding reference // for the specified element. // for (int intIndex = 0; intIndex < elementList.size(); intIndex++) { Object theObject = elementList.get(intIndex); if ((theObject == null) || !(theObject instanceof MarketData)) continue; MarketData tempRef = (MarketData) (theObject); if ((MarketData.getCPtr(tempRef) == MarketData.getCPtr(refActualElement))) { elementList.remove(tempRef); break; } } return lIndex; }
public static String parseInterval(String eventId) { if (MarketData.parseEventId(eventId).length == 4) { return MarketData.parseEventId(eventId)[3]; } return null; }
@Test public void test1() throws Exception { File historyFile = new File("src/main/java/history/EURUSDD1"); MarketDataFromFile mdff = new MarketDataFromFile("EURUSD", 1440, historyFile); MarketData data1 = new MarketData("EURUSD", "2015-02-26 06:00:00", 1.1100, 1.1110, 1.1150, 1.1000, 1000); mdff.Update(data1); ArrayList<MarketData> series = mdff.getMarketData(); MarketData currData = series.get(series.size() - 1); MarketData prevData = series.get(series.size() - 2); assertEquals(currData.getHigh(), 1.13895, 0.000001); assertEquals(currData.getLow(), 1.13364, 0.000001); assertEquals(currData.getOpen(), 1.13422, 0.000001); assertEquals(currData.getClose(), 1.13619, 0.000001); assertEquals(prevData.getHigh(), 1.13589, 0.000001); assertEquals(prevData.getLow(), 1.12890, 0.000001); assertEquals(prevData.getOpen(), 1.13353, 0.000001); assertEquals(prevData.getClose(), 1.13422, 0.000001); }
private long getCPtrAddRefMarketData(MarketData element) { // Whenever adding a reference to the list, I remove it first (if already there.) // That way we never store more than one reference per actual contained object. // for (int intIndex = 0; intIndex < elementList.size(); intIndex++) { Object theObject = elementList.get(intIndex); if ((theObject == null) || !(theObject instanceof MarketData)) continue; MarketData tempRef = (MarketData) (theObject); if ((MarketData.getCPtr(tempRef) == MarketData.getCPtr(element))) { elementList.remove( tempRef); // It was already there, so let's remove it before adding (below.) break; } } // Now we add it... // MarketData tempLocalRef = element; elementList.add(tempLocalRef); return MarketData.getCPtr(element); } // Hope I get away with overloading this for every type. Otherwise,
public boolean AddMarketData(MarketData disownObject) { return otapiJNI.MarketList_AddMarketData( swigCPtr, this, MarketData.getCPtr(disownObject), disownObject); }