Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

JForex on .Net
 Post subject: JForex on .Net Post rating: 0   New post Posted: Fri 15 Oct, 2010, 14:51 

User rating: -
Hi,
Is there a possibility to connect to the API from the .Net platform?

Best
L


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Mon 18 Oct, 2010, 09:04 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
It's always possible to make a bridge by implementing a server/client. The server on the JForex (within strategy) side and client on the other side. Then the server can pass data and execute orders on demand of the client.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Mon 18 Oct, 2010, 11:12 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
On the Java (JForex) side of things a very simple example of a server that will pass tick data could be like (see below).

I currently do not code in .net so I don't know how exactly the client would look like in a .net lang, but on the inet there surely is an example of a client application, if you do a search.
The example does work and it passes tick data (as string) in the format <instrument>";"<bid>";"<ask>, on port 4444.
How it basically works in Java you could look up here: https://download.oracle.com/javase/tutor ... erver.html

package jforex;

import java.util.*;

import com.dukascopy.api.*;

import java.net.*;
import java.io.*;

public class Bridge implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;
   private IUserInterface userInterface;
    private ServerSocket serverSocket;
    private Socket clientSocket;
    private PrintWriter server_out;
   
   public void onStart(IContext context) throws JFException {
      this.engine = context.getEngine();
      this.console = context.getConsole();
      this.history = context.getHistory();
      this.context = context;
      this.indicators = context.getIndicators();
      this.userInterface = context.getUserInterface();

        serverSocket = null;
        clientSocket = null;
        try {
            serverSocket = new ServerSocket(4444);
            clientSocket = serverSocket.accept();
            server_out = new PrintWriter(clientSocket.getOutputStream(), true);
        } catch (IOException e) {
            context.getConsole().getOut().println(e);
        }
   }

   public void onAccount(IAccount account) throws JFException {
   }

   public void onMessage(IMessage message) throws JFException {
   }

   public void onStop() throws JFException {
        server_out.close();
       
        try {
            clientSocket.close();
            serverSocket.close();
            } catch (IOException e) {
            context.getConsole().getOut().println(e);
        }
   }

   public void onTick(Instrument instrument, ITick tick) throws JFException {
            String string = instrument+";"+tick.getBid()+";"+tick.getAsk();
            server_out.println(string);
   }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Mon 18 Oct, 2010, 12:51 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
Also there is the 'Agent API', possibly you could use this, although it appears as that it has some issues.


 
 Post subject: Dukascopy Fix 4.4 under .Net Post rating: 0   New post Posted: Tue 19 Oct, 2010, 04:16 

User rating: -
Hi,
I represent some investors and we are looking for a bank/marketplace that support Fix 4.4 and .Net.
We already have a .Net implementation and I saw that Dukascopy work with Fix 4.4.
I've seen the related posts but it was not clear to me if Dukascopy have it or not.
Our complete implementation is: Fix 4.4 / Quickfix.org / .net 3.5 (c#) / (client side only for listen ticks and operate). :geek:
We want to listen the ticks for a particular pair and operate using this implementation.

Thanks! :)
Best regards


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Tue 19 Oct, 2010, 08:22 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Dukascopy FIX: https://www.dukascopy.com/swiss/english/forex/api/fix_api/
FIX .NET: https://www.quickfixengine.org/


 
 Post subject: Re: JForex on .Net Post rating: 1   New post Posted: Mon 25 Oct, 2010, 10:10 

User rating: 1
Joined: Mon 25 Oct, 2010, 09:04
Posts: 1
There is also another method.
We successfully connected to the API from .NET, using IKVM.NET:

1. Download IKVM.NET from https://www.ikvm.net/ - a Java Virtual Machine implemented in .NET
2. Download JForex API from https://www.dukascopy.com/swiss/english/forex/jforex/library/
3. Extract ikvm zip package somewhere and then extract .jar files from JForexLibrary.zip into ikvm bin-folder.

Now, using ikvmc.exe we have to convert Java bytecode from .jar files to .NET dll's:

C:\Program Files\ikvm\bin>ikvmc -target:library JForex-API-2.6.17.jar jForex-2.5.1.jar DDS2-Connector-1.1.9.jar log4j-1.2.14.jar mina-core-1.1.7.jar mina-filter-ssl-1.1.7.jar nlink-1.jar slf4j-api-1.5.8.jar slf4j-log4j12-1.5.8.jar ta-lib-0.4.4dc.jar

