A martingale script for Epicdice
epicdiceยท@emrebeylerยท
0.000 HBDA martingale script for Epicdice
I had been experimenting with [martingale](https://en.wikipedia.org/wiki/Martingale_(betting_system)). Mostly `over 60` or `under 45`, sometimes with different numbers. Didn't work out well for me but in case somebody needs it, here is a simple script does the job. ``` import json import re import sys import time from steem import Steem from steem.amount import Amount from steem.transactionbuilder import TransactionBuilder from steembase import operations sys.setrecursionlimit(50000) # config s = Steem( nodes=["https://api.steemit.com"], keys=["<active_key>"]) player = "<player_username>" start_amount = 0.100 start_bid_type = "Below" start_bid = 45 def parse_memo(memo): json_data = re.findall('(\{.*\})', memo)[0] json_data = json.loads(json_data) return json_data["TransactionId"], json_data["BlockNumber"] def get_bid_op(block_id, trx_id, s): try: b = s.get_block(block_id) except Exception as e: return get_bid_op(block_id, trx_id, s) if not b: return get_bid_op(block_id, trx_id, s) for tx in b["transactions"]: if tx["transaction_id"] == trx_id: return tx["operations"][0][1] def check_result_tx(start_block, s): found_tx = False while not found_tx: try: b = s.get_block(start_block) except Exception as e: return check_result_tx(start_block, s) if not b: return check_result_tx(start_block, s) for tx in b["transactions"]: for op_type, op_value in tx["operations"]: if op_type != "transfer": continue if op_value["from"] != "epicdice": continue if op_value["to"] != player: continue bid_tx, bid_block = parse_memo(op_value["memo"]) bid_op = get_bid_op(bid_block, bid_tx, s) win = 'Won' in op_value["memo"] return win, op_value["amount"], bid_op["amount"] start_block = start_block + 1 time.sleep(0.1) def broadcast_transfer(bid_type, bid_number, bid_amount): ops = [ operations.Transfer(**{ "from": player, "to": "epicdice", "amount": bid_amount, "memo": f"{bid_type} {bid_number}" }), ] tb = TransactionBuilder(steemd_instance=s) tb.appendOps(ops) tb.appendSigner(player, "active") tb.sign() response = s.broadcast_transaction_synchronous(tb.json()) block_num = response.get("block_num") return block_num def martingale(amount=None, bid_type=None, bid=None, total_win_amount=0, total_loss_amount=0, stop_loss=33.9, bid_no=1, total_wagered=0): amount = amount or start_amount bid_type = bid_type or start_bid_type bid = bid or start_bid if amount > stop_loss: return martingale(total_win_amount=total_win_amount, total_loss_amount=total_loss_amount, bid_no=bid_no, total_wagered=total_wagered) profit = round((total_win_amount - total_loss_amount), 3) total_wagered = round(total_wagered, 3) print( f"Bid: #{bid_no} {amount} STEEM ({bid_type} {bid})" f" [Profit: {profit} STEEM] [Total Wagered: {total_wagered} STEEM]") block_id = broadcast_transfer(bid_type, bid, f"{amount} STEEM") win, payout_amount, bid_amount = check_result_tx(block_id, s) payout_amount = Amount(payout_amount) bid_amount = Amount(bid_amount) total_wagered += bid_amount.amount bid_no += 1 total_win_amount += payout_amount.amount total_loss_amount += bid_amount.amount if win: return martingale( total_win_amount=total_win_amount, total_loss_amount=total_loss_amount, bid=bid, bid_no=bid_no, total_wagered=total_wagered) else: bid = start_bid amount = (amount * 2) amount = round(amount, 3) return martingale(amount=amount, bid_type=bid_type, bid=bid, total_win_amount=total_win_amount, total_loss_amount=total_loss_amount, bid_no=bid_no, total_wagered=total_wagered) martingale() ``` *** Once you run it, you will see an output like this: ``` Bid: #1 0.1 STEEM (Below 50) [Profit: 0 STEEM] [Total Wagered: 0 STEEM] Bid: #2 0.1 STEEM (Below 50) [Profit: 0.1 STEEM] [Total Wagered: 0.1 STEEM] Bid: #3 0.1 STEEM (Below 50) [Profit: 0.2 STEEM] [Total Wagered: 0.2 STEEM] ``` *** It requires steem-python and probably Python3.6+. It's not the best, but it works. For example, if follows the recursive approach instead of an iterative approach. (laziness, I love it.) **Make sure you audit the code before actually using it. If you don't have the skills to audit it, don't use it.**. Even though I didn't encounter any bug while wagering 20k+ STEEM with this, there is no warranty. Use it at your own risk. As a final note, if you didn't try Epicdice yet, try registering with my [referer link](https://epicdice.io/?ref=emrebeyler) so I can grab a couple of extra drinks this Friday. ๐
๐ ahmeterbay, raoul.poenar, bulent1976, bitcoinator, lionsuit, victorcovrig, bpangie, love-peace, swaze, frankdanger, zugs, supu, xyzashu, mehta, evilest-fiend, muratkbesiroglu, bilimkurgu, alitavirgen, jacekw.dev, cooperfelix, sereze, vitae, mercadosaway, noknowledge, cyworld, tahirozgen, hamsa.quality, sbi5, jacekw, akifane, ahmrahmdam, ayisigi, coinmarketcal, steemtank, crypticat, crokkon, infestor, exsis, fillter, faija, adwar, themarkymark, regulators, ydavgonzalez, beemtutorials, elchin, backinblackdevil, heist, knifer, superbouncer, bazookaguy, chemicaltroup, cooker, heister, isnochys, tyramisoux, murattatar, gokos, aydant, tinowhale, onursa, portugalcoin, chorock, samedb, tdogvoid, zcool, jumbot, ali.yuce, criptoanarquista, theblackwidow, fromhell2sky, ucmuharfli, luisal314, isisfemale, firster78, veronicacoli, arequipa, leviackerman, toninux, smafey, jacobkaled, maaz23, mhm-philippines, enjoyy, hayirhah, baycan, embesilikat, gulumserunver, rainbowlord, gjones15, ruh, ahmetchef, kemalyokus, carment, canku, tabraiz.jutt, kryptorero, bahagia9, alisari, bboyabluka, kanhiyachauhan, bluedwains, joanni, lujuria, sam-dmc, smvenezuela, arthurpendragon, shikataganai, laverdad, makotoshishio, rightscomet, nudgent, lukecreed, gydronium, sbd-fairy, basav, sutter, emrebeyler, raspibot, varolleng, pablorg94, busy.pay, unforgettable, jarunik, steinz, djenny.floro, hahajin, intelligencer, parakazan, berkerpeksag, kanrat, firatozbek, lastozgur, sauronbey, yollardannotlar, sjomeath, abbyrich, muradovv, tipitip, sulwati, ruel.cedeno, forkonti, osmania, googletr, ahmetmertugrul, ceruleanblue, alvinvoo, seanlloyd, hellowhale, turkolog, ataturk, giftbox, hyroniz, decebal2dac, senseofhumor, malay11, craigahamilton, airdroptr1, uzerebru, whiterabb1t, tentalavera, semihbalkanli, blaqboyikott, steeman220, aksapphires, uzercanan, danielsaori, ugos, plopp, bluerobo, yury-vas, we-are-welcoming, we-are-asia, daudimitch, we-are, coskunsoysal, tolgahanuzun, yakubali784362,