Strategy testing with Candles from csv file

Strategy testing with Candles from csv file
Atom
4/24/2017
Shubha


We want to perform strategy backtesting on history data stored in txt file. As we understand from the samples, the txt file should be converted to S# format before we can run strategy and testing on them. Please update if this understanding is correct.

We need sample code how we can covert txt file to S# format through code. What are the classes we should look at?

Or alternatively, can we run strategy on history data stored in txt file directly? Please share sample code if this is possible.

Regards
Shubha



Thanks:


1 2  >
Support

Avatar
Date: 4/25/2017
Reply


Send an example of your txt file.
Thanks:

Shubha

Avatar
Date: 4/25/2017
Reply


Hello,

Attaching txt file where the history data is stored. Data is stored in the format date, time, O, H, L, C and Volume values separated by comma.

Thank you.
ACCN.txt 457 KB (542)
Thanks:

Support

Avatar
Date: 4/26/2017
Reply


Ok, we will prepare an example for you.
Thanks:

Shubha

Avatar
Date: 4/27/2017
Reply


Hello! Looking forward for the example code as mentioned above, it will be really helpful.

Thank you.
Thanks:

Support

Avatar
Date: 4/28/2017
Reply


The optimal solution is to convert your data into the s# candle format of the store. An example of a converter is attached.
CandleConverter.7z 115 KB (548)
Thanks:

Shubha

Avatar
Date: 5/3/2017
Reply


Thank you for the code. We have multiple files where the 5 minute candle data is stored for each stock on the exchange. Please recommend the best approach for running strategy on these files.

One solution is to convert all of these data to S# bin format as you have specified above. Please let me know if there are other approaches we can consider.

Thank you,
Thanks:

Support

Avatar
Date: 5/3/2017
Reply


Ok.
Thanks:

Shubha

Avatar
Date: 5/10/2017
Reply


Hello,

I am trying to run a simple SMA strategy on the converted candles using HistoryEmulationConnector on the Data folder. I am specifially using the sample code in the Lesson Video 8 - TestingAndTrading sample.

The sample works fine and shows the PnL curve when using the sample code and sample data provided with the examples.

string path = Path.GetFullPath(@"..\..\..\..\History\");
((LocalMarketDataDrive)storage.DefaultDrive).Path = path;

// создаем инструмент для тестирования
_security = new Security
{
Id = "RIM5@FORTS",
Code = "RIM5",
Name = "RTS-6.15",
PriceStep = 10,
StepPrice = 2,
Board = ExchangeBoard.Forts
};

When I change the code to point to the converted candles data folder, it does not work.

string path = Path.GetFullPath(@"..\..\..\..\History\");
string path = Path.GetFullPath(@"C:\Data\NETProjects\StockSharp\ExampleStrategy\CandleConverter\bin");

*_security = new Security
{
Id = "ACCN@NYSE",
Code = "ACCN",
Name = "ACCN",
PriceStep = 10,
StepPrice = 2,
Board = ExchangeBoard.Nyse
};

The strategy just does not execute. It does not hit the code for Onstarted of strategy and ProcessCandle.

Please advise what is missing in the data that is converted.

Thank you!
Thanks:

Shubha

Avatar
Date: 5/10/2017
Reply


Hello,

I am trying to run a simple SMA strategy on the converted candles using HistoryEmulationConnector on the Data folder. I am specifially using the sample code in the Lesson Video 8 - TestingAndTrading sample.

The sample works fine and shows the PnL curve when using the sample code and sample data provided with the examples.

string path = Path.GetFullPath(@"..\..\..\..\History\");
((LocalMarketDataDrive)storage.DefaultDrive).Path = path;

// создаем инструмент для тестирования
_security = new Security
{
Id = "RIM5@FORTS",
Code = "RIM5",
Name = "RTS-6.15",
PriceStep = 10,
StepPrice = 2,
Board = ExchangeBoard.Forts
};

When I change the code to point to the converted candles data folder, it does not work.

string path = Path.GetFullPath(@"..\..\..\..\History\");
string path = Path.GetFullPath(@"C:\Data\NETProjects\StockSharp\ExampleStrategy\CandleConverter\bin");

*_security = new Security
{
Id = "ACCN@NYSE",
Code = "ACCN",
Name = "ACCN",
PriceStep = 10,
StepPrice = 2,
Board = ExchangeBoard.Nyse
};

The strategy just does not execute. It does not hit the code for Onstarted of strategy and ProcessCandle.

Please advise what is missing in the data that is converted.

Thank you!
Thanks:

Shubha

Avatar
Date: 5/10/2017
Reply


Hello,

Also, when I try to create a candle chart with the above data containing ACCN@NYSE folder, it does not create any candles. I am using SampleChart sample from Samples/Chart/Sample example that comes with the SDK. It is not able to plot the chart when I point the folder to the right folder and update the security details.

I am not sure why the data is not being read to create a chart. Maybe this is the reason why strategy is not run. Because it is not able to read the candles. Please let me know what am I missing.

Thank you.
SampleChart.png 133 KB (486)
Thanks:
1 2  >

Attach files by dragging & dropping, , or pasting from the clipboard.

loading
clippy