ikvmc.exe will generate a single .NET assembly called JForex-API-2.6.17.dll, that can be used in standart .NET project (with references to IKVM libraries!).

Form1.cs (based on code in Main.java from sample in JForexLibrary.zip):
        private string jnlpUrl = "https://www.dukascopy.com/client/demo/jclient/jforex.jnlp";
        private string userName = "<user>";
        private string password = "<password>";

        private void Form1_Load(object sender, EventArgs e)
        {
             IClient client = ClientFactory.getDefaultInstance();
             client.setSystemListener(new SystemListener(client, jnlpUrl, userName, password));
             client.connect(jnlpUrl, userName, password);

             int i = 10; //wait max ten seconds
             while (i > 0 && !client.isConnected())
             {
                 Thread.Sleep(1000);
                 i--;
             }
             if (!client.isConnected())
                 Console.WriteLine("not connected");

             java.util.HashSet set = new java.util.HashSet();
             Instrument[] array = Instrument.values();
             foreach (Instrument ins in array)
                 set.add(ins);

             client.setSubscribedInstruments(set);
             client.startStrategy(new Strategy());
        }


SystemListener class (based on anonymous class in Main.java):
    public class SystemListener : ISystemListener
    {
        private int lightReconnects = 3;
        public IClient Client { get; private set; }
        public string Url { get; set; }
        public string User { get; set; }
        public string Pass { get; set; }

        public SystemListener(IClient client, string url, string user, string pass)
        {
            Client = client;
            Url = url;
            User = user;
            Pass = pass;
        }

        #region ISystemListener Members

        public void onConnect()
        {
            lightReconnects = 3;
        }

        public void onDisconnect()
        {
            if (lightReconnects > 0)
            {
                Client.reconnect();
                --lightReconnects;
            }
            else
            {
                try
                {
                    //sleep for 10 seconds before attempting to reconnect
                    System.Threading.Thread.Sleep(10000);
                }
                catch (java.lang.InterruptedException e)
                {
                    //Console.WriteLine(e.ToString());
                }
                try
                {
                    Client.connect(Url, User, Pass);
                }
                catch (System.Exception e)
                {
                    //Console.WriteLine(e.ToString());
                }
            }
        }

        public void onStart(long l)
        {
        }

        public void onStop(long l)
        {
        }

        #endregion
    }


Some strategy implementation (a simple tick logger):
    public class Strategy : IStrategy
    {
        private StreamWriter writer;
        private DateTime DATE_BASE = new DateTime(1970, 1, 1);
       
        #region IStrategy Members

        public void onAccount(IAccount ia)
        {
        }

        public void onBar(Instrument i, Period p, IBar ib1, IBar ib2)
        {
        }

        public void onMessage(IMessage im)
        {
        }

        public void onStart(IContext ic)
        {
            writer = new StreamWriter("d:\\ticks.log", false);
        }

        public void onStop()
        {
            writer.Close();
        }

        public void onTick(Instrument i, ITick it)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(i.toString());
            builder.Append(";");
            DateTime time = DATE_BASE.AddMilliseconds(it.getTime());
            builder.Append(time.ToString("yyyy-MM-dd HH:mm:ss"));
            builder.Append(";");
            builder.Append(it.getBid());
            builder.Append(";");
            builder.Append(it.getBidVolume());
            builder.Append(";");
            builder.Append(it.getAsk());
            builder.Append(";");
            builder.Append(it.getAskVolume());

            String line = builder.ToString();
            Console.WriteLine(line);
            writer.WriteLine(line);
        }

        #endregion
    }


A.Todorov,
STS Soft developer


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Tue 26 Oct, 2010, 14:14 

User rating: 3
Joined: Mon 30 Aug, 2010, 13:06
Posts: 27
Hello a.todorov
This sounds like a great alternative for those who want to use .Net without having more than 100k on their accounts. Im gonna try it. How is the performance in this solution? Do you feel that it is slower than when you use java or is it about the same? did you ever compare the speed of for example order placements in .net with the one in java (for example with a timer which is activated when the order is sent and stopped when the answer of the server is recieved?). That would be very interresting. Thank you for this solution. By the way, do you have more samplecode which you could share?

