Skip to content

Commit

Permalink
Merge pull request #8 from ricardospinoza/main
Browse files Browse the repository at this point in the history
Add suport testnet and create new constant hedge mode
  • Loading branch information
Erfaniaa committed Jan 10, 2023
2 parents 7206a1c + bedf498 commit 60be013
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FIRST_COIN_SYMBOL = "USDT"
SECOND_COIN_SYMBOL = "BTC"
CONTRACT_SYMBOL = SECOND_COIN_SYMBOL + FIRST_COIN_SYMBOL
TIMEFRAME = "h1"
TIMEFRAME = "h1" # m1 m15 h1 h2 h4 d1
TAKE_PROFIT_PERCENTS = [2, 3, 1.5, 2] # len(TAKE_PROFIT_PERCENTS) must equals STRATEGIES_COUNT
STOP_LOSS_PERCENTS = [-1, -1, -1.5, -1.5] # len(STOP_LOSS_PERCENTS) must equals STRATEGIES_COUNT
PRICE_DECIMAL_DIGITS = 2
Expand All @@ -27,3 +27,7 @@
LAST_ACCOUNT_BALANCES_LIST_MAX_LENGTH = 12
IMPORTANT_CANDLES_COUNT = 100
SEND_TELEGRAM_MESSAGE = False
HEDGE_MOODE = True # True to allow long and short positions simultaneously
IS_TESTNET = True # True to enable mode teste for Binance
URL_BASE_PRODUCTION = "https://fapi.binance.com"
URL_BASE_TESTNET = "https://testnet.binancefuture.com"
6 changes: 4 additions & 2 deletions credentials.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
API_KEY = ""
SECRET_KEY = ""
API_KEY_PRODUCTION = ""
SECRET_KEY_PRODUCTION = ""
API_KEY_TESTNET = ""
SECRET_KEY_TESTNET = ""
TELEGRAM_API_KEY = ""
TELEGRAM_USER_ID = ""
11 changes: 7 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,12 @@ def close_all_open_positions_market_price() -> int:

def init_bot() -> None:
global binance_futures_api
binance_futures_api = UMFutures(key=API_KEY, secret=SECRET_KEY)



if IS_TESTNET:
binance_futures_api = UMFutures(key=API_KEY_TESTNET, secret=SECRET_KEY_TESTNET)
else:
binance_futures_api = UMFutures(key=API_KEY_PRODUCTION, secret=SECRET_KEY_PRODUCTION)

def update_is_price_increasing(
price_direction_indicator_name_1: str,
price_direction_indicator_name_2: str
Expand Down Expand Up @@ -921,7 +924,7 @@ def main() -> None:
init_bot()
update_account_balance_and_unrealized_profit(FIRST_COIN_SYMBOL)
set_leverage(CONTRACT_SYMBOL, LEVERAGE)
set_position_mode(hedge_mode=True)
set_position_mode(HEDGE_MOODE)
while True:
sleep(SLEEP_INTERVAL)
update_current_time()
Expand Down

0 comments on commit 60be013

Please sign in to comment.