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.

help How to use a class in another file under the same package in one Strategy
 Post subject: help How to use a class in another file under the same package in one Strategy Post rating: 0   New post Posted: Wed 24 Oct, 2018, 09:15 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 26
Location: China,
for example:

1 ) my Strategy in Strategy_test.java file!!

--------------------------------
   package JForex_pack;

/**
 *
 * @author  test
 */
import java.util.*;

import com.dukascopy.api.*;

public class Strategy_test implements IStrategy {
         @Configurable("Instrument")
    public Instrument Curinstrument = Instrument.USDJPY;
        @Configurable("Amount")
    public double Amount = 0.51;
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    // Inport class in another file Inport.java
   [b] private Inport   curPort;[/b]
    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();

       [b] curPort=new Inport(); [/b]
       
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
       
       
    }
   
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       
         if (!instrument.equals(this.Curinstrument)) {
            return;

        }
         if (period.equals(Period.ONE_MIN))
        {
            [b]int  nRetCode=curPort.callMe();
            console.getInfo().print("call me retcode"+nRetCode);[/b]
        }
       
    }
}

2) Inport.java file

   package JForex_pack;

/**
 *
 * @test
 */
public class Inport {
   
     public int callMe()
     {
          System.out.println("call me right!!");
          return 1;
     }

}


 
 Post subject: Re: help How to use a class in another file under the same package in one Strategy Post rating: 0   New post Posted: Thu 25 Oct, 2018, 14:13 
User avatar

User rating: 8
Joined: Mon 09 Jun, 2014, 21:07
Posts: 49
Location: Poland, Warsaw
Hi,

1. Remove the 'public' keyword before your second class Inport.

2. Alternatively develop things in your IDE (like Eclipse) and use Maven plugin to package your code into .jfx file:

https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=56190

Best regards,
Greg


 
 Post subject: Re: help How to use a class in another file under the same package in one Strategy Post rating: 0   New post Posted: Fri 26 Oct, 2018, 12:49 

User rating: 0
Joined: Mon 11 Dec, 2017, 03:30
Posts: 26
Location: China,
I tested it, but the following exception occurred。。。。
in the NETBEAN 8.2 environment.
exception :
Downloaded: https://repo.maven.apache.org/maven2/com ... 16.0.1.pom (8 KB at 9.4 KB/sec)
Downloading: https://www.dukascopy.com/client/jforexl ... tadata.xml
Downloading: https://smartfx.eu/publicrepo/com/dukas ... tadata.xml
Downloading: https://repo.maven.apache.org/maven2/com ... tadata.xml

ʮ�� 26, 2018 7:44:28 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 7:44:28 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80
ʮ�� 26, 2018 7:44:28 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 7:44:28 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80
ʮ�� 26, 2018 7:44:28 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 7:44:28 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80


[WARNING] Could not transfer metadata com.dukascopy.dds2:DDS2-jClient-JForex/maven-metadata.xml from/to dc_public (https://www.dukascopy.com/client/jforexlib/publicrepo/): Connection reset
Downloading: https://www.dukascopy.com/client/jforexl ... tadata.xml
Downloading: https://smartfx.eu/publicrepo/com/dukas ... tadata.xml
Downloading: https://repo.maven.apache.org/maven2/com ... tadata.xml
ʮ�� 26, 2018 7:44:29 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 7:44:29 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80
ʮ�� 26, 2018 7:44:29 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 7:44:29 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80

ʮ�� 26, 2018 7:44:29 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: I/O exception (java.net.SocketException) caught when processing request to {}->https://www.dukascopy.com:80: Connection reset
ʮ�� 26, 2018 7:44:29 ���� org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
��Ϣ: Retrying request to {}->https://www.dukascopy.com:80


[WARNING] Could not transfer metadata com.dukascopy.api:JForex-API/maven-metadata.xml from/to dc_public (https://www.dukascopy.com/client/jforexlib/publicrepo/): Connection reset
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:51.604s
[INFO] Finished at: Fri Oct 26 19:44:29 CST 2018
[INFO] Final Memory: 21M/138M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal eu.smartfx:jfxpacker:1.0.0:packToJfx (default) on project sample-project: Execution default of goal eu.smartfx:jfxpacker:1.0.0:packToJfx failed: Plugin eu.smartfx:jfxpacker:1.0.0 or one of its dependencies could not be resolved: Failed to collect dependencies for eu.smartfx:jfxpacker:jar:1.0.0 (): No versions available for com.dukascopy.dds2:DDS2-jClient-JForex:jar:[3.2.24,) within specified range -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

--- pom.xml file :

      <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>eu.smartfx.sample</groupId>
   <artifactId>sample-project</artifactId>
   <version>1.0.0</version>
   <packaging>jar</packaging>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
   </properties>

   <build>
      <plugins>

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
               <archive>
                  <manifestEntries>
                     <pluginMainClass>strategies.sample.EquityTP</pluginMainClass>
                  </manifestEntries>
               </archive>
            </configuration>
         </plugin>


         <plugin>
            <groupId>eu.smartfx</groupId>
            <artifactId>jfxpacker</artifactId>
            <version>1.0.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>packToJfx</goal>
                  </goals>
                  <configuration>
                     <inputArtifacts>
                        <artifact>${samle_test}-${1.1}</artifact>
                     </inputArtifacts>
                     <!-- optional -->
                     <copyJfxFileTo>e:/Users/Grzegorz/Documents/JForex/Strategies/</copyJfxFileTo>
                     <!-- optional -->
                  </configuration>
               </execution>
            </executions>
         </plugin>

      </plugins>
   </build>

   <repositories>
      <repository>
         <id>dc_public</id>
         <name>Dukascopy public repository</name>
         <url>https://www.dukascopy.com/client/jforexlib/publicrepo/</url>
      </repository>
   </repositories>

   <pluginRepositories>
      <pluginRepository>
         <id>sfx_public</id>
         <name>smartFX public repository</name>
         <url>https://smartfx.eu/publicrepo/</url>
      </pluginRepository>
   </pluginRepositories>

   <dependencies>
      <dependency>
         <groupId>com.dukascopy.dds2</groupId>
         <artifactId>DDS2-jClient-JForex</artifactId>
         <version>3.2.24</version>
      </dependency>

      <dependency>
         <groupId>com.dukascopy.api</groupId>
         <artifactId>JForex-API</artifactId>
         <version>2.13.47</version>
      </dependency>
   </dependencies>
</project>


 
 Post subject: Re: help How to use a class in another file under the same package in one Strategy Post rating: 0   New post Posted: Sat 27 Oct, 2018, 06:30 
User avatar

User rating: 8
Joined: Mon 09 Jun, 2014, 21:07
Posts: 49
Location: Poland, Warsaw
Hi,

As per following site:
https://stackoverflow.com/questions/13220747/maven-exception-during-project-building

you might be ecountering one of following issues:
* network issue (if you are working behind proxy you need to configure maven to use proxy in maven's settings.xml file)
* you are using old maven version, please download the newest one from: https://ftp.ps.pl/pub/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip

On top of that, please update two elements in your pom.xml file:
* <copyJfxFileTo> with path to one that exists on your filesystem, for example to {$user.home}
* <inputArtifacts><artifact> with filename of your jar package, as per your current pom.xml file configuration it should be ${project.artifactId}-${project.version}

Best regards,
Greg


 

Jump to:  

  © 1998-2024 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