best

simplex

Edit: It is working. I ported it to vb.net. Now im gonna test it a little to see how the use of indicators in more complex strategies is working. But it looks pretty fast and stable.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Mon 02 May, 2011, 15:10 

User rating: -
Does JForex-API-2.6.38 still work now?
While using JForex-API-2.6.38 with ikvm, I am getting the following javax.net.ssl.SSLHandshakeException:

  Message=sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  Source=IKVM.OpenJDK.Core
  StackTrace:
       in sun.net.www.protocol.http.HttpURLConnection.getInputStream()
       in sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream()
       in com.dukascopy.api.impl.connect.DCClientImpl.m(String )
       in com.dukascopy.api.impl.connect.DCClientImpl.connect(String str1, String str2, String str3, String str4)
       in com.dukascopy.api.impl.connect.DCClientImpl.connect(String str1, String str2, String str3)
     ....



Could you please tell me if you have any idea of what could be causing this? I have tested my application with ikvm 0.46.0.1 and ikvm 0.44.0.5.

Thanks for your help in advance

andy


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Wed 11 May, 2011, 16:28 
User avatar

User rating: 0
Joined: Tue 24 May, 2011, 00:41
Posts: 38
Location: United KingdomUnited Kingdom
Dear Mr Todorov,

Thank you very much for this fantastic piece of information and relative code.

I have run your code under Virtual Machine (Mac OS X) on Windows 7, Visual Studio 2010 and everything worked fine. From now on I think I will develop under VS because of your fantastic hint; again: a personal thank you.

Andy,

Did you import all libraries generated by ikvm? You need all the libraries, not only com.ducascopy...

Anyhow I was still having problems, since I did not have last JVM on Windows. I got the most recent update from the java website:

https://java.com/en/download/index.jsp

version 6 update 25 as of today

and it works fine. Hope this helps, please let me know if it worked out.

Good luck!


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Fri 03 Jun, 2011, 20:45 

User rating: -
(BACKGROUND: I posted this as a new thread but was instructed to refer to this thread, which does not address my issue, so I guessing that I'm being asked to post my topic here? Given that it says above "Please DO NOT POST OFF TOPICS in a one topic." it seems to me that I should not post this new topic in this thread, but I'll post it here as that seems to be what the moderator wants. I could be wrong about this, as I can only guess at this point. Perhaps all of the various topics related to IKVM with JForex are supposed to be here? I don't really know, so I hope I don't break too many rules...)

Also, and first of all, I would also like to thank Mr. Todorov for his IKVM suggestion and the clear examples that he provided. Mr. Todorov's post was very helpful, and it's working out well for me aside from this minor issue that I'm posting about.

ORIGINAL POST:

I'm coding an application in C# with the JForex API imported using IKVM. I've noticed that once my code connects using this kind of thing:

private void btnConnect_Click( object sender, EventArgs e )
{
Client = ClientFactory.getDefaultInstance();
slDukascopy = new SystemListener( Client, JForexString, UsernameString, PasswordString );
Client.setSystemListener( slDukascopy );
AttemptLogin(); // first login attempt always fails (timeout issue of some sort?)
btnConnect.Enabled = false;
btnLogin.Enabled = true;
btnDisconnect.Enabled = true;
}


It does not matter what I do, but I cannot get the JForex client to disconnect / unload -- it remains running in the background, passing traffic back and forth to the Dukascopy side, no matter what I do. (The only thing that works to unload the client is Environment.Exit( 0 ); which is a little too drastic...)

I've tried things like:

private void btnLogout_Click( object sender, EventArgs e )
{
Client.connect( null, null, null );
btnLogin.Enabled = true;
btnLogout.Enabled = false;
btnDisconnect.Enabled = true;
}


and:

private void btnDisconnect_Click( object sender, EventArgs e )
{
Client.setSystemListener( null );
slDukascopy = null;
Client = null;
btnConnect.Enabled = true;
btnLogin.Enabled = false;
btnDisconnect.Enabled = false;
}


but nothing I do is effective to drop the client communication except dumping the environment itself. I'm wondering if anyone has any ideas or knows how to reset the JForex client in code?

