|
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.
Convert pip to currency |
Tyraslin
|
Post subject: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 14:52
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
I have made some try to convert the pip with the current currency. It's seems there some errors: if i use it on EUR/USD or GBP/USD on an account on EUR, all is right. However, if i do the same thing on USD/JPY (for exemple) and i keep my account in EUR, the result is different from what it must to be (i have used https://www.dukascopy.com/swiss/english/ ... xcalc/pip/ to check it). For exemple, on a lot size, of 100 000 JFutil return me 8.326 (ask = 78.675, eur/usd=1.24548) and dukascopy calculator give me a result of 10.21. Did i forgot to do something ? By advance, thanks.
|
|
|
|
 |
API Support
|
Post subject: Re: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 14:54
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Could you please provide the example strategy and the launch scenario?
|
|
|
|
 |
Tyraslin
|
Post subject: Re: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 15:17
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
Ok so: @Configurable("Instrument 1") public Instrument instrument1 = Instrument.EURUSD; @Configurable("Instrument 2") public Instrument instrument2 = Instrument.EURGBP; @Configurable ("Instrument 3") public Instrument instrument3 = Instrument.EURJPY; @Configurable ("Instrument 4") public Instrument instrument4 = Instrument.GBPUSD; @Configurable ("Instrument 5") public Instrument instrument5 = Instrument.USDJPY; @Configurable ("Instrument 6") public Instrument instrument6 = Instrument.USDCAD; @Configurable ("Instrument 7") public Instrument instrument7 = Instrument.USDCHF; @Configurable ("Instrument 8") public Instrument instrument8 = Instrument.AUDCAD;
@Configurable("Decimal separator in Excel") public String decSepa = ",";
@Configurable("Type sheet name") public String sheetName = "SPOT"; @Configurable("Langage of Excel") public String lang="FR";
private final Set<Instrument> instruments = new HashSet<Instrument>(Arrays.asList(new Instrument[] { instrument1, instrument2, instrument3, instrument4, instrument5, instrument6, instrument7, instrument8 }));
@Override public void onStart(IContext context) throws JFException { conversation = new DDEClientConversation(); console = context.getConsole(); context.setSubscribedInstruments(instruments); int i = 10; while (!context.getSubscribedInstruments().containsAll(instruments)) { try { console.getOut().println("Instruments not subscribed yet " + i); Thread.sleep(100); } catch (InterruptedException e) { console.getOut().println(e.getMessage()); } i--; } try { conversation.connect("Excel", sheetName); //I would like to have this values in a excel sheet JFUtils utils=context.getUtils(); int rows=3; for (Instrument instrument : instruments) { double curr1=utils.convertPipToCurrency(instrument, context.getAccount().getCurrency()); Double Curr1 = new Double (curr1); conversation.poke(getCell(rows,1),convertToDecimal(Curr1.toString())); rows++; } } catch (DDEClientException e) { print(e.toString()); } }
/....
public String convertToDecimal (String value) { String strToConvert; strToConvert =(decSepa ==",") ? value.replace('.', ',') : value; //(because i use excel in french) return strToConvert; }
public String getCell(int row, int column) { //To adapt on some other langages String str=""; if (lang=="FR") { str="L"+row+"C"+(column); } else if (lang =="EN") { str="R"+row+"C"+(column); } else if (lang=="GE") { str="R"+row+"K"+(column); } return str; }
As you can see, i use it to retrieve this values in an excel sheet (nammed "SPOT"). Thanks.
|
|
|
|
 |
API Support
|
Post subject: Re: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 15:20
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
API Support wrote: and the launch scenario? - How do you launch it? In historical tester (please provide the settings) or with live data?
|
|
|
|
 |
Tyraslin
|
Post subject: Re: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 15:22
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
|
|
|
 |
API Support
|
Post subject: Re: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 15:33
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
Tyraslin
|
Post subject: Re: Convert pip to currency |
Post rating: 0
|
Posted: Tue 05 Jun, 2012, 16:22
|
|
User rating: 4
Joined: Wed 21 Dec, 2011, 10:21 Posts: 30 Location: France, Sallanches
|
In fact, it seems that this portion of code doesn't work: ... int rows=3; for (Instrument instrument : instruments) { double curr1=utils.convertPipToCurrency(instrument, context.getAccount().getCurrency()); Double Curr1 = new Double (curr1); conversation.poke(getCell(rows,1),convertToDecimal(Curr1.toString())); rows++; } ...
So i have replaced by this in the onTick method: ... double curr1=utils.convertPipToCurrency(instrument1,currency); Double Curr1 = new Double (curr1); conversation.poke(getCell(3,5),convertToDecimal(Curr1.toString())); ...
for each of the instruments i want. Now it's work perfectly.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|