Oh no, not another python backtester...

Hi GAT, thanks for releasing pysystemtrade to the great unwashed. finding it
very educational.

I'm trying to recreate the included data. The file EDOLLAR_price.csv currently
has a last entry of "2016-07-08,98.9725" I understand that we are looking at
around 40 months out on the curve so i would expect the contract to be one of
201906, 201909, 2019012

Looking at Quandl CME data 201906 gives last price on our date of 2016-07-08
201906 98.98. But where does the price actually come from? is it your last
sampled price from IB?

I'm begining to create my own Panama adjusted price series and am using the
included price csv's as reference.

Any tips and pointers for this process? Would it be possible to give the
contracts which forms each of the price series files?

When reconstructing the carry files should I be rolling them on volume for the
carry contract or price contract? This sould be easier to check as I have the
source contracts in the file by construction.

Kind regards,
D


The carry data file gives the current contracts being used for prices

So for example in here:

https://github.com/robcarver17/pysystemtrade/blob/master/sysdata/legacycsv/EDOLLAR_carrydata.csv

The final row (#8646) has a price contract of 201909 and a price of 98.1175. The carry contract is 201906.

Then in the price file there is the same price (at the end of these files the current adjusted price will always ). That price will be the closing price from IB on that day, which should be the same as quandl although obviously no guarantee.

The rolling is done on a constant maturity basis, adjusted in earlier years if there isn't liquidity far enough out on the curve.

I'm hoping to publish an extension to pysysystemtrade that creates this data, after pulling individual contracts from quandl, plus explanatory blogpost.

GAT
 
Hi GAT, Why do the returns and metrics in pysystemtrade change so markedly if you change the base currency? Shouldn't the returns be similar for various currencies given they are mostly USD instruments and most of the account stays in cash? The vol is often much lower than target vol when using non-USD currency balances. How do you grapple with this?

I've looked into this and I can't repeat the problem, nor can I see any obvious bugs that might be the cause. For example with USD and GBP I get sharpe ratios within 0.02 of each other. There are still some small differences as you'd expect for the following reasons:

The main difference is with euros as the base currency you only have the FX history since 1999 so a lot of the earlier back test vanishes.

The concept of "cash" is irrelevant since the backtest doesn't know about margin. Obviously if you have £1,000,000 that will give you different positions to having $1,000,000; and the difference will vary over time as those amounts are different. Plus profits will be daily marked to market into the base currency and so will be different.

The differences are smaller if you use roundpositions=False when doing accounting or turn off buffering (config.buffer_size=0.0)

Small amounts of capital and rounded positions combined with buffering may lead to weird non linearities where you have a position in one currency but not in another which could be a cause of lower vol.


GAT.
 
The carry data file gives the current contracts being used for prices

I'm hoping to publish an extension to pysysystemtrade that creates this data, after pulling individual contracts from quandl, plus explanatory blogpost.

GAT

I look forward to the extension (and blogpost). Would be reassuringly complete to have the stitching code for the example data files. Thanks
 
Hi GAT,

I notice a bug(?) in pysystemtrade.

Code:
system.accounts.portfolio(roundpositions=False,delayfill=False)

>>> system.data.daily_prices("GBP").tail(10)
Loading csv data for GBP
2017-01-05    1.2427
2017-01-06    1.2293
2017-01-09    1.2178
2017-01-10    1.2179
2017-01-11    1.2223
2017-01-12    1.2178
2017-01-13    1.2200
2017-01-16       NaN <-------- Holiday
2017-01-17    1.2411
2017-01-18    1.2352

>>> system.accounts.get_notional_position("GBP").tail(10)
2017-01-05   -84.629566
2017-01-06   -77.148345
2017-01-09   -75.307283
2017-01-10   -78.993038
2017-01-11   -81.460877
2017-01-12   -85.617533
2017-01-13   -88.694337
2017-01-16   -88.694339
2017-01-17   -86.485507
2017-01-18   -88.339476

>>> system.accounts.pandl_for_instrument("GBP").tail(10)
2017-01-05    -7555.350031
2017-01-06    10596.153621
2017-01-09     8760.748599
2017-01-10      -72.328423
2017-01-11    -2942.568750
2017-01-12     3170.171272
2017-01-13    -1588.764330
2017-01-16        0.000000
2017-01-17        0.000000 <-------- not supposed to be zero
2017-01-18     4656.453583
 
Hi GAT,

I notice a bug(?) in pysystemtrade.

Code:
system.accounts.portfolio(roundpositions=False,delayfill=False)

>>> system.data.daily_prices("GBP").tail(10)
Loading csv data for GBP
2017-01-05    1.2427
2017-01-06    1.2293
2017-01-09    1.2178
2017-01-10    1.2179
2017-01-11    1.2223
2017-01-12    1.2178
2017-01-13    1.2200
2017-01-16       NaN <-------- Holiday
2017-01-17    1.2411
2017-01-18    1.2352

>>> system.accounts.get_notional_position("GBP").tail(10)
2017-01-05   -84.629566
2017-01-06   -77.148345
2017-01-09   -75.307283
2017-01-10   -78.993038
2017-01-11   -81.460877
2017-01-12   -85.617533
2017-01-13   -88.694337
2017-01-16   -88.694339
2017-01-17   -86.485507
2017-01-18   -88.339476

>>> system.accounts.pandl_for_instrument("GBP").tail(10)
2017-01-05    -7555.350031
2017-01-06    10596.153621
2017-01-09     8760.748599
2017-01-10      -72.328423
2017-01-11    -2942.568750
2017-01-12     3170.171272
2017-01-13    -1588.764330
2017-01-16        0.000000
2017-01-17        0.000000 <-------- not supposed to be zero
2017-01-18     4656.453583

Probably a subtle date / time alignment; I've raised an issue

https://github.com/robcarver17/pysystemtrade/issues/48

Thanks
GAT
 
Thanks for the reply (in Jan), I'm starting with recreating the carry data as this seems simpler.

If I remember correctly, you said that you are not rolling with fixed rules, that there is some discretion applied as to when contracts are rolled.

Does this mean that the carry data files provided in pysystemtrade show the
dates of when each of your active instruments were rolled? Meaning you are recording the date when the roll is initiated for use in constructing backtest data.

For data which is outside of the date range your system has been live and rolling, how did you come up with the roll dates? Are these roll dates volume based or bid ask spread based?

Regarding this reply:

The carry data file gives the current contracts being used for prices

The final row (#8646) has a price contract of 201909 and a price of 98.1175. The carry contract is 201906.

Then in the price file there is the same price (at the end of these files the current adjusted price will always ). That price will be the closing price from IB on that day, which should be the same as quandl although obviously no guarantee.

GAT

Do the change in carry pair dates indicate points in the price file where panama adjustment is applied?
 
Last edited:
Thanks for the reply (in Jan), I'm starting with recreating the carry data as this seems simpler.

If I remember correctly, you said that you are not rolling with fixed rules, that there is some discretion applied as to when contracts are rolled.

Does this mean that the carry data files provided in pysystemtrade show the
dates of when each of your active instruments were rolled? Meaning you are recording the date when the roll is initiated for use in constructing backtest data.

Yes since around January 2014 these are actual roll dates.

For data which is outside of the date range your system has been live and rolling, how did you come up with the roll dates? Are these roll dates volume based or bid ask spread based?

They are based on a fixed time before the expiry date, with adjustments to those dates when there isn't a sychronous price between the current and new contracts.

Regarding this reply:
..,


Do the change in carry pair dates indicate points in the price file where panama adjustment is applied?

Yes

GAT
 
Hi GAT,
I was wondering if there is a feature in pysystemtrade to be able to conduct portfolio attributions?
Also, have you ever experimented with 'value' rules in futures markets?
Thanks!
 
Hi GAT,
I was wondering if there is a feature in pysystemtrade to be able to conduct portfolio attributions?
Also, have you ever experimented with 'value' rules in futures markets?
Thanks!

Depends what you mean by 'attributions'. There is a lot of diagnostics in the accounting stage but if you mean something distinct perhaps you could give an example?

'Value' as distinct from carry I'm not sure what that means in futures. If you mean the definition used by Anti Illmanen, which is a long run mean reversion to an equilibrium, then:

a) for absolute value (reversion to the univariate equilibrium for that instrument) I haven't looked at it because the time scales involved mean it isn't statistically significant
b) for relative value (say within asset class) then yes, I actually use this myself

GAT
 
Back
Top