Hi All
I hope your well and smashing the green into where ever you smash it...
Some of you may know I have been dabbling with automation on various sports/markets. I would be interested to hear peoples experiences of when they started out and how the journey is going or ended with the automation side of things. I have various strategies running and the two below I thought I had found the golden egg However, I am getting a little side action as you can see. I tweeted Peter and he told me a year is a good test for a solid strategy.
What are other peoples views?
Do people run volatile strategies that they know will be a decent ROI?
What are people's experience with drawdown?
Take it easy people.
Mick
Automation Strategies
- Realrocknrolla
- Posts: 1903
- Joined: Fri Jun 05, 2020 7:15 pm
You do not have the required permissions to view the files attached to this post.
- Realrocknrolla
- Posts: 1903
- Joined: Fri Jun 05, 2020 7:15 pm
Great start to the week to be fair, maybe the sideways action is to be expected.
- Realrocknrolla
- Posts: 1903
- Joined: Fri Jun 05, 2020 7:15 pm
Hi LP
Hope your well.
I am more interested in peoples experience of drawdown through there automation.
Daily, Weekly, Monthly etc. More piece of mind than anything to compare I suppose.
The two stats i posted are on the dog markets, and undertake 30-50 bets each day. Certain grades and prices etc.
Hope your well.
I am more interested in peoples experience of drawdown through there automation.
Daily, Weekly, Monthly etc. More piece of mind than anything to compare I suppose.
The two stats i posted are on the dog markets, and undertake 30-50 bets each day. Certain grades and prices etc.
Interesting my bot I gave up on recently shows a similar trend over the same period as your first bot:Realrocknrolla wrote: ↑Tue May 11, 2021 11:04 amHi All
I hope your well and smashing the green into where ever you smash it...
Some of you may know I have been dabbling with automation on various sports/markets. I would be interested to hear peoples experiences of when they started out and how the journey is going or ended with the automation side of things. I have various strategies running and the two below I thought I had found the golden egg However, I am getting a little side action as you can see. I tweeted Peter and he told me a year is a good test for a solid strategy.
What are other peoples views?
Do people run volatile strategies that they know will be a decent ROI?
What are people's experience with drawdown?
Capture B.png
Capture A.png
Take it easy people.
Mick
- Realrocknrolla
- Posts: 1903
- Joined: Fri Jun 05, 2020 7:15 pm
Yo Ggoat68 wrote: ↑Tue May 11, 2021 10:02 pmInteresting my bot I gave up on recently shows a similar trend over the same period as your first bot:Realrocknrolla wrote: ↑Tue May 11, 2021 11:04 amHi All
I hope your well and smashing the green into where ever you smash it...
Some of you may know I have been dabbling with automation on various sports/markets. I would be interested to hear peoples experiences of when they started out and how the journey is going or ended with the automation side of things. I have various strategies running and the two below I thought I had found the golden egg However, I am getting a little side action as you can see. I tweeted Peter and he told me a year is a good test for a solid strategy.
What are other peoples views?
Do people run volatile strategies that they know will be a decent ROI?
What are people's experience with drawdown?
Capture B.png
Capture A.png
Take it easy people.
Mick
Screenshot 2021-05-11 at 22.00.41.png
Looks similar.
Why did you give up?
So started to get worse and worse especially after trying larger stakes, and I was convinced I had back fitted it, I had too much if volume doing X for fav2 while fav3 was at a higher price and fav1's price was less than 2.5,... get my drift...?Realrocknrolla wrote: ↑Tue May 11, 2021 10:22 pmYo Ggoat68 wrote: ↑Tue May 11, 2021 10:02 pmInteresting my bot I gave up on recently shows a similar trend over the same period as your first bot:Realrocknrolla wrote: ↑Tue May 11, 2021 11:04 amHi All
I hope your well and smashing the green into where ever you smash it...
Some of you may know I have been dabbling with automation on various sports/markets. I would be interested to hear peoples experiences of when they started out and how the journey is going or ended with the automation side of things. I have various strategies running and the two below I thought I had found the golden egg However, I am getting a little side action as you can see. I tweeted Peter and he told me a year is a good test for a solid strategy.
What are other peoples views?
Do people run volatile strategies that they know will be a decent ROI?
What are people's experience with drawdown?
Capture B.png
Capture A.png
Take it easy people.
Mick
Screenshot 2021-05-11 at 22.00.41.png
Looks similar.
Why did you give up?
However, i've not got anything else to run at the moment so may re-instate it for the hell of it! (at small stakes!)
Gents,Realrocknrolla wrote: ↑Tue May 11, 2021 7:42 pmGreat start to the week to be fair, maybe the sideways action is to be expected.
This is just crying out for further testing..there is no point guessing whether something is just lucky (or unlucky)
If you dont know that then you wont know when to carry on of ditch the idea?
One great way I test these is by using a Monte Carlo (thanks to Xitan to introducing them to me).
heres a real example..based on real bets
Im current running three test accounts to see which gives the best results for a new strategy. (i have other accounts in the background , that are tried and tested and I wont be touching them). The screenshot is just two accounts just to serve as an illustration..)
I can see that although they both have the same profit, one has a slightly better ROI (Profit/Risk (Risk = liability). You can also see how many times the MC (based on a random number generator) beats the strategy. So I can see that the strategy on the top image is better than the one below it. (you can also see the shape of the P&L curve is different too). So I know this isnt anything to do with luck
Ill run this for a period of time and see which performs better. I may then decide to make some more changes and rinse and repeat. (Its really important to keep detailed notes or you will get lost in the future, leave some breadcrumbs! so you can retrace)
So what do you need to run the Monte Carlo, a free program called pycharm and the code on the slack groupcreated by Birchy , you just copy and paste the code into PC and away you go. It is very easy to run. (if anyone is interested in this program Ill ask the author if he wouldn't mind me pasting it in here)
Regards
Peter
You do not have the required permissions to view the files attached to this post.
Thanks Peter, you've prompted me to revisit monte carlo on this. However MC means different things to different people, it essentially means applying some random analysis. The 3 applications ive seen arePeterLe wrote: ↑Wed May 12, 2021 12:30 amGents,Realrocknrolla wrote: ↑Tue May 11, 2021 7:42 pmGreat start to the week to be fair, maybe the sideways action is to be expected.
This is just crying out for further testing..there is no point guessing whether something is just lucky (or unlucky)
If you dont know that then you wont know when to carry on of ditch the idea?
One great way I test these is by using a Monte Carlo (thanks to Xitan to introducing them to me).
heres a real example..based on real bets
Im current running three test accounts to see which gives the best results for a new strategy. (i have other accounts in the background , that are tried and tested and I wont be touching them). The screenshot is just two accounts just to serve as an illustration..)
I can see that although they both have the same profit, one has a slightly better ROI (Profit/Risk (Risk = liability). You can also see how many times the MC (based on a random number generator) beats the strategy. So I can see that the strategy on the top image is better than the one below it. (you can also see the shape of the P&L curve is different too). So I know this isnt anything to do with luck
Ill run this for a period of time and see which performs better. I may then decide to make some more changes and rinse and repeat. (Its really important to keep detailed notes or you will get lost in the future, leave some breadcrumbs! so you can retrace)
So what do you need to run the Monte Carlo, a free program called pycharm and the code on the slack groupcreated by Birchy , you just copy and paste the code into PC and away you go. It is very easy to run. (if anyone is interested in this program Ill ask the author if he wouldn't mind me pasting it in here)
Regards
Peter
1) random slicing of original data, this i think is what pycharm does.
2) drawdown analysis, this essentially uses (1) over many iterations to produce a poisson distribution confidence on how bad a drawdown could be at a 95% poisson confidence
3) randomized exit, this tests the strength of the strategy entry and helps to show whether or not the strategy is fitted to the data, in particular the original exit method. The theory being a strong entry should be more resilient
Ive done (1) on my strategy and it holds up well which given the overall profit over the period is not unsurprising, it all depends whether random selection picks all from the initial uptrend or from the flat/declining section.
I will however look at doing (3), which I think could be very useful.
Pycharm i presume processes excel data? So wouldnt be able to achieve (3), unless it plugs into flumine?
Thanks
HI
So I wouldn't necessarily say that MC means different things to different people, for eg I would use it in probably the same way as many other traders.
You are essentially looking at how things may have gone had you placed the same bets (lets call the combined bets a 'season' and then run the season a hundred thousand times), you will get a sense of what your max drawdown would be and an average drawdown.
Pycharm has nothing to do with BFLW or Flumine, it is an independent IDE for Python. Its super easy to use (If I can learn it anyone can!)
You basically download the free version, run it and copy the code in. Download your bethistory to your downloads folder and that's it, very easy
Ive asked the author for his permission to post the code here, so as soon as he replies, you will be good to go!
Regards
Peter
So I wouldn't necessarily say that MC means different things to different people, for eg I would use it in probably the same way as many other traders.
You are essentially looking at how things may have gone had you placed the same bets (lets call the combined bets a 'season' and then run the season a hundred thousand times), you will get a sense of what your max drawdown would be and an average drawdown.
Pycharm has nothing to do with BFLW or Flumine, it is an independent IDE for Python. Its super easy to use (If I can learn it anyone can!)
You basically download the free version, run it and copy the code in. Download your bethistory to your downloads folder and that's it, very easy
Ive asked the author for his permission to post the code here, so as soon as he replies, you will be good to go!
Regards
Peter
As promised; here's the code you need, Thanks to Birchy on the Slack Group
import os
from random import random
from matplotlib import pyplot
from tkinter import *
from tkinter import filedialog
from time import time
gui = Tk()
home_path = os.path.expanduser('~')
init_dir = os.path.join(home_path, 'Downloads')
init_path = os.path.join(init_dir, 'BetHistory.csv')
csv_path = StringVar(gui, value=init_path)
mc_iters = IntVar(gui, value=10) # initial number of MC iterations
csv_bets = []
def update_file_path():
hist_path = filedialog.askopenfilename(
parent=gui,
initialdir=init_dir,
title='Choose BetHistory file',
filetypes=[('csv', '*.csv')]
)
if hist_path:
# update label
csv_path.set(hist_path)
def load_csv():
global csv_bets
csv_bets = []
with open(csv_path.get(), 'r') as f:
for row in reversed(f.readlines()[1:]):
cols = list(row.split(','))
if len(cols) != 12:
continue # corrupted csv data
# convert csv strings to floats
for i, v in enumerate(cols):
if i < 7: continue
try:
if '(' in cols:
cols = cols.replace('(', '-').partition(')')[0]
cols = float(cols)
except:
pass
cols[2] = cols[2].upper() # bet side
# add extra info for Monte Carlo lookups
side = cols[2] # 'BACK', 'LAY'
stake = cols[8] # bet stake
price = cols[10] # avg price matched
payout = round(stake * (price - 1), 2) # back win or lay payout
mc_lookup = {
'p_win': 1 / price, # implied probability
True: 0.0, # return if runner wins
False: 0.0, # return if runner loses
}
if side == 'BACK':
mc_lookup[True] = payout # return if runner wins
mc_lookup[False] = -stake # return if runner loses
elif side == 'LAY':
mc_lookup[True] = -payout # return if runner wins
mc_lookup[False] = stake # return if runner loses
cols.append(mc_lookup)
# update cache
csv_bets.append(cols)
def calc_actual_pnl():
"""returns (P&L, ROI, PLOT) tuple"""
load_csv()
total_pnl = 0.0
total_risk = 0.0
roi = 0.0
pnl_plots = []
for bet in csv_bets:
if bet[2] == 'BACK': bet[9] = bet[8] # liability = stake
total_risk = round(total_risk + bet[9], 2)
total_pnl = round(total_pnl + bet[11], 2)
pnl_plots.append(total_pnl)
if total_risk > 0:
roi = round(100 * (total_pnl / total_risk), 2)
return total_pnl, roi, pnl_plots
def plot_graph():
total_pnl, roi, pnl_plots = calc_actual_pnl()
if total_pnl:
# maximise plot window
mngr = pyplot.get_current_fig_manager()
try:
mngr.window.state('zoomed') # OS = WINDOWS
except:
# not tested on OSX/Linux!
pass
pyplot.plot(pnl_plots)
pyplot.xlabel('BETS')
pyplot.ylabel('P&L')
title = 'P&L: %.2f ROI: %.2f%%' % (total_pnl, roi)
pyplot.title(title)
pyplot.show()
def run_monte_carlo():
# calc actual P&L
total_pnl, roi, pnl_plots = calc_actual_pnl()
# run MC
label_mc_result['text'] = ''
button_path['state'] = 'disabled'
button_mc_start['state'] = 'disabled'
button_plot['state'] = 'disabled'
mc_better_count = 0
mc_run_count = int(mc_iters.get() * 1000)
iupdate = 0
start_time = time()
max_drawdown = 0.0
dd_mean_sum, dd_mean_count = 0.0, 0
for i in range(mc_run_count):
mc_pnl, max_pnl = 0.0, 0.0
iupdate += 1
if iupdate > 50:
# update gui
prog = 'Running: %d/%d' % (i, mc_run_count)
label_mc_result['text'] = prog
gui.update()
iupdate = 0
sample_dd = 0.0
for bet in csv_bets:
mc_lookup = bet[12]
runner_wins = random() <= mc_lookup['p_win'] # MC random result
mc_pnl += mc_lookup[runner_wins]
if mc_pnl > max_pnl: max_pnl = mc_pnl
dd = max_pnl - mc_pnl
if dd > sample_dd: sample_dd = dd
if sample_dd > max_drawdown: max_drawdown = sample_dd
dd_mean_sum += sample_dd
dd_mean_count += 1
# did MC P&L beat our actual P&L?
if mc_pnl > total_pnl:
mc_better_count += 1
# outputs
run_time = time() - start_time
eval_count = mc_run_count * len(csv_bets) # total evaluations
mc_better_percentage = 100 * (mc_better_count / mc_run_count)
msg = 'Statistics:\n'
msg += '* Completed %.1fM evaluations in %.2fs\n' % (eval_count / 1e6, run_time)
msg += '* Analysed %d strategy bets\n' % len(csv_bets)
msg += '* Monte Carlo beats strategy: '
msg += '%d times in %d runs (%.2f%%)\n' % (mc_better_count, mc_run_count, mc_better_percentage)
msg += '* Drawdown: max = %.2f, mean = %.2f' % (max_drawdown, dd_mean_sum / dd_mean_count)
label_mc_result['text'] = msg
button_path['state'] = 'normal'
button_plot['state'] = 'normal'
button_mc_start['state'] = 'normal'
gui.update()
# set main window size & header font
gui.geometry('450x300') # main window size
gui.title('BetHistory.csv Analysis')
# file path gui
button_path = Button(gui, text='Change', command=update_file_path)
button_path.place(x=20, y=16)
label_file = Label(gui, text='FILE:')
label_file.place(x=85, y=20)
label_path = Label(gui, textvariable=csv_path)
label_path.place(x=120, y=20)
# plotting gui
button_plot = Button(gui, text='Plot P&L Graph', command=plot_graph)
button_plot.place(x=20, y=80)
# Monte Carlo gui
input_mc_iters = Entry(gui, textvariable=mc_iters, justify='center')
input_mc_iters.place(x=140, y=141, width=40, height=24)
button_mc_start = Button(gui, text='Run Monte Carlo', command=run_monte_carlo)
button_mc_start.place(x=20, y=140)
label_mc = Label(gui, text='x1000 iterations')
label_mc.place(x=180, y=142)
label_mc_result = Label(gui, justify=LEFT)
label_mc_result.place(x=20, y=170)
gui.mainloop()
import os
from random import random
from matplotlib import pyplot
from tkinter import *
from tkinter import filedialog
from time import time
gui = Tk()
home_path = os.path.expanduser('~')
init_dir = os.path.join(home_path, 'Downloads')
init_path = os.path.join(init_dir, 'BetHistory.csv')
csv_path = StringVar(gui, value=init_path)
mc_iters = IntVar(gui, value=10) # initial number of MC iterations
csv_bets = []
def update_file_path():
hist_path = filedialog.askopenfilename(
parent=gui,
initialdir=init_dir,
title='Choose BetHistory file',
filetypes=[('csv', '*.csv')]
)
if hist_path:
# update label
csv_path.set(hist_path)
def load_csv():
global csv_bets
csv_bets = []
with open(csv_path.get(), 'r') as f:
for row in reversed(f.readlines()[1:]):
cols = list(row.split(','))
if len(cols) != 12:
continue # corrupted csv data
# convert csv strings to floats
for i, v in enumerate(cols):
if i < 7: continue
try:
if '(' in cols:
cols = cols.replace('(', '-').partition(')')[0]
cols = float(cols)
except:
pass
cols[2] = cols[2].upper() # bet side
# add extra info for Monte Carlo lookups
side = cols[2] # 'BACK', 'LAY'
stake = cols[8] # bet stake
price = cols[10] # avg price matched
payout = round(stake * (price - 1), 2) # back win or lay payout
mc_lookup = {
'p_win': 1 / price, # implied probability
True: 0.0, # return if runner wins
False: 0.0, # return if runner loses
}
if side == 'BACK':
mc_lookup[True] = payout # return if runner wins
mc_lookup[False] = -stake # return if runner loses
elif side == 'LAY':
mc_lookup[True] = -payout # return if runner wins
mc_lookup[False] = stake # return if runner loses
cols.append(mc_lookup)
# update cache
csv_bets.append(cols)
def calc_actual_pnl():
"""returns (P&L, ROI, PLOT) tuple"""
load_csv()
total_pnl = 0.0
total_risk = 0.0
roi = 0.0
pnl_plots = []
for bet in csv_bets:
if bet[2] == 'BACK': bet[9] = bet[8] # liability = stake
total_risk = round(total_risk + bet[9], 2)
total_pnl = round(total_pnl + bet[11], 2)
pnl_plots.append(total_pnl)
if total_risk > 0:
roi = round(100 * (total_pnl / total_risk), 2)
return total_pnl, roi, pnl_plots
def plot_graph():
total_pnl, roi, pnl_plots = calc_actual_pnl()
if total_pnl:
# maximise plot window
mngr = pyplot.get_current_fig_manager()
try:
mngr.window.state('zoomed') # OS = WINDOWS
except:
# not tested on OSX/Linux!
pass
pyplot.plot(pnl_plots)
pyplot.xlabel('BETS')
pyplot.ylabel('P&L')
title = 'P&L: %.2f ROI: %.2f%%' % (total_pnl, roi)
pyplot.title(title)
pyplot.show()
def run_monte_carlo():
# calc actual P&L
total_pnl, roi, pnl_plots = calc_actual_pnl()
# run MC
label_mc_result['text'] = ''
button_path['state'] = 'disabled'
button_mc_start['state'] = 'disabled'
button_plot['state'] = 'disabled'
mc_better_count = 0
mc_run_count = int(mc_iters.get() * 1000)
iupdate = 0
start_time = time()
max_drawdown = 0.0
dd_mean_sum, dd_mean_count = 0.0, 0
for i in range(mc_run_count):
mc_pnl, max_pnl = 0.0, 0.0
iupdate += 1
if iupdate > 50:
# update gui
prog = 'Running: %d/%d' % (i, mc_run_count)
label_mc_result['text'] = prog
gui.update()
iupdate = 0
sample_dd = 0.0
for bet in csv_bets:
mc_lookup = bet[12]
runner_wins = random() <= mc_lookup['p_win'] # MC random result
mc_pnl += mc_lookup[runner_wins]
if mc_pnl > max_pnl: max_pnl = mc_pnl
dd = max_pnl - mc_pnl
if dd > sample_dd: sample_dd = dd
if sample_dd > max_drawdown: max_drawdown = sample_dd
dd_mean_sum += sample_dd
dd_mean_count += 1
# did MC P&L beat our actual P&L?
if mc_pnl > total_pnl:
mc_better_count += 1
# outputs
run_time = time() - start_time
eval_count = mc_run_count * len(csv_bets) # total evaluations
mc_better_percentage = 100 * (mc_better_count / mc_run_count)
msg = 'Statistics:\n'
msg += '* Completed %.1fM evaluations in %.2fs\n' % (eval_count / 1e6, run_time)
msg += '* Analysed %d strategy bets\n' % len(csv_bets)
msg += '* Monte Carlo beats strategy: '
msg += '%d times in %d runs (%.2f%%)\n' % (mc_better_count, mc_run_count, mc_better_percentage)
msg += '* Drawdown: max = %.2f, mean = %.2f' % (max_drawdown, dd_mean_sum / dd_mean_count)
label_mc_result['text'] = msg
button_path['state'] = 'normal'
button_plot['state'] = 'normal'
button_mc_start['state'] = 'normal'
gui.update()
# set main window size & header font
gui.geometry('450x300') # main window size
gui.title('BetHistory.csv Analysis')
# file path gui
button_path = Button(gui, text='Change', command=update_file_path)
button_path.place(x=20, y=16)
label_file = Label(gui, text='FILE:')
label_file.place(x=85, y=20)
label_path = Label(gui, textvariable=csv_path)
label_path.place(x=120, y=20)
# plotting gui
button_plot = Button(gui, text='Plot P&L Graph', command=plot_graph)
button_plot.place(x=20, y=80)
# Monte Carlo gui
input_mc_iters = Entry(gui, textvariable=mc_iters, justify='center')
input_mc_iters.place(x=140, y=141, width=40, height=24)
button_mc_start = Button(gui, text='Run Monte Carlo', command=run_monte_carlo)
button_mc_start.place(x=20, y=140)
label_mc = Label(gui, text='x1000 iterations')
label_mc.place(x=180, y=142)
label_mc_result = Label(gui, justify=LEFT)
label_mc_result.place(x=20, y=170)
gui.mainloop()
It is essentially just replaying your bets in random "buckets" in random "orders" so you can assess drawdown and such... not sure it can truly help you know how "fitted" your strategy is?
I actually think the random exit idea is a possible way of helping understand how "fitted" your strategy might be see ref here: https://www.seeitmarket.com/3-of-many-u ... ing-18266/
I actually think the random exit idea is a possible way of helping understand how "fitted" your strategy might be see ref here: https://www.seeitmarket.com/3-of-many-u ... ing-18266/
- Realrocknrolla
- Posts: 1903
- Joined: Fri Jun 05, 2020 7:15 pm
Yes, i'm good at "shit" stuff, rubbish at "trading"Realrocknrolla wrote: ↑Wed May 12, 2021 6:16 pmI like colours.
But i cant do shit like that. My skills are not up there yet.