# In[17]: #now lets construct a trend following strategy based on the previous strategy #call it oil money version 2 or whatever #here i would only import the strategy script as this is a script for analytics and visualization #the official trading strategy script is in the following link # https://github.com/je-suis-tm/quant-trading/blob/master/Oil%20Money%20project/Oil%20Money%20Trading%20backtest.py import oil_money_trading_backtest as om #generate signals,monitor portfolio performance #plot positions and total asset signals=om.signal_generation(dataset,'brent','nok',om.oil_money) p=om.portfolio(signals,'nok') om.plot(signals,'nok') om.profit(p,'nok') #but thats not enough, we are not happy with the return #come on, 2 percent return? #i may as well as deposit the money into the current account #and get 0.75% risk free interest rate #therefore, we gotta try different holding period and stop loss/profit point #the double loop is very slow, i almost wanna do it in julia #plz go get a coffee or even lunch and dont wait for it dic={} for holdingt in range(5,20): for stopp in np.arange(0.3,1.1,0.05): signals=om.signal_generation(dataset,'brent','nok',om.oil_money \ holding_threshold=holdingt, \ stop=stopp)
#import the strategy script as this is a script for analytics and visualization #the official trading strategy script is in the following link # https://github.com/je-suis-tm/quant-trading/blob/master/Oil%20Money%20project/Oil%20Money%20Trading%20backtest.py import oil_money_trading_backtest as om #generate signals,monitor portfolio performance #plot positions and total asset signals = om.signal_generation(dataset, 'vasconia', 'cop', om.oil_money, stop=0.001) p = om.portfolio(signals, 'cop') om.plot(signals, 'cop') om.profit(p, 'cop') # In[15]: #try different holding period and stop loss/profit point dic = {} for holdingt in range(5, 20): for stopp in np.arange(0.001, 0.005, 0.0005): signals = om.signal_generation(dataset, 'vasconia', 'cop', om.oil_money, holding_threshold=holdingt, stop=round(stopp, 4)) p = om.portfolio(signals, 'cop')