Bid Ask History prices?

Created at 07 May 2016, 19:43
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
FM

fm1975a1

Joined 03.04.2016

Bid Ask History prices?
07 May 2016, 19:43


Hello everybody.. Got a bot that exporting chat data to Excel CSV file, the code for it is this:

using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class DumpToCSV : Robot
    {
        protected override void OnStop()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var folderPath = Path.Combine(desktopFolder, "FXP-Files");
            Directory.CreateDirectory(folderPath);
            var filePath = Path.Combine(folderPath, Symbol.Code + " " + TimeFrame + ".csv");
            using (var writer = File.CreateText(filePath))
            {
                for (var i = 0; i < MarketSeries.Open.Count + 1; i++)
                {


                    writer.WriteLine(ConcatWithComma(MarketSeries.OpenTime[i].AddHours(3), MarketSeries.OpenTime[i].AddHours(3).DayOfWeek, MarketSeries.OpenTime[i].AddHours(3).Hour, MarketSeries.Open[i], MarketSeries.High[i], MarketSeries.Low[i], MarketSeries.Close[i], MarketSeries.TickVolume[i]));
                }

                writer.WriteLine("Done.");
                Console.WriteLine("Done.");
            }


        }

        private string ConcatWithComma(params object[] parameters)
        {
            return string.Join(",", parameters.Select(p => p.ToString()));
        }
    }
}


But this one just exporting bid or ask data, and i need both..

Can anyone help? please!..

Also does anyone knows how to view the Console for the cAlgo like with Visual Studio to see all the processes? [i added the "Done" message to the code but i do not see it]


Thanks everybody..


@fm1975a1
Replies

moneybiz
07 May 2016, 23:00

You can use OnTick() event to get the bid and ask prices.
Override the method and then you can get the price pair from Symbol.Bid/Ask object to accomplish what you want.
Then load your bot for backtesting.
From the settings icon choose tick data as source. Then select the date ranges you want the prices for from above (you will see it somewhere over the settings icon) and run the bot.

It will download the ticks for the range from the server and the OnTick() event will fire for each tick received. Save the values to some file.
Don't forget to add "AccessRights = AccessRights.FileSystem" attribute to the top of your robot otherwise you won't be able to access the file system.

If you can't make it I can post my bot that I'm using to do exactly what you're trying to do.

 

public string Delimiter { get; set; }

protected override void OnTick()
{
    base.OnTick();

    var logEvent = $"{Time:yyyy-MM-dd HH:mm:ss.fff}{Delimiter}{Symbol.Bid}{Delimiter}{Symbol.Ask}";
    _writer.WriteLine(logEvent);
}

 


@moneybiz

fm1975a1
09 May 2016, 04:55

RE:

moneybiz said:

You can use OnTick() event to get the bid and ask prices.
Override the method and then you can get the price pair from Symbol.Bid/Ask object to accomplish what you want.
Then load your bot for backtesting.
From the settings icon choose tick data as source. Then select the date ranges you want the prices for from above (you will see it somewhere over the settings icon) and run the bot.

It will download the ticks for the range from the server and the OnTick() event will fire for each tick received. Save the values to some file.
Don't forget to add "AccessRights = AccessRights.FileSystem" attribute to the top of your robot otherwise you won't be able to access the file system.

If you can't make it I can post my bot that I'm using to do exactly what you're trying to do.

 

public string Delimiter { get; set; }

protected override void OnTick()
{
    base.OnTick();

    var logEvent = $"{Time:yyyy-MM-dd HH:mm:ss.fff}{Delimiter}{Symbol.Bid}{Delimiter}{Symbol.Ask}";
    _writer.WriteLine(logEvent);
}

 

Hello and thanks for the reply sir.. The bot you talking about, is it exporting to excel file History prices for time frames i.e. Hourly daily etc.. I got robot that showing the ticks data for both bid and ask, but that is not what i need.. So if this bot can exporting bid and ask history data for some time frame, i'll really like that.. or if there's an option to get tick Bid Ask for very far back, like several years, although it's very unlike cause obviously it's huge amount of data, but if there's, i could code one that break it down to Days or Hours or other Time frames OHLC data..

So thanks again and have a nice day.. much appreciated..


@fm1975a1

moneybiz
11 May 2016, 20:00

RE: RE:

fm1975a1 said:

Hello and thanks for the reply sir.. The bot you talking about, is it exporting to excel file History prices for time frames i.e. Hourly daily etc.. I got robot that showing the ticks data for both bid and ask, but that is not what i need.. So if this bot can exporting bid and ask history data for some time frame, i'll really like that.. or if there's an option to get tick Bid Ask for very far back, like several years, although it's very unlike cause obviously it's huge amount of data, but if there's, i could code one that break it down to Days or Hours or other Time frames OHLC data..

So thanks again and have a nice day.. much appreciated..

 

You can get tick data since 2012 november from cAlgo.
Load your tick saving bot and run backtesting from 2012 november till the current date.

All the tick data will be fed to your bot.

Later with that tick data you can build your own bars of whatever duration you want. You can build 30 seconds bars, 123 ticks bars, etc. but not on cAlgo, you have to make your own tester.

If you want to save bar and tick data together just override OnBar() method and save the last 2 tick data received before OnBar() for close of the previous bar and oppening of the new. You you'll have ticks that close a bar and open a new one.


@moneybiz

fm1975a1
12 May 2016, 10:11

