Spreads in R (Quantstrat and FinancialInstrument) - Matlab, R project and Python | futures io social day trading
futures io futures trading


Spreads in R (Quantstrat and FinancialInstrument)
Updated: Views / Replies:4,505 / 14
Created: by treydog999 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Spreads in R (Quantstrat and FinancialInstrument)

  #11 (permalink)
Elite Member
Philadelphia + NJ/US
 
Futures Experience: Beginner
Platform: quantstrat
Favorite Futures: ETFs
 
Posts: 52 since Aug 2014
Thanks: 4 given, 39 received

@treydog999

I wrote this post to address this topic:

A Way To Model Execution On Individual Legs Of A Spread In Quantstrat | QuantStrat TradeR

Let me know if it helps.

Reply With Quote
The following 3 users say Thank You to IlyaKipnis for this post:
 
  #12 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received


IlyaKipnis View Post
@treydog999

I wrote this post to address this topic:

A Way To Model Execution On Individual Legs Of A Spread In Quantstrat | QuantStrat TradeR

Let me know if it helps.

Thanks for that post. I have been wracking my brain for weeks for a way to do this. I do lose the ability to use built in optimization and other functionality but it is definitely worth it. I really appreciate you doing this since no one else was as helpful. A few of the people in R-Sig finance told me this was out of the scope of quantstrat and just ended it there. You created a work around that comes up with usable results. creating a loop or function to work out multiple series of precomputed signals is a small price to pay for being able to test the ideas without starting from scratch.

Reply With Quote
 
  #13 (permalink)
Elite Member
tel aviv
 
Futures Experience: Advanced
Platform: Multicharts, SC
Favorite Futures: es
 
Posts: 34 since Jun 2009
Thanks: 4 given, 1 received


@IlyaKipnis

thanks for your code. I will try to make it intraday but first this...

I tried to add the short side of it as mentioned @ the end of your blog using this code
where the "_s" is for the short of the pair (short 3 UNG and long 1 UGAZ)

 
Code
#Short pair

#short signal of the pair
signal_s <- Cl(spread) < EMA(Cl(spread), n=nEMA) 
UNG$precomputedSig_s <- signal_s 
UGAZ$precomputedSig_s <- signal_s *-1

#long rules
add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=.5, 
                          relationship="gt", cross=TRUE),
           label="longEntry")

add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=.5, 
                          relationship="lt", cross=TRUE),
           label="longExit")

#short rules
add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=-.5, 
                          relationship="lt", cross=TRUE),
           label="shortEntry")

add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=-.5, 
                          relationship="gt", cross=TRUE),
           label="shortExit")

#buy 1
add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="longEntry", sigval=TRUE, ordertype="market", 
                        orderside="long", replace=FALSE, prefer="Open", orderqty=1), 
         type="enter", path.dep=TRUE)

add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="longExit", sigval=TRUE, orderqty="all", ordertype="market", 
                        orderside="long", replace=FALSE, prefer="Open"), 
         type="exit", path.dep=TRUE)

#short 3
add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="shortEntry", sigval=TRUE, ordertype="market", 
                        orderside="short", replace=FALSE, prefer="Open", orderqty=-3), 
         type="enter", path.dep=TRUE)

add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="shortExit", sigval=TRUE, orderqty="all", ordertype="market", 
                        orderside="short", replace=FALSE, prefer="Open"), 
         type="exit", path.dep=TRUE)
#########################################################################
#End of short the pair
#########################################################################
I am getting this error when running this line:
 
Code
 out <- applyStrategy(strategy=strategy.st,portfolios=portfolio.st)
Error in get(signal$name) : object 'sigThreshold_s' not found

I assume this is something to do with quantmode which i am not familiar with and hope for you help.

Also, I assume that the units of 3 and 1 should be 300 and 100 as min. trade size for equities.
Thanks and happy holidays.

Reply With Quote
 
  #14 (permalink)
Elite Member
Philadelphia + NJ/US
 
Futures Experience: Beginner
Platform: quantstrat
Favorite Futures: ETFs
 
Posts: 52 since Aug 2014
Thanks: 4 given, 39 received


giladbi View Post
@IlyaKipnis

thanks for your code. I will try to make it intraday but first this...

I tried to add the short side of it as mentioned @ the end of your blog using this code
where the "_s" is for the short of the pair (short 3 UNG and long 1 UGAZ)

 
Code
#Short pair

#short signal of the pair
signal_s <- Cl(spread) < EMA(Cl(spread), n=nEMA) 
UNG$precomputedSig_s <- signal_s 
UGAZ$precomputedSig_s <- signal_s *-1

#long rules
add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=.5, 
                          relationship="gt", cross=TRUE),
           label="longEntry")

add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=.5, 
                          relationship="lt", cross=TRUE),
           label="longExit")

#short rules
add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=-.5, 
                          relationship="lt", cross=TRUE),
           label="shortEntry")

add.signal(strategy.st, name="sigThreshold_s",
           arguments=list(column="precomputedSig_s", threshold=-.5, 
                          relationship="gt", cross=TRUE),
           label="shortExit")

#buy 1
add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="longEntry", sigval=TRUE, ordertype="market", 
                        orderside="long", replace=FALSE, prefer="Open", orderqty=1), 
         type="enter", path.dep=TRUE)

add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="longExit", sigval=TRUE, orderqty="all", ordertype="market", 
                        orderside="long", replace=FALSE, prefer="Open"), 
         type="exit", path.dep=TRUE)

#short 3
add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="shortEntry", sigval=TRUE, ordertype="market", 
                        orderside="short", replace=FALSE, prefer="Open", orderqty=-3), 
         type="enter", path.dep=TRUE)

add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="shortExit", sigval=TRUE, orderqty="all", ordertype="market", 
                        orderside="short", replace=FALSE, prefer="Open"), 
         type="exit", path.dep=TRUE)
#########################################################################
#End of short the pair
#########################################################################
I am getting this error when running this line:
 
Code
 out <- applyStrategy(strategy=strategy.st,portfolios=portfolio.st)
Error in get(signal$name) : object 'sigThreshold_s' not found

I assume this is something to do with quantmode which i am not familiar with and hope for you help.

Also, I assume that the units of 3 and 1 should be 300 and 100 as min. trade size for equities.
Thanks and happy holidays.

Both instruments should contain the signal name. UNG doesn't have sigThreshold_s. The reason it works for me is that I called the signal the same thing in the spread, but defined it differently.

Reply With Quote
 
  #15 (permalink)
Trading Apprentice
London + London
 
Futures Experience: Advanced
Platform: IB
Favorite Futures: All
 
Posts: 1 since Jan 2017
Thanks: 0 given, 0 received

Any progress

Hi,

I can across your post and was wondering what approach you finally took?

Reply With Quote

Reply



futures io > > > > Spreads in R (Quantstrat and FinancialInstrument)

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
R Backtesting and Optimization: Quantstrat Big Mike Matlab, R project and Python 16 February 14th, 2015 09:06 PM
WFA (walk forward analysis) Result using quantstrat R treydog999 Matlab, R project and Python 3 October 21st, 2014 11:22 AM
Preventing Look Forward Bias in Quantstrat/R treydog999 Matlab, R project and Python 4 September 8th, 2014 02:18 PM
Outright or Spreads? joeyk Bonds and Interest Rates Trading 31 July 16th, 2014 10:07 AM
Credit Spreads Trendi Options on Futures 7 January 29th, 2013 11:49 PM


All times are GMT -4. The time now is 10:23 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-10 in 0.09 seconds with 19 queries on phoenix via your IP 54.221.73.186