SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Sep 16, 2019 7:49 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Sep 25, 2012 1:41 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
I’m getting some strange fills using Currenex.

In this scenario I’ve opened a Long positions (Filled at 0.82261) and opened a stop underneath it (stop price 0.81801) on NSDUSD.

However, the stop order appears to have been filled immediately (@ 0.82317). What’s happening here? Confusion on order types between OQ and CNX?

Whilst this is an example, it seems to happen consistency across multiple positions.

I don’t have this problem when running exactly the same code base using OQ’s paper facility.

Thank and regards,

drolles


Top
 Profile  
 
PostPosted: Tue Sep 25, 2012 11:28 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Probably, a reason of the problem is Currency property of NSDUSD instrument. It should be NSD. Otherwise, CNX inverts limit and stop prices, like 1/price

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Wed Sep 26, 2012 12:29 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Alexei,

Thanks very much for the prompt reply.

I’ll give your suggestion a try to see how it goes.

Just to check, I’m going to put the quote currency (i.e. the first currency) as the currency within the instrument description. Is that correct?

I’m also having another issue.

I’m getting rejected orders with “invalid amount” when I’m trying to trade things like USDJPY. See screen shot attached. I think CNX is looking for the value not the amount?

Thanks and regards,

Dan


Attachments:
FXDD Currenex - USDJPY rejected amount.JPG
FXDD Currenex - USDJPY rejected amount.JPG [ 30.28 KiB | Viewed 10819 times ]
Top
 Profile  
 
PostPosted: Wed Sep 26, 2012 10:35 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Dan,

I'm not sure, but I think that 800 is incorrect quantity for CNX's orders - it's too small.
Please, ask CNX support about this rejection - it goes from their side.

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Sat Sep 29, 2012 11:29 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Alexei,

Thanks very much for the reply.

I’ve got in contact with FXDD / CNX on this. They said that mini-lots is the smallest you can trade (i.e. 10,000 position).

I’m a little confused here. Let’s say I want to trade ~30,000 position on of AUDJPY (3 times over the minimum). The current exchange rate is: ~ 80.88.

I’ve developed the table below to illustrate that:
Attachment:
Position sizing - threshold.JPG
Position sizing - threshold.JPG [ 17.7 KiB | Viewed 10811 times ]

So how do I trade this position size with OQ if it is submitting “Qty” that is not below the threshold and will be rejected?

Thanks and regards,

Dan


Top
 Profile  
 
PostPosted: Sat Sep 29, 2012 3:00 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Dan,

Excuse me, but I don't understand you clearly. MinLots is 10,000, but you want to trade 400 and ask me how do you can do it?

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Sun Sep 30, 2012 1:28 pm 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Alexei,

Thanks for that reply.

I’m comparing my backtests and the position sizing that OQ is giving me vs the positions sizes I’m calculating on this http://www.earnforex.com/position-size-calculator and the two are not aligning.

My underlying assumption here is that the positions (and their sizes) should be equal always between OQ and the broker. Would you agree? I should be able to reconcile OQ to my broker account at the end of each trading day to confirm the trades are exactly the same. Do you feel this is a fair assumption?

In this backtest the Strategy currency in this case is set to USD.
Attachment:
Position sizing - threshold cont - backtest results.JPG
Position sizing - threshold cont - backtest results.JPG [ 47.68 KiB | Viewed 10808 times ]
In the case of the AUDJPY trades below what is “Qty” here, AUD? The instrument currency is set to AUD (as per our previous exchange on this thread). So is the “Value” in USD? If so, aren’t I buying nearly 3 mini-lots.

Which if I do the calculation of the PnL from that trade, appears to been. As I lost 19 pips and the loss was ~USD 75 (75 / 19) = 3.9.

So let me put the question another way, how do I buy a mini-lot of AUDJPY using Qty when firing the order to CNX? I need to fire an order with 10,000 right. But, what will be the “Value” in the OQ portfolio? I enter 10,000 into Qty it will do 10,000 * 81.5 Value = 815,000 … which is obviously not what I want… I want to buy use 10,000 AUDs to buy 815,000 of Yen. CNX will have 1 mini-lot and OQ will have the conversation of that mini-lot, the 2 will not equal.

I suspect that I know what is happening here. Unfortunately, it is the same flaw I found in NinjaTrader. See here: http://www.ninjatrader.com/support/help ... tegies.htm.

I also understand why now PBJ and GP2X have replied as thus in this thread: viewtopic.php?f=41&t=9799. PBJ solution about manually inserting Transactions into the Portfolio is really messy, but I completely understand why he has now done it.

So in summary, the portfolio in OQ is never going to equal the portfolio at the broker; not good at all. What are the implications of this … e.g. how am I going to use fixed fractional position sizing if the Portfolio value within OQ doesn’t equal reality? It is impossible (hence, PBJ’s solution).

Not good news.