RE: RE: RE:

moneybiz said:

fm1975a1 said:

Hello and thanks for the reply sir.. The bot you talking about, is it exporting to excel file History prices for time frames i.e. Hourly daily etc.. I got robot that showing the ticks data for both bid and ask, but that is not what i need.. So if this bot can exporting bid and ask history data for some time frame, i'll really like that.. or if there's an option to get tick Bid Ask for very far back, like several years, although it's very unlike cause obviously it's huge amount of data, but if there's, i could code one that break it down to Days or Hours or other Time frames OHLC data..

So thanks again and have a nice day.. much appreciated..

 

You can get tick data since 2012 november from cAlgo.
Load your tick saving bot and run backtesting from 2012 november till the current date.

All the tick data will be fed to your bot.

Later with that tick data you can build your own bars of whatever duration you want. You can build 30 seconds bars, 123 ticks bars, etc. but not on cAlgo, you have to make your own tester.

If you want to save bar and tick data together just override OnBar() method and save the last 2 tick data received before OnBar() for close of the previous bar and oppening of the new. You you'll have ticks that close a bar and open a new one.



Hi.. Sorry but i know almost nothing about the cAlgo programming or loading and stuff.. Can you tell me exactly please, how to get that 2012 and on tick data to excel file? i'll take it from there.. 


@fm1975a1

moneybiz
12 May 2016, 11:18 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE: RE: RE:

Hi.. Sorry but i know almost nothing about the cAlgo programming or loading and stuff.. Can you tell me exactly please, how to get that 2012 and on tick data to excel file? i'll take it from there.. 

Click on the marked places.

 


@moneybiz

fm1975a1
14 May 2016, 22:59 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE: RE: RE: RE:

moneybiz said:

Hi.. Sorry but i know almost nothing about the cAlgo programming or loading and stuff.. Can you tell me exactly please, how to get that 2012 and on tick data to excel file? i'll take it from there.. 

Click on the marked places.

 



Okay i tried that, but after clicked that play button it loaded days X / 1300+ days and nothing from there.. I don't know how to operate this cAlgo at all..can you tell me exactly what to do to get the file?.. I got only DumpToCSV bot and one who saves the live ticks to Excel file.. Should i add some other bot or something?..


@fm1975a1

fm1975a1
15 May 2016, 00:23

RE: RE: RE: RE: RE: RE:

This post was removed by moderator.

 


@fm1975a1

moneybiz
16 May 2016, 13:49

RE: RE: RE: RE: RE: RE:

Okay i tried that, but after clicked that play button it loaded days X / 1300+ days and nothing from there.. I don't know how to operate this cAlgo at all..can you tell me exactly what to do to get the file?.. I got only DumpToCSV bot and one who saves the live ticks to Excel file.. Should i add some other bot or something?..

 

I don't that bot. But if it is coded properly it should save all the tick data for 1300+ days. If it doesn't contact the developer.


@moneybiz

fm1975a1
17 May 2016, 04:05

RE: RE: RE: RE: RE: RE: RE:

moneybiz said:

Okay i tried that, but after clicked that play button it loaded days X / 1300+ days and nothing from there.. I don't know how to operate this cAlgo at all..can you tell me exactly what to do to get the file?.. I got only DumpToCSV bot and one who saves the live ticks to Excel file.. Should i add some other bot or something?..

 

I don't that bot. But if it is coded properly it should save all the tick data for 1300+ days. If it doesn't contact the developer.


No it's downloading the data, but Excel CSV file can contain about only 1.048 Million rows, which is just couple of months of data from 2012, and maybe it'll be possible to add another sheets or files, or extend the rows it can contain but then the second problem is that this DumpToCSV bot gives me the OHLC data, which in this all fourth are the same value, and it's not both bid and ask data which is what i need.. and also the CSV file is 2.99GB for just several months of data, so it should be about 50GB of data for 2012-2016 OHLC tick data.. it's all so sucks.. with my former broker, i could download all data with bid and ask prices, even 50 years back of daily OHLC bid and ask, with not all that mess and difficulties.. is there any way to do that here? please?.. 


@fm1975a1

moneybiz
19 May 2016, 23:52

RE: RE: RE: RE: RE: RE: RE: RE:

fm1975a1 said:

No it's downloading the data, but Excel CSV file can contain about only 1.048 Million rows, which is just couple of months of data from 2012, and maybe it'll be possible to add another sheets or files, or extend the rows it can contain but then the second problem is that this DumpToCSV bot gives me the OHLC data, which in this all fourth are the same value, and it's not both bid and ask data which is what i need.. and also the CSV file is 2.99GB for just several months of data, so it should be about 50GB of data for 2012-2016 OHLC tick data.. it's all so sucks.. with my former broker, i could download all data with bid and ask prices, even 50 years back of daily OHLC bid and ask, with not all that mess and difficulties.. is there any way to do that here? please?.. 

I use a database to store the data and call whenever I want whatever date range I want.

In your case the simplest solution would be to write the month by month. Like 2016_01.csv, 2016_02.csv, ...
The data from 2012-11 to 2016-03 is around 2.31GB. Don't try to open that file with notepad or something. Just use code to read from it or seperate everything to monthly files.

In OnTick() event you only need to read the Time, Symbol.Bid and Symbol.Ask values and write them to file.
These 3 values are the only thing you need. I don't know how your bot constructs the OHLC data. You don't need OHLC.


@moneybiz