Monte Carlo Simulation and Python 13 - D'Alembert Strategy



Monte Carlo Simulation with Python Playlist: http://www.youtube.com/watch?v=9M_KPXwnrlE&feature=share&list=PLQVvvaa0QuDdhOnp-FnVStDsALpYk2hk0 In this video, we program the D'Alembert Strategy. The D'Alembert betting strategy is a progressive betting strategy that uses increments rather than multiples. In the monte carlo simulation with Python series, we test various betting strategies. A simple 50/50 strategy, a martingale strategy, and the d'alembert strategy. We use the monte carlo simulator to calculate possible paths, as well as to calculate preferred variables to use including wager size, how many wagers, and more. There are many purposes for a monte carlo simulator. Some people use them as a form of brute force to solve complex mathematical equations. A popular example used is to have a monte carlo simulator solve for pi. In our case, we are using the Monte Carlo simulator to account for randomness and the degree of risk associated with a betting strategy. In the world of stock trading and investing, people can use the Monte Carlo simulator to test a given strategy's risk. It used to be very much the case that only performance was considered, for the most part, to decide on a trader's value. Only until recently has the paradigm shifted to consider a strategy's risk more closely. Through this series, you will be able to see just how much random variability can affect the outcome, regardless of how "good" or "bad" a strategy might have been. http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6