Thanks and regards,

drolles


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 1:40 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Yep, now the market has opened I've tested this. See the below.

....

OQ's positions
Attachment:
OQ - Positions of mini-lots.JPG
OQ - Positions of mini-lots.JPG [ 13.2 KiB | Viewed 10805 times ]

Brokers Positions
Attachment:
Currenex - Positions of mini-lots.JPG
Currenex - Positions of mini-lots.JPG [ 39.93 KiB | Viewed 10805 times ]


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 1:51 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Now with the positions closed, with the PnL appearing in Yen, not in USD...

OQ's Portfolio Results
Attachment:
OQ - broker intergration - position closed.JPG
OQ - broker intergration - position closed.JPG [ 19.85 KiB | Viewed 10805 times ]

CNX's Results
Attachment:
Currenex - broker intergration - position closed.JPG
Currenex - broker intergration - position closed.JPG [ 41.51 KiB | Viewed 10805 times ]


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 2:01 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
And with the portfolio outcome - 290.00 USD (not Yen)
Attachment:
OQ - Portfolio Values - position closed.JPG
OQ - Portfolio Values - position closed.JPG [ 59.25 KiB | Viewed 10804 times ]


Top
 Profile  
 
PostPosted: Tue Oct 02, 2012 10:28 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

It seems that the main reason of the problem is that with CNX you should define "wrong" currency for an instrument. For EUR/USD pair you should specify EUR as the currency for the instrument to submit limit and stop orders to CNX. Once you define EUR currency - OQ will use this currency for this instrument. While in reality (and on the broker side) the currency is USD for EUR/USD pair and this is why you see positions in different currencies.

What you could try is this: set the currency to USD in OQ and
1) make sure you use 1/price for limit and stop orders.
or
2) a bit more sophisticated way: you can try to use MarketDataFilter and "replace" the quotes and trades coming from CNX with 1/quotes and 1/trades. In this case your strategy will get "correct" quotes and trades and you will be able to use "natural" prices for stop and limit orders.
viewtopic.php?f=64&t=9740

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 1:14 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Sergey,

Thanks for your reply.

I’m not getting these results. Did you test this on JPY crosses?

On the instruments where I’ve swapped the currency to JPY my orders are being rejected by CNX for invalid amounts.

I had to enter an order of 1,000,000 to have the order accepted.

See the screen shot attached with a series of test orders
Attachment:
Currenex - JPY cross problem.JPG
Currenex - JPY cross problem.JPG [ 55.61 KiB | Viewed 10784 times ]


Thanks,

drolles


Top
 Profile  
 
PostPosted: Sun Oct 07, 2012 12:52 pm 
Offline

Joined: Sun Oct 30, 2011 12:12 am
Posts: 220
Hi,


It seems to me that what you describe has serious consequences for using Currenex as an AltSource in QuantRouter.
I'm just asking with respect to data feed, not orders.

Example:
I want to store tick data for EURUSD on both IB and Currenex at the same time.
I setup QuantRouter, add the EURUSD instrument { Symbol = EURUSD, Currency = USD }.
Then I define an AltIDGroup { AltSource = IB, AltSymbol = EUR, AltExchange = IDEALPRO }.
Then I define an AltIDGroup { AltSource = Currenex, AltSymbol = EUR/USD }.
In OQ, I add a QR_IB_EURUSD instrument with AltIDGroup { AltSource = QuantRouter, AltSymbol = EURUSD(IB)Bid|Ask }.
In OQ, I add a QR_Currenex_EURUSD instrument with AltIDGroup { AltSource = QuantRouter, AltSymbol = EURUSD(Currenex)Bid|Ask }.
I display the Data Capture (QuantRouter) tab, add QR_IB_EURUSD and QR_Currenex_EURUSD to it and start.

=> Will QR display a provider error or inverted prices because the Currenex setup for EURUSD uses USD as currency?

If indeed there is an issue, then I'll need to create 2 separate instruments for EURUSD in QR: one for IB with USD currency, one for Currenex with EUR currency.
Longer term, you might want to add AltCurrency to the AltIDGroup.

Please help, I've been setting up this test environment for hours.


Top
 Profile  
 
PostPosted: Mon Oct 08, 2012 9:55 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Quote:
=> Will QR display a provider error or inverted prices because the Currenex setup for EURUSD uses USD as currency?

No. Currency field makes sense for orders only, not for market data.

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Mon Oct 08, 2012 11:14 am 
Offline

Joined: Sun Oct 30, 2011 12:12 am
Posts: 220
Thanks Alexei!

Another quick related question: it seems impossible currently to connect to multiple Currenex feeds within QuantRouter, is that correct?
Currenex is just a technology provider so you might get a different feed from one broker's Currenex feed and another's. Same for Integral, Hotspot, FXall.
I'd like to be able to store ticks from multiple Currenex feeds. Are you considering making that a possibility?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group