Fully automated futures trading

Discussion in 'Journals' started by globalarbtrader, Feb 11, 2015.

  1. traider

    traider

    Hi,

    does anyone know why actual positions are really wild at the beginning of historical period? (See JPY below)
    I wouldn't want to hold 100 contracts when trading a new instrument, so am trying to understand this effect.

    Graphed using system.accounts.get_actual_position(instr).plot(title=instr)

    corn.PNG

    wild jpy.png
    Code to replicate, note I added JPY to my system...

    from systems.provided.futures_chapter15.basesystem import futures_system
    from matplotlib.pyplot import show

    system = futures_system(log_level="on")
    print(system.accounts.portfolio().sharpe())
    #system.accounts.portfolio().curve().plot()




    instr = system.get_instrument_list()[1]
    instr = "JPY"
    system.accounts.get_actual_position(instr).plot(title=instr)


    show()
     
    #1611     May 17, 2018
  2. Try plotting the intermediate diagnostics to see where the wildness is coming from. This is also good to understand better what you are doing.

    GAT
     
    #1612     May 18, 2018
  3. traider

    traider

    I checked intermediate stages for JPY and realised a couple of things:

    There isn't carry data at the beginning so forecast weight is set to 0 for carry

    Weights are unstable at beginning even though config is using fixed weights. This is probably due to exponential smoothing of weights. Not sure if this is meant to be as the weight plot was a surprise.
     
    #1613     May 18, 2018
  4. Yes, but that's probably not whats causing it though. Step backwards from the position rather than forwards.

    GAT
     
    #1614     May 18, 2018
  5. traider

    traider

    System position is calculated from formula in book, instrument weight being one of the variables.
    LxMxN

    It's primarily because of volatility scalar (JPY extreme low vol early on)
    Less influence but still a factor is the instrument weighting.
    There is no data for other instruments that early, so JPY weight is entire portfolio.
    instr_weights.PNG vol scalar.PNG volatility.PNG
     
    #1615     May 18, 2018
  6. That makes sense

    GAT
     
    #1616     May 18, 2018
  7. traider

    traider

    Hi

    The carry2 signal in the system doesn't seem to have been scaled by the stdev

    def carry2(raw_carry, smooth_days=90):

    smooth_carry = raw_carry.ewm(smooth_days).mean()

    return smooth_carry


    For JPY,
    JPY raw carry
    2018-05-10 -0.000215
    2018-05-11 -0.000215
    2018-05-14 -0.000216
    2018-05-15 -0.000216
    2018-05-16 -0.000216

    CORN raw carry
    2018-05-10 -37.133632
    2018-05-11 -36.904800
    2018-05-14 -36.638590
    2018-05-15 -36.470717
    2018-05-16 -36.264224


    Not sure if I'm missing something obvious...
     
    #1617     May 20, 2018
  8. The normalisation is done at an earlier stage

    https://github.com/robcarver17/pysystemtrade/blob/master/systems/futures/rawdata.py#L172

    GAT
     
    #1618     May 21, 2018
  9. traider

    traider

    I traced the method, it seems that raw_carry isn't called by the carry rule in futuresconfig.yaml due to the way it is defined
    carry2 calls only rawdata.daily_annualised_roll()

    futuresconfig.yaml
    carry:
    function: systems.provided.futures_chapter15.rules.carry2
    data:
    - "rawdata.daily_annualised_roll"


    When I changed the config to

    data:
    - "rawdata.raw_carry"

    the raw carry forecasts look more correct (ie comparable across instruments)
     
    #1619     May 21, 2018
  10. Now fixed on github. Thanks for finding the error.

    GAT
     
    #1620     May 21, 2018