Giter Site home page Giter Site logo

bsc-predict / bsc-predict-bot Goto Github PK

View Code? Open in Web Editor NEW
36.0 3.0 17.0 14 KB

PancakeSwap Prediction market bot. Use your own strategy

Home Page: https://www.bscpredict.com

Python 100.00%
pancakeswap pancakeswap-bot bnb binance defi binance-smart-chain pancakeswap-prediction-bot

bsc-predict-bot's Introduction

PancakeSwap Prediction Market Starter Bot

This is a starter bot for BSCPredict or its official UI interface PancakeSwap Prediction Markets.

PRODUCT IS AS-IS. USE AT YOUR OWN DISCRETION

STRATEGIES PROVIDED ARE ONLY FOR DEMONSTRATION PURPOSES AND WILL LOSE MONEY

Quick Start

  1. Setup your virtual environment python3 -m venv venv && source venv/bin/activate && pip install -r requirements

  2. Copy over .env.sample to .env and update it with your account and secret key 1

  3. See strategies/SimpleBot.py for a simple "follow" strategy that copies over the last available winner. Edit the logic 2

  4. Run the bot python main.py --strategy SimpleBot --size 0.001 3

  5. Press CTRL+C to cancel

1. See Security section 2. The SimpleBot strategy is merely for demonstration purposes. Don't run this strategy as it is surely to lose money 3. This will run the bot and bet 0.001 ETH per bet

Background

Prediction markets are 5-minute binary options on the BNB-BUSD price hosted on the Binance Smart Chain. Users can predict whether they think the price of BNB will go up or down in 5 minute intervals. Contract can be found here. See documentation here.

Adding new strategies

See SimpleBot as an example of a strategy. You can copy this, alter it and run it with its new class name.

A strategy is defined by a class that extends BaseClass with a single function implementation of get_bet(self, upcoming: Round) -> Optional[Bet]. The function should return either a None or a Bet dataclass that's defined as follows.

class Direction(Enum):
  BULL = 0
  BEAR = 1

@dataclass
class Bet:
  """ Class for specifying a bet """
  direction: Direction
  amount_eth: int
  epoch: int

For instance, if you want to create a strategy that always bets BULL:

class Bot(BaseBot):
  def get_bet(self, upcoming: Round) -> Optional[Bet]:
    return Bet(direction=Direction.BULL, amount_eth=self.bet_size_eth, epoch=upcoming.epoch)    

Additional Configuration

Config.py has additional configuration, none of which is crucial to your both.

Security

NEVER SHARE YOUR PRIVATE KEYS TO ANYONE. If anyone has access to your private key, they can (and will) steal all your funds and you won't be able to do anything about it.

In order for the bot to work you have to input your private key. See metamask help for exporting your private keys.

Account and the corresponding private key need to be updated in .env file. NEVER CHECK THIS FILE INTO VERSION CONTROL OR SHARE IT WITH ANYONE

The BaseBot class that your strategy inherits from is initialized with your private key, and private key is passed to functions claim and make_bet in contract/utils.py

Review the BaseBot function carefully so you understand whats happening to your private key.

Useful Links

bsc-predict-bot's People

Contributors

bsc-predict avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bsc-predict-bot's Issues

Claim Function

First of all, nice work with the script. Very easy to add my own strategies.

The only issue I'm facing is the claim function doesn't seem to work. I've done some brief debugging, just enough to know for sure that it is executing claimed = claim(account=self.account, secret_key=self.secret_key) in BaseBot.py. However nothing is actually being claimed on the contract.

Are you aware of the issue or does it function properly on your system?

Thanks,

Not working

Not working on Python 3.8 and 3.11. all sort of errors
File "c:\Python38\Predict\contracts\prediction.py", line 20, in
rounds = [Round(r.split(",")) for r in r.text.split("\n")[1:] if len(r) > 0]

File "c:\Python38\Predict\classes\RoundClass.py", line 29, in init
epoch,
VlueError: too many values to unpack (expected 14)

Using Windows I added \r\n for the next line, still not working. It gets the csv but doesn't see, to parse it correctly.

If I modify RoundCLass like below, it jumps the error but contract is reverted. No bet.

def __init__(self, t: List):
  epoch, \
  startTimestamp, \
  lockTimestamp, \
  closeTimestamp, \
  lockPrice, \
  closePrice, \
  lockOracleId, \
  closeOracleId, \
  totalAmount, \
  bullAmount, \
  bearAmount, \
  rewardBaseCalAmount, \
  rewardAmount, \
  oracleCalled, \
  *extra  = t

It's buggy and I'm done iwth it. Verdict. Not working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.