GithubHelp home page GithubHelp logo

hephyrius / binance_futures_bot Goto Github PK

View Code? Open in Web Editor NEW
299.0 299.0 124.0 218 KB

A bot that trades leveraged USDT futures markets on binance.

Python 100.00%
binance binance-bots bot cryptocurrency-trading-bot trading-bot

binance_futures_bot's Introduction

Hephyrius

Anurag's github stats


  • 📫 Discord: Hephyrius#6790 / Github / Telegram / Twitter
  • 🎓 PhD @ Queen Mary, University of London
  • 🔬 Researching AI Applications to Source Separation
  • 🎩 Occasionally moonlight as a whitehat💰
  • 👷 Shadowy Builder, MEV chaser and occasional quant 📈
  • 🤖 Some AI Stuff I Built SingularitAI
  • 🎬 Some AI Videos I Made
  • 🍗 Ex-contributor at Aura & Ex-Whitehat Scholar at Immunefi
  • ♾️ I don't have the time to maintain any code I open source under my aliases, feel free to contribute and I'll accept the pull request

binance_futures_bot's People

Contributors

devrawnie avatar hephyrius avatar kelows avatar tooflex 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance_futures_bot's Issues

order/close is looping (XRPUSDT/WAVESUSDT) non-stop

Hello sir,
first of all , i would like to thankyou for getting this program in public and available yo anyone.

regarding the latest update, i see that it is looking at 5m and 15m time frame.

the bot is looping for ordering and closing trades, my theory is that 15m and 5m time frame are going in opposite direction,
so the bot will open position then will close it immediately,

so it will go
order
exit
order
exit

i am trying to troubleshoot and modify but no luck(not really a developer, just a trying hard newby pythoneer).

Love your bot. I just have one request.

I have been trying to use your bot but I want to use it with Trading View Alerts to trigger the Buy and Sell signals instead of the built in strategy. I have tried modifying to code to do so but i am not successful. Can you provide a bot that can use the Tradng View Alerts as triggers ? I found one somewhere else but it only works on the spot market and i want to use your code since it`s designed for the Binance Futures market. Please help me out.

help me

unnamed
i can't run, i already have api key, setting. but i cant run it

No module named 'binance_f'

File "bot.py", line 3, in
import bot_functions as bf
File "/home/ubuntu/binance_futures_bot/bot_functions.py", line 1, in
from binance_f import RequestClient
ModuleNotFoundError: No module named 'binance_f'

only opening sell positions

_side = "BUY"
if qty > 0.09:
    _side = "SELL"

if qty < 0.13:
    qty = qty * -1

How can I configure my limits so It won't (hopefully) close on a loss, or minimize the risk. My qty is 0.1 but I'm planning to lower it.

another parameter to close the position?

can it have another parameter to close the position, for example, this position will be closed automatically after earning certain percentage, could you please help? thanks

HTTPSConnectionPool

HTTPSConnectionPool(host='fapi.binance.com', port=443): Max retries exceeded with url: /fapi/v1/klines?symbol=ETHUSDT&interval=1h&limit=95 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000001C571C7F160>, 'Connection to fapi.binance.com timed out. (connect timeout=None)'))

I checked the request weight api hard limit (1200 request weight per minute). Even though I am way below under limit with 95 candles and put some time.sleep() in the code, I still get this mind blowing error. I also calculated the other rest api functions weights as well. Any one knows how to handle this issue?

Encountered Exception ('RuntimeError', '[Json] Get json item field: withdrawAvailable does not exist')

please help
`
(binance-bot) (base) Nonnames-MacBook-Pro-2:binance_futures_bot noname$ python3 bot.py
Bot Starting
Encountered Exception ('RuntimeError', '[Json] Get json item field: withdrawAvailable does not exist')
Encountered Exception ('RuntimeError', '[Json] Get json item field: withdrawAvailable does not exist')
Encountered Exception ('RuntimeError', '[Json] Get json item field: withdrawAvailable does not exist')

