Oh no, not another python backtester...

Discussion in 'App Development' started by globalarbtrader, Dec 18, 2015.

  1. Hi GAT,

    How can one insert a rule into pysystemtrade that results in a long position if greater than e.g., 5 day simple moving average and short if below? This is of course not what I am directly trying to test, but I found it embarrassing that I cannot seem to code such a simple thing into pysystem trade.

    I've tried:

    def trend(price):
    trend = pd.DataFrame(np.where(pd.rolling_mean(price,5)>0,1,-1),index=price.index,columns=price.columns)
    return trend
     
    #81     Oct 5, 2017
  2. This is a python / pandas issue rather than with pysystemtrade, but as I'm a nice guy who likes to show off how pythonic I can be:

    trend=price - price.rolling(5).mean()
    position=trend.apply(lambda x:1 if x>0.0 else -1)

    GAT
     
    #82     Oct 9, 2017
    AvantGarde likes this.
  3. traider

    traider

    Can I check if risk free rate is used in the calculation of sharpe ratio in pysystemtrade? From reading the code it doesn't seem to be. Is there a reason to include it vs not including?
    Can you elaborate roughly how the mean return for futures investment calculated since they are leveraged products?
    Thanks!
     
    #83     Nov 17, 2017
  4. No futures returns are already excess returns so you don't subtract rf. Any interest on unused margin would need to be added on.

    GAT
     
    #84     Nov 18, 2017
  5. traider

    traider

    I'm getting an error
    ImportError: cannot import name 'align_to_joint'

    from syscore.pdutils import align_to_joint, uniquets, divide_df_single_column

    I checked the pdutils file but it doesn't seem to have the align_to_joint.
    Does anyone know how to resolve this?
     
    #85     Nov 19, 2017
  6. which script are you trying to run? i f i remember correctly the core of pysystemtrade is solid (i'm using parts in my core system) but periphery scripts require some tweaks due to changes made during refactoring. If you do fix them up, please push them back to upstream
     
    #86     Nov 20, 2017
  7. Yes, on the 'to do' list is to move all the examples out to a different library apart from the core ones that belong to the instructions.

    GAT
     
    #87     Nov 20, 2017
  8. traider

    traider

    In function
    get_cash_costs(self, instrument_code):

    Does anyone know the difference between
    value_of_block_commission vs value_of_pertrade_commission ?

    For example JPY futures, value block is $2.46 which coincides with the comm charged by IB.
    wholesystem.py inside mythbusting folder.
    My current workaround is to just comment it out, realized that this script doesn't use those fn
     
    #88     Nov 20, 2017
  9. Per trade is a cost per trade, regardless of size.
    Per block is a cost that scales with the number of contracts traded.

    GAT
     
    #89     Nov 21, 2017
  10. djames

    djames

    Hi GAT, I have a simple question regarding the forecast position of pysystemtrade.

    I'm using close prices and therefore pysystemtrade spits out a position to take for the day of the close price. Is there a function which gives me a position to take for the next day? Or do you use these positions to put on at the open of next trading day?
     
    #90     Nov 21, 2017
    shuraver likes this.