thx! t.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Fri 03 Jun, 2011, 21:18 

User rating: -
Just wanted to share some code that has worked out for me to access the trading thread, using JForex with IKVM to code in C# / .NET.

(Please bear with me if this is an off-topic post, I can repost it to its own topic if that's necessary!)

Anyway, I was getting "wrong thread" type of errors when trying to place/modify/close orders from strategy methods other than the standard 6 .onTick, .onBar, etc. I had made a method in my Strategy class called .OpenLong from which I was trying to open simple market buy orders. Messed around for a while, trying to get things going with an anonymous delegate function, etc., etc., and eventually stumbled on this method that works for me. I thought I would share this in case others wanted to do the same thing, and perhaps if others can provide pointers on how to do it better, as I've only got 2 months experience with C#!

First of all, what I do is make my own generic subclass of Callable for each type of function that I want to call. (I should note too that a single derived class could also be used with internal logic in the .call() method to select the desired function.) So I have, for example, a plain-vanilla submit order subclass:

    public class MyCallableSubmitOrder<T> : Callable
    {
        public IOrder NewOrder;

        public IEngine MainJForexEngine;
        public string strLabel;
        public Instrument CurrentInstrument;
        public IEngine.OrderCommand Command;
        public double OrderSize;

        public object call()
        {
            NewOrder = MainJForexEngine.submitOrder( strLabel, CurrentInstrument, Command, OrderSize );
            return NewOrder;
        }
    }


And also a submit order with a stop setting:

    public class MyCallableSubmitOrderWithStop<T> : Callable
    {
        public IOrder NewOrder;

        public IEngine MainJForexEngine;
        public string strLabel;
        public Instrument CurrentInstrument;
        public IEngine.OrderCommand Command;
        public double OrderSize;
        private double MarketPrice = 0;
        private double DefaultSlippage = -1;
        public double StopLoss;
        private double TakeProfit = 0;

        public object call()
        {
            NewOrder = MainJForexEngine.submitOrder( strLabel, CurrentInstrument, Command, OrderSize,
                                                     MarketPrice, DefaultSlippage, StopLoss, TakeProfit );
            return NewOrder;
        }
    }


(etc., etc. There are also MyCallables for adjusting stops, closing positions, etc.)

Then, within the strategy class I've got my custom methods for the various types of operations that I need to do. For example, corresponding to the above two subclasses there are these two methods which can be called from anywhere in the main forms code:

For plain-vanilla long positions:

        public bool OpenLong( string strLabel )
        {
            // clear previous order variables as they are invalidated immediately upon open request
            //
            dblBuyClosedOrderPrice = 0;

            MyCallableSubmitOrder<IOrder> mycallable = new MyCallableSubmitOrder<IOrder>();
            mycallable.MainJForexEngine = MainJForexEngine;
            mycallable.strLabel = strLabel;
            mycallable.CurrentInstrument = CurrentInstrument;
            mycallable.Command = IEngine.OrderCommand.BUY;
            mycallable.OrderSize = 0.001;

            Future future = TradingContext.executeTask( ( Callable )mycallable );
            Thread.sleep( 1000 );
            BuyOrder = MainJForexEngine.getOrder( strLabel );

            for ( int i = 0; ( i < 10 ) && ( BuyOrder == null ); i++ )
            {
                Thread.sleep( 500 );
                BuyOrder = MainJForexEngine.getOrder( strLabel );
            }
            if ( BuyOrder != null )
            {
                BuyOrderPipValue = CurrentInstrument.getPipValue();
                fMainAppForm.SetControlPropertyValue( tbLongPosition, "Text", strLabel + ":" + strCurrentInstrument );
                return true;
            }
            else
                return false;
        }


For long positions with an initial fixed stop:

        public bool OpenStopLong( string strLabel, double dblLongStop )
        {
            dblBuyClosedOrderPrice = 0;

            MyCallableSubmitOrderWithStop<IOrder> mycallable = new MyCallableSubmitOrderWithStop<IOrder>();
            mycallable.MainJForexEngine = MainJForexEngine;
            mycallable.strLabel = strLabel;
            mycallable.CurrentInstrument = CurrentInstrument;
            mycallable.Command = IEngine.OrderCommand.BUY;
            mycallable.OrderSize = 0.001;
            mycallable.StopLoss = dblLongStop;

            Future future = TradingContext.executeTask( ( Callable )mycallable );
            Thread.sleep( 1000 );
            BuyOrder = MainJForexEngine.getOrder( strLabel );

            for ( int i = 0; ( i < 10 ) && ( BuyOrder == null ); i++ )
            {
                Thread.sleep( 500 );
                BuyOrder = MainJForexEngine.getOrder( strLabel );
            }
            if ( BuyOrder != null )
            {
                BuyOrderPipValue = CurrentInstrument.getPipValue();
                fMainAppForm.SetControlPropertyValue( tbLongPosition, "Text", strLabel + ":" + strCurrentInstrument );
                dblBuyOpenedOrderPrice = -1;
                return true;
            }
            else
                return false;
        }


And then, as there are some delays getting order details back from the server, I use the .onTick() method to query values and set appropriate variables and text box controls later, using (for example), the dblBuyOrderOpenedPrice as a flag that indicates when -1 that values need to be reloaded from the server. A portion of the .onTick() method that handles some of the late variable initialization looks like this:

            // some variables and text display fields are set here as there are delays in getting pricing results from the server
            //
            // Opening a Buy Order
            //
            if ( ( BuyOrder != null ) && ( dblBuyOpenedOrderPrice == 0 ) )
            {
                dblBuyOpenedOrderPrice = BuyOrder.getOpenPrice();
                fMainAppForm.SetControlPropertyValue( tbLongOpen, "Text", dblBuyOpenedOrderPrice.ToString().Trim() );
            }

            // Opening a Buy-with-a-Stop Order
            //
            if ( ( ( BuyOrder != null ) && ( dblBuyOpenedOrderPrice == -1 ) ) || // -1 flags a Buy-with-a-Stop order
                 blOpenedBuyWithAStopPricesPending )
            {
                blOpenedBuyWithAStopPricesPending = true;
                dblBuyOpenedOrderPrice = BuyOrder.getOpenPrice();
                if ( dblBuyOpenedOrderPrice != 0 )
                {
                    dblBuyCurrentStopSetting = BuyOrder.getStopLossPrice();
                    fMainAppForm.SetControlPropertyValue( tbLongOpen, "Text", dblBuyOpenedOrderPrice.ToString().Trim() );
                    fMainAppForm.SetControlPropertyValue( tbLongStop, "Text", dblBuyCurrentStopSetting.ToString().Trim() );
                    blOpenedBuyWithAStopPricesPending = false;
                }
            }

            // Adjusting Stop on a Buy Order
            //
            if ( ( ( BuyOrder != null ) && ( dblBuyCurrentStopSetting == -1 ) ) || // -1 flags a Stop Adjustment order
                 blAdjustedBuyStopPricePending )
            {
                blAdjustedBuyStopPricePending = true;
                dblBuyCurrentStopSetting = BuyOrder.getStopLossPrice();
                if ( dblBuyCurrentStopSetting != dblSavedBuyStopSetting )
                {
                    fMainAppForm.SetControlPropertyValue( tbLongStop, "Text", dblBuyCurrentStopSetting.ToString().Trim() );
                    blAdjustedBuyStopPricePending = false;
                }
            }


The following is an example of how I access these trading functions from the main forms code, in the case of a buy-with-a-stop call:

        private void btnOpenStopLong_Click( object sender, EventArgs e )
        {
            string strOrderLabel;
            double dblStopPrice;

            // set-up the X stop value field to valid selection first
            //
            if ( txtboxXLong.Text == null )
            {
                txtboxXLong.Text = "10";
                dblXLongStop = 10;
            }
            else
            {
                try
                {
                    dblXLongStop = Convert.ToDouble( txtboxXLong.Text );
                }
                catch
                {
                    txtboxXLong.Text = "10";
                    dblXLongStop = 10;
                }
            }

            // normal open with a stop processing starts here
            //
            txtboxLongClose.Text = null;

            uintLongNumber++;
            strOrderLabel = "B" + uintLongNumber.ToString().Trim();

            // the strategy object's current instrument is exposed as a public, and as the buy is of the current instrument, the current market
            // price can be accessed here to calculate the desired stop loss in pips
            //
            dblStopPrice = DemoTradeStrategy.CurrentTick.getAsk() - ( dblXLongStop * DemoTradeStrategy.CurrentInstrument.getPipValue() );

            if ( DemoTradeStrategy.OpenStopLong( strOrderLabel, dblStopPrice ) )
            {
                strLong = strOrderLabel;

                btnOpenLong.Enabled = false;
                btnOpenStopLong.Enabled = false;
                btnUpdateLong.Enabled = true;
                btnStopSetLong.Enabled = true;
                btnCloseLong.Enabled = true;
            }
            else
            {
                txtboxLongPosition.Text = "FAIL!";
            }
            Refresh();
        }



Anyway, for what it's worth, I thought I would post this code. It took me a few hours to figure out how to get access to that Java-based trading thread from within .NET, and it seemed like a useful discovery to me that might be of benefit to others. As always, feel free to pillage the posted code if it will help your project -- AND, if you've got a better way to do this then by all means please post it too! As I said, I'm a C# / .NET newbie, so take it for what it's worth...

thx, t.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Mon 18 Jun, 2012, 20:16 

User rating: 0
Joined: Mon 18 Jun, 2012, 19:23
Posts: 1
It's been a while since someone posted something here (and no other threads about JForex on .Net using IKVM libraries too). Does anyone use this?

With new JForex libraries (2.6.69), i have an issue, that sometimes it crashes when trying to connect. There is no such problem with the old libraries (2.6.23), but in those - there is no function to disconnect or to connect using Pin.
And crash can't be handled (try..catch doesn't help), it's somewhere deep in JForex libraries i suppose. It happens in about 20% of connect tries. And if connected, then disconnect and connect again - never crashes... it's happening only with the first connect try.

