[R-SIG-Finance] pl() function from PMwR package split an error: 'x' and 'y' lengths differ
Enrico Schumann
e@ @end|ng |rom enr|co@chum@nn@net
Thu Apr 24 21:32:27 CEST 2025
Quoting Arnaud Gaboury <arnaud.gaboury using gmail.com>:
> On Mon, 2025-04-21 at 20:01 +0200, Enrico Schumann wrote:
>> On Mon, 21 Apr 2025, Arnaud Gaboury writes:
>>
>> [...]
>>
>> > Yes, it doesn't spit any error too on my machine. So there is an
>> > issue
>> > in my real data set, no idea where.
>> > Any idea how I can proceed to understand why it works on a short
>> > sample
>> > and not with the whole set ? Any commands I can pass to debug ?
>>
>> Check the dimensions of the inputs: `dim(P)[1]` must be the
>> same as `length(along.timestamp)`.
>>
>> Other than that, do bisection: Try with half the dataset. If
>> that fails, try with a quarter; if half the dataset works,
>> try with three-quarters of the dataset. And so on.
>
> After hours of review, cleaning etc, I finally managed to get the pl()
> function to work correctly and returns the PL as expected.
>
> How do you manage to get such a nice view for PL, as shown on your
> previous email? Did you format it especially for this thread, or do you
> use any kind of package (org ?) to organise and print friendly the PL
> details?
>
> Thank you again for your PMwR package.
>
> ## AAVEUSDC
> ## timestamp 2024-12-16 23:59:59 2024-12-17 23:59:59 [...]
> ## P/L total -4458.4645 -28363.6680 [...]
> ## __ realised 0 0 [...]
> ## __ unrealised -4458.4645 -28363.6680 [...]
> ## average buy 382.4441
> ## average sell NaN
> ## cum. volume 1152.058 1152.058 [...]
> ##
> ## BTCUSDC
> ## timestamp 2024-12-16 23:59:59 2024-12-17 23:59:59 [...]
> ## P/L total -10860.390 -9880.188 [...]
> ## __ realised 0.0000 0.0000 [...]
> ## __ unrealised -10860.390 -9880.188 [...]
> ## average buy 105988.6
> ## average sell 96408.23
> ## cum. volume 9.337211 9.385321 [...]
> ##
> ## ‘P/L total’ is in units of instrument;
> ## ‘volume’ is sum of /absolute/ amounts.
Im glad that it worked. The output is default, though with
a fairly-small `width` set, to which `print.pl` reacts, such as
`options(width = 45)`.
--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net
More information about the R-SIG-Finance
mailing list