Author Topic: Some questions on the statistics  (Read 11321 times)

Max Mayhew

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Some questions on the statistics
« on: May 25, 2017, 07:19:08 pm »
Hi Admin,

Just want to say first off, congrats, what a fantastic tool you have created and what a brilliant resource. I can only applaud you here, truly,

Secondly, I have some questions regarding clarification of some statistical terms; I have studied mathematics at University but never applied it to trading in this way, so if possible could I have clarification on the purpose of these tests and their significance? I apologise in advance if these seem very infant queries, but I have been searching the web for answers for days and am hoping you may be able to help!

1) Orthogonal regression (I can see regression co-efficient of alpha and beta, but why are these relevant?
What does the mean reversion co-efficient represent? What is the value we would want to see? And why the half life?)

2) What exactly is the autocorrelation PACF graph showing us (not understanding the 'lag' axis).

3) Engle Granger Co-integration test I understand, but why do we see the squared values of the regression, what should we be looking for here?


admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #1 on: May 29, 2017, 05:21:57 am »
Hello Max!

Thanks for nice words! Now, about your questions:

1) Orthogonal Regression - just presented as an additional layer of visualizing relationship between two instruments. The advantage is that the beta coefficient is the same (with flipped sign of the exponent) if you switch the order of both variables. Half-life is just an additional measure to see how fast the relation ship reverts to the mean. Orthogonal regression is not really used for pair trading - it is just an additional measure to explore the relationship. PTL analyses are not only used by pair traders, they are also used by students and university teachers (econometric, ...), who want to see these extra measures...

2) The PACF is just a visual indication of the amount of autocorrelation in the data. Autocorrelation above/below confidence intervals is non-random and invalidates cointegration results unless it is adjusted for by lagging the data and rerunning a
series of regressions. You can use PACF as an additional filter if you use correlation (ADF test). PACF result above confidence threshold may invalidate the whole ADF result...

3) R-Squared is provided as an additional measure. More info for instance here:
https://www.quora.com/What-is-cointegration-of-time-series-data-in-statistics
If you google for "cointegration r-squared" you will find even more resources.

Kind regards,
Karel

Max Mayhew

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Some questions on the statistics
« Reply #2 on: September 14, 2017, 10:41:53 am »
Hi Again!

Just another few questions (sorry):

1) What time frame is your backtesting facility used on (daily, 4hr, 1hr etc)?

2) When opening a position, I remember reading somewhere (perhaps here) that the open and close price of the trades are based solely on the open and close price of the assets traded? My question really is, are trades triggered intraday or only when the market opens and when the market closes?

Thank you in advance!

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #3 on: September 14, 2017, 03:51:57 pm »
Hello!

1) daily
2) stats (moving average, std dev) are determined using EOD close prices; signals to enter/exit are determined using real-time bid/ask prices (intraday)

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #4 on: September 14, 2017, 03:54:51 pm »
in addition to #2 - you can limit the time period where signals are evaluated (for instance - last 10 minutes before market close)

maybe this could be useful to you: https://www.pairtradinglab.com/faq#pairs-trading-eod-intraday

Max Mayhew

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Some questions on the statistics
« Reply #5 on: September 20, 2017, 09:34:14 am »
Legend!

Last question (I hope, sorry), if using 100% margin, how are the pair trade sizes calculated in a portfolio. I have calculated a portfolio of 3 pairs, one of those pairs is using 9k (of 100k) per trade, another pair is using 36k, what would be the rationale behind this?

Thanks

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #6 on: September 23, 2017, 12:28:56 pm »
Hello!

Margin allocation is explained here: https://wiki.pairtradinglab.com/wiki/Pair_Trading_Lab_Portfolios

If you think your portfolio is not set up correctly, please create a ticket in Helpdesk, describing the problem in detail (including the portfolio name), we will take a look!
Thanks!
Karel

Max Mayhew

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Some questions on the statistics
« Reply #7 on: September 26, 2017, 06:22:59 am »
Hi thank you
I have opened a ticket!

Max

Max Mayhew

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Some questions on the statistics
« Reply #8 on: September 29, 2017, 06:36:46 am »
Hi,

Quick question on the EOD and intraday:

You said "stats (moving average, std dev) are determined using EOD close prices; signals to enter/exit are determined using real-time bid/ask prices (intraday)".

Am I understanding that you use EOD to calculate things such as Z score etc, if a price at the EOD moves the Z score above an entry threshold, will your backtests enter the moment the market opens? If price has moved to a point where entry threshold is breached but the market is now closed because it is the EOD, when will it then trigger this trade?

Thank you!

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #9 on: September 29, 2017, 09:07:46 am »
Hi,

for instance the Ratio model:
  • the moving average and standard deviation is calculated each day based on EOD prices
  • then the immediate Z-Score is calculated using the precomputed moving average, standard deviation AND real-time bid/ask prices

JackBeach

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
Re: Some questions on the statistics
« Reply #10 on: July 17, 2022, 08:04:58 pm »
Hi, PTL Team,

Is the real-time bid/ask spread really happening in real-time in PTL Trader, or let's say every 1, 2 or 3 seconds.?

I'm trying to see if it really makes sense to have the lowest latency possible in my setup.
« Last Edit: July 17, 2022, 08:08:10 pm by JackBeach »

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #11 on: July 18, 2022, 03:21:38 am »
Well the bid-ask spread definitely exists :) This is a property of every market. I don't understand the part about 1 -2 - 3 seconds.

JackBeach

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
Re: Some questions on the statistics
« Reply #12 on: July 18, 2022, 06:03:38 am »
Hi, Karel.

Simply put, I would like to know how fast (how frequent) PTL is polling the data during trading.
I'm not doubting at all the "real-time"-ness of PTL, I'm just interested in knowing how often PTL is getting the data from IB?

Example: Is PTL polling the real-time data every 100ms, 500ms, 1 sec...?
« Last Edit: July 18, 2022, 06:07:29 am by JackBeach »

admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 338
  • Karma: +13/-0
    • Pair Trading Lab
Re: Some questions on the statistics
« Reply #13 on: July 18, 2022, 08:33:01 am »
PTL Trader uses streaming interface for bid & ask prices, so it depends on the IB system if it applies any throttling or not. In theory it can be <50ms latency.

JackBeach

  • Newbie
  • *
  • Posts: 23
  • Karma: +1/-0
Re: Some questions on the statistics
« Reply #14 on: July 18, 2022, 08:42:53 am »
That's really amazing.

Thank you so much for your reply!