What else can i say... i'm using exactly the same code to connect as before, so i don't think that problem can be there. And i've tried, old libraries still connect without crash. And java installed is newest, so please don't tell me to update.

Oh and another thing, "ClientFactory.getDefaultInstance()" as shown in this thread is not working for me, it shows "DCClientImpl class not found", but it's there... so i'm just creating an instance of DCClientImpl instead. But doing the same worked fine in 2.6.23, so it should not be a problem (and it works in 80% of connects), but who knows...

Seems to be all i can say about this problem.

Maybe somebody had the same problem? And solved it?
Or at least maybe someone can tell me where can i get old versions of JForex libraries? I can find there some middle version, that can connect using Pin, and doesn't have the connection crash problem.

Thanks!


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Sat 08 Feb, 2014, 11:30 
User avatar

User rating: 0
Joined: Tue 24 May, 2011, 00:41
Posts: 38
Location: United KingdomUnited Kingdom
Dear Support,

I am having problems in creating the .dll file from ikvm.

Specifically since now you make use of maven, I am not capable to find all the dependencies. I am not familiar with maven, in fact.

Is there a way to use JForex under .net as a compiled .DLL?

The code published by A.Todorov was functional and of great help, but the link to the JForex SDK does not work anymore.

Will you be so kind to provide me with a link to a valid repository where the whole SDK is present for public download or to suggest me any other viable solution to call JForex SDK through .NET?