Comments

  1. import random
    import matplotlib
    import matplotlib.pyplot as plt
    import time

    lower_bust = 31.235
    higher_profit = 63.208

    sampleSize = 100
    startingFunds = 10000
    wagerSize = 100
    wagerCount = 100

    def rollDice():
    roll = random.randint(1,100)

    if roll == 100:
    #print roll,'roll was 100, you lose. What are tho edds?! Play again!'
    return False
    elif roll <= 50:
    #print roll, 'roll was 1-50, you lose. Play again!'
    return False

    elif 100 > roll >= 50:
    #print roll, 'roll was 51-99, you win! * pretty lights flash* Play more!'
    return True

    def dAlembert(funds,initial_wager,wager_count):
    global da_busts
    global da_profits

    value = funds
    wager = initial_wager
    currentWager = 1
    previousWager = 'win'
    previousWagerAmount = initial_wager

    while currentWager <= wager_count:
    if previousWager == 'win':
    if wager == initial_wager:
    pass
    else:
    wager -= initial_wager

    print 'current wager:',wager,'value:',value

    if rollDice():
    value += wager
    print 'we won, current value:',value
    previousWagerAmount = wager
    else:
    value -= wager
    previousWager = 'loss'
    print 'we lost, current value',value
    previousWagerAmount = wager

    if value <= 0:
    da_busts += 1
    break

    elif previousWager == 'loss':
    wager = previousWagerAmount + initial_wager
    if (value - wager) <= 0:
    wager = value

    print 'lost the last wager, current wager:',wager,'value',value

    if rollDice():
    value += wager
    print 'we won, current value:',value
    previousWagerAmount = wager
    previousWager = 'win'

    else:
    value -= wager
    print 'we lost, current value:',value
    previousWagerAmount = wager

    if value <= 0:
    da_busts += 1
    break

    currentWager += 1

    if value > funds:
    da_profits += 1

    print value

    da_profits = 0.0
    da_busts = 0.0

    dAlembert(startingFunds,wagerSize,wagerCount)

    time.sleep(555555)

    def multiple_bettor(funds, initial_wager, wager_count):
    global multiple_busts
    global multiple_profits

    value = funds
    wager = initial_wager
    wX = []
    vY = []

    currentWager = 1
    previousWager = 'win'
    previousWagerAmount = initial_wager

    while currentWager <= wager_count:
    if previousWager == 'win':
    #print 'we won the last wager, great'
    if rollDice():
    value+=wager
    #print value
    wX.append(currentWager)
    vY.append(value)
    else:
    value -= wager
    previousWager = 'loss'
    #print value
    previousWagerAmount = wager
    wX.append(currentWager)
    vY.append(value)
    if value <= 0:
    #print 'we went broke after'.currentWager,'bets'
    multiple_busts += 1
    break

    elif previousWager == 'loss':
    #print 'we lost the last one, so we will be smart and double'
    if rollDice():
    wager = previousWagerAmount * random_multiple
    if (value - wager) < 0:
    wager = value
    #print 'we won',wager
    value += wager
    #print value
    wager = initial_wager
    previousWager = 'win'
    wX.append(currentWager)
    vY.append(value)
    else:
    wager = previousWagerAmount * random_multiple
    if (value - wager) < 0:
    wager = value
    #print 'we lost',wager
    value -= wager
    previousWagerAmount = wager
    wX.append(currentWager)
    vY.append(value)
    if value <= 0:
    #print 'we went broke after',currentWager,'bets'
    multiple_busts += 1
    break

    #print value
    previousWager = 'loss'

    currentWager += 1

    #print value
    #plt.plot(wX,vY,color)
    if value > funds:
    multiple_profits += 1

    def doubler_bettor(funds, initial_wager, wager_count, color):
    value = funds
    wager = initial_wager
    global doubler_busts
    global doubler_profits
    wX = []
    vY = []

    currentWager = 1
    previousWager = 'win'
    previousWagerAmount = initial_wager

    while currentWager <= wager_count:
    if previousWager == 'win':
    #print 'we won the last wager, great'
    if rollDice():
    value+=wager
    #print value
    wX.append(currentWager)
    vY.append(value)
    else:
    value -= wager
    previousWager = 'loss'
    #print value
    previousWagerAmount = wager
    wX.append(currentWager)
    vY.append(value)
    if value <= 0:
    #print 'we went broke after'.currentWager,'bets'
    doubler_busts += 1
    break

    elif previousWager == 'loss':
    #print 'we lost the last one, so we will be smart and double'
    if rollDice():
    wager = previousWagerAmount * 2

    if (value - wager) < 0:
    wager = value
    #print 'we won',wager
    value += wager
    #print value
    wager = initial_wager
    previousWager = 'win'
    wX.append(currentWager)
    vY.append(value)
    else:
    wager = previousWagerAmount * 2
    if (value - wager) < 0:
    wager = value
    #print 'we lost',wager
    value -= wager
    previousWagerAmount = wager
    wX.append(currentWager)
    vY.append(value)
    if value <= 0:
    #print 'we went broke after',currentWager,'bets'
    doubler_busts += 1
    break

    #print value
    previousWager = 'loss'

    currentWager += 1

    #print value
    plt.plot(wX,vY,color)
    if value > funds:
    doubler_profits += 1

    def simple_bettor(funds, initial_wager, wager_count, color):
    global simple_busts
    global simple_profits
    value = funds
    wager = initial_wager

    wX = []
    vY = []

    currentWager = 1

    while currentWager <= wager_count:
    if rollDice():
    value += wager
    wX.append(currentWager)
    vY.append(value)
    else:
    value -= wager
    wX.append(currentWager)
    vY.append(value)

    currentWager += 1

    if value <= 0:
    value = 0
    simple_busts+=1
    #print 'Funds:', value

    plt.plot(wX,vY,color)
    if value > funds:
    value = 0
    simple_profits+=1

    while True:
    multiple_busts = 0.0
    multiple_profits = 0.0

    multipleSampSize = 100000
    currentSample = 1

    random_multiple = random.uniform(0.1,10.0)

    while currentSample <= multipleSampSize:
    multiple_bettor(startingFunds,wagerSize,wagerCount)
    currentSample += 1

    if ((multiple_busts/multipleSampSize)*100.00 < lower_bust) and ((multiple_profits/multipleSampSize)*100.00 > higher_profit):
    print '############'
    print 'Found a winner, the multiple was', random_multiple
    print 'Lower bust to beat',lower_bust
    print 'Higher profit rate to beat:', higher_profit
    print 'bust rate:',(multiple_busts/multipleSampSize)*100.00
    print 'Profit rate:',(multiple_profits/multipleSampSize)*100.00
    print '############'

    else:
    pass
    '''print '############'
    print 'Found a loser, the multiple was', random_multiple
    print 'Lower bust to beat',lower_bust
    print 'Higher profit rate to beat:', higher_profit
    print 'bust rate:',(multiple_busts/multipleSampSize)*100.00
    print 'Profit rate:',(multiple_profits/multipleSampSize)*100.00
    print '############'''
  2. peeked here and there again on this series, and it seems what you are accomplishing with a randomized simulation can be accomplished analytically in a cleaner way with probability distributions.

    The only real utility of Monte Carlo that I know of is multi dimensional integration with more than something like 7 degrees of freedom if i recall correctly... or when the domain is too weird.
  3. Roulette det not have a 50/50 chance. It's 18/37 so even worse than your roll dice function.


Additional Information:

Visibility: 3731

Duration: 15m 7s

Rating: 14