`

Invalid Syntax

Hi, just wanted to test this on binance futures testnet, but i am getting a Invalid Syntax error :

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "/usr/lib/python2.7/runpy.py", line 102, in _get_module_details
loader = get_loader(mod_name)
File "/usr/lib/python2.7/pkgutil.py", line 462, in get_loader
return find_loader(fullname)
File "/usr/lib/python2.7/pkgutil.py", line 472, in find_loader
for importer in iter_importers(fullname):
File "/usr/lib/python2.7/pkgutil.py", line 428, in iter_importers
import(pkg)
File "bot.py", line 74
bf.singlePrint(f"Exited Position: {qty} ${market_price}", std)
^
SyntaxError: invalid syntax

Python 2.7.16

help

C:\Users\Administrator\Desktop\talon>bot.py
Bot Starting
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)

"Margin is insufficient" - I have plenty of margin.

Please help.. I have plenty of margin room.

{"code":-2019,"msg":"Margin is insufficient."} Encountered Exception ('ExecuteError', '[Executing] -2019: Margin is insufficient.') Traceback (most recent call last): File "C:\Users\mxwo\Documents\Apps\binance_futures_bot\bot.py", line 47, in <module> qty, side, in_position = bf.handle_signal(client, std, File "C:\Users\mxwo\Documents\Apps\binance_futures_bot\bot_functions.py", line 218, in handle_signal execute_order(client, _qty=qty, _side=order_side, _market=market) File "C:\Users\mxwo\Documents\Apps\binance_futures_bot\bot_functions.py", line 107, in execute_order client.post_order(symbol=_market, File "C:\Users\mxwo\Documents\Programs\lib\site-packages\binance_f\requestclient.py", line 246, in post_order response = call_sync(self.request_impl.post_order(symbol, side, ordertype, File "C:\Users\mxwo\Documents\Programs\lib\site-packages\binance_f\impl\restapiinvoker.py", line 44, in call_sync check_response(json_wrapper) File "C:\Users\mxwo\Documents\Programs\lib\site-packages\binance_f\impl\restapiinvoker.py", line 21, in check_response raise BinanceApiException(BinanceApiException.EXEC_ERROR, "[Executing] " + str(code) + ": " + msg) binance_f.exception.binanceapiexception.BinanceApiException: ('ExecuteError', '[Executing] -2019: Margin is insufficient.')

i have SSL error

Encountered Exception HTTPSConnectionPool(host='fapi.binance.com', port=443): Max retries exceeded with url: //fapi/v1/klines?symbol=BTCUSDT&interval=5m (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))

`side` doesn't change in handle signal

I could be wrong, but is it possible side does not get set to 1 in case of a long position in handle_signal on line 274? I noticed this after trades exited very fast in most situations.

Possible solution:

...
    market_price = get_market_price(client, _market=market)
    in_position = True

    if order_side == "BUY":
        side = 1
    else:
        side = -1

    singlePrint(f"{order_side}: {qty} ${market_price} using x{leverage} leverage", std)
...

[ISSUE] BOT.PY

When i start bot.py
ModuleNotFoundError: No module named 'binance_f'

even installed all requirements

COMMAND:
python -m pip install binance_f

ain't help

OUTPUT:
ERROR: Could not find a version that satisfies the requirement binance_f
ERROR: No matching distribution found for binance_f

Change trailing stop

Thanks for the bot
I would like to know if possible to move trailing stop above the execution price to prevent losses

Binance API Error Started at 31 May 2022 5:15AM UTC

Started receiving this error today out of nowhere when calling candle stick data from Binance API. Are there any updates I should know of? Anyone having the same problem?

Error:

raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

check_in_position always returns False

Hey Harnick,

Not a python expert but I think there is something wrong with check_in_position. Its always returning False even though when its true. I tried printing out the positions array, everything seems right. The key is positionAmt, not sure if some funky string to float thing is happening during the compare.

isolated mode doesnt work

"market": "SANDUSDT",
"leverage": "15",
"trading_periods": "1m,3m",
"margin_type": "ISOLATED",
"trailing_percentage": "2.0",
"api_url" : "https://fapi.binance.com/"

and always gets into cross mode, any idea ?

Executing] -1120: Invalid interval.')

Bot Starting
Encountered Exception ('ExecuteError', '[Executing] -1120: Invalid interval.')
Encountered Exception ('ExecuteError', '[Executing] -1120: Invalid interval.')

inquiry regarding strategy

Hi @Hephyrius , good day sir.

just want to confirm the strategy. it seems to be using supertrend to me instead of talon sniper. can you confirm if that is the case?

this is the best bot i have seen. just a littler bit of tweaking the strategy.

image

ive been testing this in freqtrade (buys only as freqtrade dont support futures)
image
5m,15m timeframe
image

5m,30m timeframe
image

5m,1h timeframe
image

limit usage of capital on every order

its a recomendation, to use a limite capital on every order, so is not spending all the capital on the wallter to make every order, or at least to have the config to do it

Order's position side does not match user's setting

"code":-4061,"msg":"Order's position side does not match user's setting."}
Encountered Exception ('ExecuteError', "[Executing] -4061: Order's position side does not match user's setting.")

Hello... Im having that issue, any ideas ? thanks !

3d time interval issues

setting.json
"trading_periods": "5m,15m",

If 3d are included in trading_periods, it will not run.
Is it just me?

Visualize JSON data with dashboard..

Hi I'm new to coding really and would love to have the JSON information that's sent (assuming via TV webhook) formatted into a webpage that uses the JSON data and builds a table to have a nice little dashboard.

Any ideas of where to start or how to incporporate?

Thanks!

Precision is over the maximum defined for this asset

I'm running tests but I still haven't got it working, it's not clear to me the amount to be invested in the order and I get this error. Any advice is welcome.

{"code":-1111,"msg":"Precision is over the maximum defined for this asset."}
Erro: ('ExecuteError', '[Executing] -1111: Precision is over the maximum defined for this asset.')
Traceback (most recent call last):
File "C:\binance_futures_bot-main\bot.py", line 44, in
qty, side, in_position = bf.handle_signal(client, std,
File "C:\binance_futures_bot-main\bot_functions.py", line 218, in handle_signal
execute_order(client, _qty=qty, _side=order_side, _market=market)
File "C:\binance_futures_bot-main\bot_functions.py", line 107, in execute_order
client.post_order(symbol=_market,
File "C:\binance_futures_bot-main\venv\lib\site-packages\binance_f\requestclient.py", line 246, in post_order
response = call_sync(self.request_impl.post_order(symbol, side, ordertype,
File "C:\binance_futures_bot-main\venv\lib\site-packages\binance_f\impl\restapiinvoker.py", line 44, in call_sync
check_response(json_wrapper)
File "C:\binance_futures_bot-main\venv\lib\site-packages\binance_f\impl\restapiinvoker.py", line 21, in check_response
raise BinanceApiException(BinanceApiException.EXEC_ERROR, "[Executing] " + str(code) + ": " + msg)
binance_f.exception.binanceapiexception.BinanceApiException: ('ExecuteError', '[Executing] -1111: Precision is over the maximum defined for this asset.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\binance_futures_bot-main\bot.py", line 118, in
time.sleep(15)

[feature] use binance futures testnet

Hello,

Maybe it would be great to implement a connection to the testnet to make tests before going live?

i think it is in the RequestClient constructor

and add a key in the settings to know which network we should use, i'll try to make a PR (see #7)

Cheers!

json read error

im keep getting this message using Ubuntu and python 3.8

Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)
Encountered Exception Expecting value: line 1 column 1 (char 0)

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.