Fully automated futures trading

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

  1. Kernfusion

    Kernfusion

    possibly, but we still need to use spread for estimating costs so the relative instrument cost differences will remain the same..
     
    Last edited: Nov 18, 2023
    #3861     Nov 18, 2023
  2. I don't necessarily agree with that. If an instrument has a very narrow spread (think ES) you will most likely pay the bid or ask price when filling an order. However, if an instrument has a very wide spread and you fill mostly between bid and ask then your apparent spread is much smaller than the (bid - ask) spread. Using (bid - ask) results in a too pessimistic, i.e. too expensive, cost estimation. I am not familiar with the OJ contract that you mentioned, so can't judge in what category that would fall.
     
    #3862     Nov 18, 2023
  3. jiikoo

    jiikoo

    Hi all, I'm experimenting with AFTS chapter 25 dynamic optimisation. Scripts are standalone but data for csv's is from pysystemtrade (which is still work in progress). A couple of (beginner) questions:

    Data
    If the scripts are run on pysystemtrade server, how do I pull data from db instead of csv's? Something like "rawdata.get_daily_prices" but didn't get it working.

    From chapter10:
    all_data = dict([
    (instrument_code, pd_readcsv("%s.csv" % instrument_code))
    for instrument_code in instrument_list
    ])

    EU sectors
    Instruments with dash in name (eg. EU-OIL) gives the following error. Tried to escape the dash but no luck so far. How do I get around this?
    SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

    IDM
    To be sure, when I have over 30 instruments but DO gives less than 10 for small capital, is it still safe to use IDM=2.5?

    Instrument weights
    Instead of equal weights, would it be better to use those in provided in rob_system config?

    Rules
    I added multiple carry spans (10,30,60,125 from rob_system) and ewmac 8. Is it possible to add definition of which rules are used for which instruments (so to able to trade faster ewmac)? In addition, is possible to add forecast weights (as in rob_system)?
     
    #3863     Nov 20, 2023
  4. WTF is the 'psystemtrade server'?!

    Can you paste in the exact code you are using to produce this error.

    IDM is the same regardless of whether you subsequently do DO or not

    If you want. Please read everything I've ever written on portfolio optimisation on my blog and in several books to understand why or why not.

    [/QUOTE]

    If you are using pysystemtrade then yes to both, RTFM https://github.com/robcarver17/pysystemtrade/blob/master/docs/backtesting.md

    If you are not, then of course it's possible but you need to write the code yourself to do it.

    Rob
     
    #3864     Nov 20, 2023
  5. jiikoo

    jiikoo

    chapter25.py with following changes, default instruments replaced with EU-OIL

    #) = get_data_dict_with_carry(["sp500", "eurostx", "us10", "us2"])
    ) = get_data_dict_with_carry(["EU-OIL"])

    #asset_class_groupings = dict(bonds=["us2", "us10"], stocks=["sp500", "eurostx"])
    asset_class_groupings = dict(stocks=["EU-OIL"])

    #multipliers = dict(sp500=5, eurostx=10, us10=1000, us2=2000)
    multipliers = dict(EU-OIL=50)

    #instrument_weights = dict(sp500=0.25, eurostx=0.25, us10=0.25, us2=0.25)
    instrument_weights = dict(EU-OIL=1)

    #cost_per_contract_dict = dict(sp500=0.875, eurostx=6.8, us10=9.5, us2=5.5)
    cost_per_contract_dict = dict(EU-OIL=5)

    gives

    multipliers = dict(EU-OIL=50)
    ^
    SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

    Script works with any instrument without dash in the name. Same behavior in notebook and cli.
     
    #3865     Nov 20, 2023
  6. This is farily basic python: You can't put a reserved character as a dict key unless you're using the {} form of dict and you put the key in quotes

    So this wont' work my_dict = dict(a-2=5)
    This will work my_dict = {'a-2':5}

    Rob
     
    #3866     Nov 20, 2023
  7. jiikoo

    jiikoo

    Thanks, it works now! Sorry to bother with dumb questions, but I did try..
     
    #3867     Nov 20, 2023
  8. jiikoo

    jiikoo

    Sorry for being ambiguos, I meant the AFTS standalone scripts are being run on the same box as pysystemtrade. So I have data in pysystemtrade db and couldn't yet figure out how to access that data from AFTS scripts, without csv's.
     
    #3868     Nov 20, 2023
  9. You need to read the pystemtrade manual, but this would work:

    Code:
    from systems.provided.basic.system import dbFuturesSimData
    d = dbFuturesSimData()
    d.daily_prices('US10')
    Rob
     
    #3869     Nov 20, 2023
  10. jiikoo

    jiikoo

    Thanks again! I was trying with rawdata. I've read the docs, but have to read and experiment much more until everything falls into place.
     
    #3870     Nov 20, 2023