Thanks in advance and have a great weekend.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Mon 10 Feb, 2014, 08:42 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
To copy dependencies simply go to the root folder of the project and type:
mvn dependency:copy-dependencies
and the dependencies will get copied to the JForex-SDK/target/dependency folder. For this you have to have maven installed.
Alternatively you can go to our public repository and manually download all the dependencies by the given paths in the latest JForex-SDK.pom file, see:
https://publicrepo.site.dukascopy.com/jforexlib/publicrepo/com/dukascopy/dds2/JForex-SDK/2.31/


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Tue 11 Feb, 2014, 01:38 
User avatar

User rating: 0
Joined: Tue 24 May, 2011, 00:41
Posts: 38
Location: United KingdomUnited Kingdom
Dear API Support,

Thank you very much for your kind response.

I have another problem.

I have successfully installed maven and run the code provided and it seems I can run a strategy from .NET, through ikvm.

Unfortunately I can not run a tester.

I get the following exception, if trying to run the tester:

Exception in thread "StrategyRunner Thread" java.lang.IllegalArgumentException:
No thick history for EUR/ZAR to create custom period candles of 1 Sec
at com.dukascopy.charts.data.datacache.customperiod.tick.LoadCandlesFromTicksAction.<init>(LoadCandlesFromTicksAction. java:82)
[...] at java.lang.Thread.run(Thread.java:937).

