Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, bigsmack), 1,667 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Data from CSV not parsed correctly #488197
04/18/24 10:45
04/18/24 10:45
Joined: Apr 2024
Posts: 6
Germany
E
EternallyCurious Offline OP
Newbie
EternallyCurious  Offline OP
Newbie
E

Joined: Apr 2024
Posts: 6
Germany
Hello everybody,


I am having trouble to convert a CSV file to a .t1 file. When I print the parsed values, none of the columns is being correctly parsed and I don't receive any warning or error message.

The CSV file has following format:

Code
Time,AskPrice,BidPrice
1704213005783,49.20,49.10
1704213006179,49.22,49.13
1704213006575,49.23,49.13
1704213007576,49.24,49.13


I use following lines to parse the file:

Code
string Format = "+%t,f,f";

int Year;
for(Year = 2024; Year <= 2024; Year++) {
	dataNew(1,0,0);
	int records = dataParse(1,Format,strf(CSVFileName,Year), 0, 0);
	printf("\n%i - %d rows read",Year,records);

	dataNew(2,0,0);
	int i, N = 0;

	for(i = 0; i < records; i++) 
	{
		var time = dataVar(1,i,0);
		var askPrice = dataVar(1,i,1);
		var bidPrice = dataVar(1,i,2);
		printf("%s: %.2f, %.2f\n", strdate("%Y.%m.%d %H:%M:%S.", time), bidPrice, askPrice);
		
		T1* Quote = dataAppendRow(2,2);
		Quote->time = time;
		Quote->fVal = -bidPrice;
		Quote = dataAppendRow(2,2);
		Quote->time = time;
		Quote->fVal = askPrice;
		N += 2;
	}

	dataSave(2,strf(OutName,Year), 0, N); // store year dataset
	printf("\n%s saved",strf(OutName,Year));
}



Can somebody help me to find the problem?

I attached a sample CSV file and the complete code.


Best regards,

EC

Attached Files
TQQQ_2024.csv (3 downloads)
_EC_CSVToTicks2.c (2 downloads)
Last edited by EternallyCurious; 04/19/24 06:41.
Re: Data from CSV not parsed correctly [Re: EternallyCurious] #488201
04/20/24 08:32
04/20/24 08:32
Joined: Jul 2000
Posts: 27,987
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,987
Frankfurt
The time conversion does not look right.

Re: Data from CSV not parsed correctly [Re: EternallyCurious] #488207
04/20/24 21:39
04/20/24 21:39
Joined: Apr 2024
Posts: 6
Germany
E
EternallyCurious Offline OP
Newbie
EternallyCurious  Offline OP
Newbie
E

Joined: Apr 2024
Posts: 6
Germany
What exactly do you think it does not look well with the time?

I use %t because the first column has Unix format in milliseconds. It is described in the "Dataset handling" section of the Zorro documentation.

Code
%t - for a date/time field in Unix format, either seconds or milliseconds since January 1,1970.

Re: Data from CSV not parsed correctly [Re: EternallyCurious] #488215
04/25/24 10:20
04/25/24 10:20
Joined: Apr 2024
Posts: 6
Germany
E
EternallyCurious Offline OP
Newbie
EternallyCurious  Offline OP
Newbie
E

Joined: Apr 2024
Posts: 6
Germany
I attached the text from the output window.

Attached Files
Log.png (22 downloads)
Re: Data from CSV not parsed correctly [Re: EternallyCurious] #488224
04/26/24 11:18
04/26/24 11:18
Joined: Jul 2000
Posts: 27,987
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,987
Frankfurt
The time and all other variables are zero. So the first step is debugging the conversion and checking the content of the dataset. Debugging is explained in the manual under "troubleshooting".

If you still cannot find the reason and want individual support, you could either subscribe a premium support ticket, or simply hire a programmer to write the conversion script for you. The current fee for a CSV -> t1 conversion, as to my knowledge, is 120 EUR.

Re: Data from CSV not parsed correctly [Re: EternallyCurious] #488242
05/06/24 18:50
05/06/24 18:50
Joined: Aug 2016
Posts: 66
D
dr_panther Offline
Junior Member
dr_panther  Offline
Junior Member
D

Joined: Aug 2016
Posts: 66
I've observed that when converting CSV data to T6 format, the datetime parameter appears as a decimal value. The integer part before the dot represents the number of days since January 1, 1900. The fractional part after the dot represents the time of the day in decimal format. For example, 45000.5 corresponds to 45,000 days after January 1, 1900, at 12 noon.

And keep in mind for t1, stand for time plus one data point, which is either ask or bid price, you don't have three field to populate.
Ask and bid prices are represented by positive / negative values. Check the manual for details: https://zorro-project.com/manual/en/history.htm

typedef struct T1
{
DATE time; // UTC timestamp of the tick in DATE format
float fPrice; // price data, positive for ask and negative for bid
} T1;


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1