Click here to Login





                                                   How to force simulator to close open positions when data ends?

  0

0
Dave Walton
2014-05-16 03:45:41


Hi QS,

I've started to do backtesting with survivorship bias free data. I use Norgate Premium data and something I was not expecting happens when including delisted stocks. basically if I have an open position on one of the symbols that is delisted prior to my simulation end date, the simulator keeps the position open through the end of my simulation. I would expect the simulator to close this position. This ties up capital in a way that does not mimic reality. Is there a way to change this behavior in the simulator?



clonex
2014-05-16 08:37:18

  0

Try
sell = ref(close-1)=0;



QuantShare
2014-05-16 09:17:27

  0

Best Answer
Hi Dave,

You can add the following sell rule:

sell = .....
sell = sell and IsLastBar();




Dave Walton
2014-05-18 06:54:50

  0

Thanks QS. I forgot about the IsLastBar() function...

It should be this just for clarity's sake:

sell = sell OR IsLastBar();

This exits as normal or whenever the data time series ends. That is exactly what I wanted.



QuantShare
2014-05-18 16:42:33

  0

Yes Dave, sorry, it should be OR not AND


Torsten
2016-05-25 10:01:54

  0

Hi Dave,

are you using Norgate's PDU alpha for your backtests?

If so, I would be very interested how to get the data into QS. The PDU alpha data to is the reason I'm still using AB.

Best regards,
Torsten



Dave Walton
2016-05-25 18:58:39

  0

Hi Torsten,

I use Norgate data in QS but I maintain my own database of index constituency. Norgate supports this natively for AB, RE, and Python. I also use RE so I cross-check results.



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Simple pattern detection rules using close and open prices
How far are the close prices from the support line
Open Interest Data for Equity, Index and Futures Securities
Historical Earnings Surprise, EPS and Consensus Data
Daily Stock Quotes - Stock Market EOD Data

How-to Lessons
How to speed up watchlist and screener plug-ins when working with...
How to download historical EOD data for penny stocks
How to download and use U.S. stocks earnings data
How to download new quotes when selecting a chart
How to automate the data downloading process

Related Forum Threads
How to define an alternate asset to buy when no positions are hel...
How do I find the close price for an entry matching a custom DB
How to download data for selected symbols ?
How is buy/sell price calculated when running a backtest?
How to read the number of positions in trading system

Blog Posts
How to create a trading system, screen and composite using earnin...
How to Download Trading Data for Certain Securities Only
Step by step on how to get free realtime/delayed data for stocks,...
How to create buy and sell trading rules based on News Data
How to Automatically Import Local Data Into QuantShare









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.