-5

There is a documentation for backtesting in R in GitHub(https://timtrice.github.io/backtesting-strategies/).

I have a query in two lines of code mentioned in this document (https://timtrice.github.io/backtesting-strategies/using-quantstrat.html#settings-and-variables).

First line

Sys.setenv(TZ = "UTC")

Second line

currency('USD')

As you can see, the first line sets - system time to the US and the second line - sets the currency in which trading is occurring to the US. I am an Indian Trader and my job is to do back-testing with equity data for Indian companies. I use quantstrat and quantmod packages along with its dependencies. The data is downloaded from Yahoo Finance through R platform.

  • What is the argument should an Indian trader pass to both these functions(Sys.setenv and currency)???. The currency of Indian market is INR(Indian Nation Rupees) and the time of India is GMT+5:30

I have tried to pass the argument "GMT+5:30" to Sys.setenv function and it turned back an error. But when i tried to pass GMT, there was no error. But Indian timing is GMT+5:30.

Community
  • 1
  • 1
Praveen Kumar-M
  • 223
  • 2
  • 10
  • I do not have an answer to your question. However, for one, I see your question got down-voted multiple times without explanation, showing people's poor behaviour without helping you. Besides that, about your question: one of the things I miss most is "what have you tried yourself to solve this problem"? Additionally, I see you're linking to a github page, and mention two lines of code that I can't find on the first tab of that page. Perhaps be more precise in your info, and perhaps have a have a look at [how to ask a good question](https://stackoverflow.com/help/how-to-ask). Good luck. – 4rj4n Apr 16 '18 at 08:34
  • 1. UTC is not US time, but is [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) or GMT. Download a test file with historic data and see how the date-time looks like. In most cases UTC should be fine as this overwrites your default pc settings which may cause errors. 2. Check on Yahoo in which currency the stock is reported. If in INR, set currency to INR, if in Dollars, set currency to USD. – phiver Apr 16 '18 at 08:57
  • Thank you so much 4rj4n for your suggestion. I have made the modification. I will improve my style of asking question. Thanks phiver for your answer. And also thanks to people who downvoted me, as always. – Praveen Kumar-M Apr 16 '18 at 09:17
  • Check ?Sys.setenv() to see what the input should be. For instance, shouldn't you use one of the standard time zone abbreviations instead of GMT+5:30? – 4rj4n Apr 16 '18 at 10:20
  • I found the answer. For determining the time zone, type `OlsonNames()` in R. You will get a comprehensive list of timezones. Among that, please choose the specific one according to your timezone. So for me(Indian trader), it would be `Sys.getenv("Asia/Kolkata")` For the currency, please set it as `currency("INR")` . I thank Ilya Kipnis for help in arriving at solution. – Praveen Kumar-M Apr 16 '18 at 14:51

1 Answers1

0

I found the answer. For determining the time zone, type OlsonNames() in R. You will get a comprehensive list of timezones. Among that, please choose the specific one according to your timezone. So for me(Indian trader), it would be Sys.getenv("Asia/Kolkata") For the currency, please set it as currency("INR") . I thank Ilya Kipnis - for helping in arriving at solution.

Praveen Kumar-M
  • 223
  • 2
  • 10