I have tried to run java threads (using java.lang.Thread.sleep(timeInMillsecs))
as well as C# thread using System.Threading.Thread.Sleep(timeInMillSecs)

I still get the same message, plus why does it mention EUR/ZAR? I am asking for EUR/USD. Please find also attached a screenshot from VS output console, if may useful.

Any help highly appreciated. Thanks again.


Attachments:
Screen Shot 2014-02-11 at 00.27.23.png [42.06 KiB]
Downloaded 389 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Tue 11 Feb, 2014, 09:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
dedalus wrote:
Exception in thread "StrategyRunner Thread" java.lang.IllegalArgumentException:
No thick history for EUR/ZAR to create custom period candles of 1 Sec
at com.dukascopy.charts.data.datacache.customperiod.tick.LoadCandlesFromTicksAction.<init>(LoadCandlesFromTicksAction. java:82)
[...] at java.lang.Thread.run(Thread.java:937).

I have tried to run java threads (using java.lang.Thread.sleep(timeInMillsecs))
as well as C# thread using System.Threading.Thread.Sleep(timeInMillSecs)

I still get the same message, plus why does it mention EUR/ZAR? I am asking for EUR/USD.
We are just speculating, but could it be some off-by-one enum conversion problem between .NET and java. If this was the case, then EUR/TRY would cause the loading of EUR/USD.

On another note - is there anything that prevents you from writing your program directly in java? In our opinion, C# and java syntaxes and APIs are similar enough to make the transition, especially from C# to java.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Wed 12 Feb, 2014, 00:02 
User avatar

User rating: 0
Joined: Tue 24 May, 2011, 00:41
Posts: 38
Location: United KingdomUnited Kingdom
Dear Support,

Thank you very much for your prompt and kind answer.

Unfortunately that did not solve the issue: I have the exactly the same behaviour, mentioning EUR/ZAR, even when asking for EUR/TRY.

I agree that C# and Java are very similar, if not the same, at a syntax level; but I tend to strongly prefer C# since I am familiar with Visual Studio and am less familiar with Java over all: for example I would not know how to accomplish lambda expressions (if are present), delegates, or dynamic typing, to cite just few, without considering LINQ and parallelisation, for example.

Other than that, I would like to adopt some numeric libraries written for .NET.

Any hint, highly appreciated. Thank you very much, anyway.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Wed 12 Feb, 2014, 09:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
dedalus wrote:
I agree that C# and Java are very similar, if not the same, at a syntax level; but I tend to strongly prefer C# since I am familiar with Visual Studio and am less familiar with Java over all: for example I would not know how to accomplish lambda expressions (if are present), delegates, or dynamic typing, to cite just few, without considering LINQ and parallelisation, for example.
Lambdas are going to be there with Java 8. Delegates you can write as Callable or Runnable and then pass it as an argument. LINQ has some third-party libraries which come with an performance overhead. Paralellisation you can achieve by using executors and other. Bottom line, java has the same expressive power, but you might required to write more code to achieve the same thing. The internet is full of descriptions "how to do this C# thing in java" - thus, it should not take too much time to adapt. Essentially you have a choice between a pure-java code which does not have additional issues discussed above or writing in C# and very limited API Support when you have an issue, because when you report an issue for a proper investigation from our side you need to post a java program.
dedalus wrote:
Other than that, I would like to adopt some numeric libraries written for .NET.
You can use JNA to load dll's in java:
viewtopic.php?f=65&t=46790
dedalus wrote:
Any hint, highly appreciated. Thank you very much, anyway.
As we posted already above, for us to investigate an issue we need a java program which replicates the case. Plus the reproduction steps, if any.


 
 Post subject: Re: JForex on .Net Post rating: 0   New post Posted: Wed 30 Dec, 2015, 05:23 
User avatar

User rating: 2
Joined: Fri 27 Jul, 2012, 07:04
Posts: 82
Location: Spain, Paracuellos de Jarama
Hello,
How I can download JForexLibrary.zip ?

Thanks


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com