Page 1 of 1

Min Spread is less than zero on export

Posted: Sat Jan 27, 2024 10:33 am
by Reg
I just moments ago downloaded BTCUSD and then exported it to a custom CSV with the format:

Code: Select all

{BarBeginTime:yyyyMMdd},{BarBeginTime:HH:mm:ss},{Open},{High},{Low},{Close},{Volume},{BarMinSpread},{BarMaxSpread}
Looking a sample of the output I see this:

Code: Select all

Date	Timestamp		Open	High	Low	Close	Volume		Min Spread	Max Spread
20170704	12:00:00 AM	2546.6	2554.3	2543.9	2554.3	11.2306000571698	0	11.4
20170704	12:15:00 AM	2551.2	2561.9	2550.9	2560	17.8153000774328	0	9.1
20170704	12:30:00 AM	2560	2569.1	2551.7	2567.7	25.8040001278277	0	10.7
20170704	12:45:00 AM	2567.8	2570.7	2559.9	2565.5	29.1118001332507	0	13.4
20170704	01:00:00 AM	2565.7	2570.5	2559.9	2566.2	15.9826000905596	0	8.5
20170704	01:15:00 AM	2566	2573.3	2560.3	2572.7	25.8159001001623	0	7.8
20170704	01:30:00 AM	2572.8	2575.8	2563.5	2575.5	7.76410003285855	0	7.6
20170704	01:45:00 AM	2575.2	2576.6	2565.1	2573.2	21.5881000955123	0	9.7
20170704	02:00:00 AM	2575.1	2579	2566	2575	17.3003000509925	0	9.1
20170704	02:15:00 AM	2577.4	2584	2572	2584	28.4337001298554	0	11.3
20170704	02:30:00 AM	2584	2587.6	2572.7	2587.6	14.5492000537924	0	9.1
20170704	02:45:00 AM	2587.6	2607.5	2587.5	2605.9	21.7363001164049	0	8.6
20170704	03:00:00 AM	2605.9	2608.4	2598.5	2608.3	20.6738000754267	0	7.6
20170704	03:15:00 AM	2608.3	2623.5	2600.5	2622.5	24.4506001002155	0	9.3
20170704	03:30:00 AM	2622.5	2624.2	2611.5	2618.5	20.3595000705682	0	7.1
20170704	03:45:00 AM	2618.5	2623.4	2611.4	2612.7	18.6836001074407	0	6
20170704	04:00:00 AM	2612.1	2620.5	2604.9	2620.5	17.8791000745259	0	6.3
20170704	04:15:00 AM	2620.2	2624.1	2617.2	2618.4	18.0135000804439	0	8
20170704	04:30:00 AM	2618.3	2619.9	2606.4	2607.4	18.0598000807222	0	4.5
20170704	04:45:00 AM	2609.6	2620.1	2606.7	2619	17.692500079982	0	5.4
20170704	05:00:00 AM	2618.8	2621.2	2610.7	2616.9	19.6084000759292	0	5.1
20170704	05:15:00 AM	2619.1	2636	2616.7	2635.3	20.7775000764523	0	6.2
20170704	05:30:00 AM	2635.6	2637.4	2623.3	2629.4	14.2103000590578	0	6.8
20170704	05:45:00 AM	2629.4	2629.4	2617.4	2621.9	14.7335000711028	0	9.2
20170704	06:00:00 AM	2620.5	2622.8	2615	2621.4	14.5279000625014	0	5.4
20170704	06:15:00 AM	2621.7	2623.6	2614.9	2619.6	18.8706000663806	-1.9	9.7
20170704	06:30:00 AM	2620.2	2625.1	2618.1	2624.6	11.9546000561677	0	6.2
20170704	06:45:00 AM	2623.5	2628.8	2620.9	2625.6	24.4566001084168	0	9.8
20170704	07:00:00 AM	2626.1	2630.7	2623.5	2627.8	21.3573000587057	0	8.5
20170704	07:15:00 AM	2625.8	2635.2	2625	2635.1	15.8005000560079	0	6.3
20170704	07:30:00 AM	2634.7	2636.4	2626.1	2630.8	15.6811000606976	0	5.9
20170704	07:45:00 AM	2630	2635.7	2629.5	2630.7	19.5175000794698	0.1	4.5
20170704	08:00:00 AM	2630.5	2631.5	2619.9	2624.1	7.98990002833307	0	9.4
20170704	08:15:00 AM	2624	2625.8	2615.6	2620.1	17.3930000937544	0	5.8
20170704	08:30:00 AM	2620	2621.8	2610.8	2615	23.9847001165617	0	8.4
20170704	08:45:00 AM	2615	2615	2599.8	2605.4	14.4093000497669	0	9.3
20170704	09:00:00 AM	2603.7	2611.5	2598.1	2605.4	12.5252000335604	-3.5	8.8
20170704	09:15:00 AM	2605.5	2610.4	2602.7	2607.5	16.5392000861466	0	7
20170704	09:30:00 AM	2608.3	2615.2	2602	2615.2	30.3673001159914	0	11.6
As you can see some of the Min Spread values are negative numbers. I don't know if this is a bug, bad data, whether I should totally ignore that column because it can't be trusted. I think for now I'll just assume anything negative as zero but I would appreciate knowing the reality behind this so I know correctly how to deal with it.

Re: Min Spread is less than zero on export

Posted: Sat Jan 27, 2024 10:29 pm
by tickstory
Hi Reg,

We can confirm that there is a brief moment where Bid is greater than the Ask price. It is likely a matter of liquidity and is a valid pricing scenario. You should always code for this possibility in your strategy.

Code: Select all

20170704,06:25:58,2619.9,2622.4,2619.9,2622.4,0.0559999998658895,-1.9,0.4
Hope this helps.