Skip to content

Instantly share code, notes, and snippets.

@JeffreyShran
Forked from talesa/pump_dump.py
Created February 21, 2021 14:42
Show Gist options
  • Save JeffreyShran/a44f799f6e54da3f1d72c05f9154fbcb to your computer and use it in GitHub Desktop.
Save JeffreyShran/a44f799f6e54da3f1d72c05f9154fbcb to your computer and use it in GitHub Desktop.

Revisions

  1. @talesa talesa revised this gist Jan 7, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pump_dump.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # you have to execute this code line by line so use jupyter notebook or hydrogen inside atom editor

    # import libraries
    import ccxt
    from datetime import datetime
  2. @talesa talesa revised this gist Jan 7, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pump_dump.py
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ def has_been_realised(orders, time, wait_time=5.0):

    # this function waits until the order has been realised or cancels the order after 5 seconds (you can change this time in the command below)
    has_been_realised([(order['id'], symbol)], datetime.now(), wait_time=5.0)
    # It produces output of this sort
    # It produces output of this sort:
    # Try at 2018-01-07 19:00:18.168240
    # Try at 2018-01-07 19:00:18.477217
    # Realised at 2018-01-07 19:00:18.928225
  3. @talesa talesa revised this gist Jan 7, 2018. 1 changed file with 26 additions and 6 deletions.
    32 changes: 26 additions & 6 deletions pump_dump.py
    Original file line number Diff line number Diff line change
    @@ -1,38 +1,58 @@
    # import libraries
    import ccxt
    from datetime import datetime

    # create exchange API handle
    exchange = getattr(ccxt, 'binance')()
    # paste in your API key and secret here (if you're afraid they're gonna get stolen, inspect the ccxt library open source code on github)
    exchange.apiKey = ''
    exchange.secret = ''

    def has_been_realised(orders, time):
    # This function waits until your orders has been executed
    def has_been_realised(orders, time, wait_time=5.0):
    while True:
    orders = [(id, symbol) for id, symbol in orders if exchange.fetch_order(id=id, symbol=symbol)['status'] != 'closed']
    if len(orders) == 0:
    print('Realised at {}'.format(datetime.now()))
    return True
    if datetime.now().timestamp() > time.timestamp() + 5.0 :
    if datetime.now().timestamp() > time.timestamp() + wait_time :
    [exchange.cancel_order(id=id, symbol=symbol) for id, symbol in orders]
    print('Cancelling orders at {}'.format(self.now()))
    return False
    print('Try at {}'.format(datetime.now()))


    # the factor of what multiple of pre-pump price to limit buy at
    factor = 1.1
    tickers = exchange.fetch_tickers()

    # run ahead of time to fetch your balance
    balance = exchange.fetch_balance()

    # run this few seconds before the pump coin is announced to obtain most recent tickers
    tickers = exchange.fetch_tickers()

    # this is where you start executing the script the moment you receive info on which coin is pumped
    # insert the code of pumped coin here
    currency = ''

    symbol = currency+'/BTC'

    # these lines determine the buy order price and amount
    buy_order_price = factor * tickers[symbol]['ask']
    buy_order_amount = balance['BTC']['free'] / buy_order_price / 1.01
    buy_order_amount = balance['BTC']['free'] / buy_order_price / 1.01 # this 1.01 is safety factor so that you won't get insufficient amount error
    # this places the limit buy order
    order = exchange.create_order(symbol, 'limit', 'buy', amount=buy_order_amount, price=buy_order_price)

    has_been_realised([(order['id'], symbol)], datetime.now())
    # this function waits until the order has been realised or cancels the order after 5 seconds (you can change this time in the command below)
    has_been_realised([(order['id'], symbol)], datetime.now(), wait_time=5.0)
    # It produces output of this sort
    # Try at 2018-01-07 19:00:18.168240
    # Try at 2018-01-07 19:00:18.477217
    # Realised at 2018-01-07 19:00:18.928225

    # Fetch balance again so you know how much of currency you've actually bought
    balance = exchange.fetch_balance()

    # Create market sell order
    order = exchange.create_order(symbol, 'market', 'sell', amount=balance[currency]['free'])

    has_been_realised([(order['id'], symbol)], datetime.now())
  4. @talesa talesa created this gist Jan 7, 2018.
    38 changes: 38 additions & 0 deletions pump_dump.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import ccxt
    from datetime import datetime

    exchange = getattr(ccxt, 'binance')()
    exchange.apiKey = ''
    exchange.secret = ''

    def has_been_realised(orders, time):
    while True:
    orders = [(id, symbol) for id, symbol in orders if exchange.fetch_order(id=id, symbol=symbol)['status'] != 'closed']
    if len(orders) == 0:
    print('Realised at {}'.format(datetime.now()))
    return True
    if datetime.now().timestamp() > time.timestamp() + 5.0 :
    [exchange.cancel_order(id=id, symbol=symbol) for id, symbol in orders]
    print('Cancelling orders at {}'.format(self.now()))
    return False
    print('Try at {}'.format(datetime.now()))


    factor = 1.1
    tickers = exchange.fetch_tickers()
    balance = exchange.fetch_balance()

    currency = ''

    symbol = currency+'/BTC'

    buy_order_price = factor * tickers[symbol]['ask']
    buy_order_amount = balance['BTC']['free'] / buy_order_price / 1.01
    order = exchange.create_order(symbol, 'limit', 'buy', amount=buy_order_amount, price=buy_order_price)

    has_been_realised([(order['id'], symbol)], datetime.now())

    balance = exchange.fetch_balance()

    order = exchange.create_order(symbol, 'market', 'sell', amount=balance[currency]['free'])
    has_been_realised([(order['id'], symbol)], datetime.now())