|
|
SGT_FW
by Aku_Aku. 06/02/25 17:54
|
|
|
|
|
|
|
0 registered members (),
357
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Difficulty in Making Series from CSV
#488662
03/16/25 14:35
03/16/25 14:35
|
Joined: Apr 2023
Posts: 56
vicknick
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2023
Posts: 56
|
So after getting the prices from my CSV file, I am able to place the prices into the series. This series prints out the correct prices.
vars readLatestPrices(string AssetName)
{
string FilePath = strf("C:\\Users\\chu_h\\Desktop\\output\\%s.csv", AssetName);
string content = file_content(FilePath);
.....rest of the code
vars ClosePrice= series(0, 1500);
int i, idx;
for(i = 0; i < size; i++) {
idx = (head - 1 - i + 1500) % 1500;
ClosePrice[i] = Prices[idx];
}
int i;
for(i = 0; i < 10; i++) {
printf("#Prices[%d] = %.6f\n", i, ClosePrice[i]); //Prints correct latest 10 prices
}
return CloseSeries;
}
However, when I try to use this prices series to create another series, Zorro doesn't seem to go though the series, and instead it remain at the latest price.
vars Prices = readLatestPrices("GC_J"); //This gives the correct price series
vars PricesDiff = series(Prices[0] - Prices[1]); //This always give same value, for example if ClosePrice[0]-ClosePrice[1] = 10, the series will just be 10,10,10,...
// Print the 10 most recent PricesDiff
printf("\n#Asset: %s - Latest 10 PricesDiff (newest first):\n", "GC_J");
int i;
for(i = 0; i < 10; i++) {
printf("#PricesDiff[%d] = %.6f\n", i, PricesDiff[i]);
}
The resulting PricesDiff series is such: #Asset: GC_J - Latest 10 PricesDiff (newest first):
PricesDiff[0] = 10
PricesDiff[1] = 10
PricesDiff[2] = 10
PricesDiff[3] = 10
PricesDiff[4] = 10
PricesDiff[5] = 10
PricesDiff[6] = 10
PricesDiff[7] = 10
PricesDiff[8] = 10
PricesDiff[9] = 10 It only prints out the difference of the first and second element (ClosePrice[0]-ClosePrice[1]), which is 10 in this case. This is in contrast when Zorro get the price from T6, which Zorro will automatically loop through the previous series value to fill in the series. Is there a way to make Zorro loop through CloseSeries to get correct PricesDiff, instead of having to rewrite the code with "for" loop to fill the series?
Last edited by vicknick; 03/16/25 14:59.
|
|
|
Re: Difficulty in Making Series from CSV
[Re: AndrewAMD]
#488669
03/19/25 04:22
03/19/25 04:22
|
Joined: Apr 2023
Posts: 56
vicknick
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2023
Posts: 56
|
Thanks for your suggestion, but I think it's getting a bit off topic here. The CSV data has been tested to load successfully.
I just want to know if its appropriate to use for loop to create a secondary series based on a first series, since Zorro is not able to increment in this case.
Last edited by vicknick; 03/19/25 04:23.
|
|
|
Re: Difficulty in Making Series from CSV
[Re: vicknick]
#488671
03/19/25 11:13
03/19/25 11:13
|
Joined: Apr 2023
Posts: 56
vicknick
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2023
Posts: 56
|
The problem is not about shifting, but about series giving the wrong value: vars Prices = readLatestPrices("GC_J"); //This gives the correct price series
vars PricesDiff = series(Prices[0] - Prices[1]); //will just be 10,10,10,... However, if I manually loop through the Prices series to create PriceDiff, I get the correct values: vars Prices = readLatestPrices("GC_J"); //This gives the correct price series
vars PricesDiff = series(0);
int i;
for(i = 0; i < LookBack; i++) PricesDiff[i] = Prices[i] - Prices[i+1]; //will be 10, 3, -5, 4,... I think it's appropriate to do so right?
Last edited by vicknick; 03/19/25 11:25.
|
|
|
|