def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: bot_id = 1234567890 coin, currency = pair.split('/') p3cw = Py3CW( key='1', secret='2', ) logger.info(f"3Commas: Sending buy signal for {pair} to 3commas bot_id={bot_id}") error, data = p3cw.request( entity='bots', action='start_new_deal', action_id=f'{bot_id}', payload={ "bot_id": bot_id, "pair": f"{currency}_{coin}{currency}", }, ) if error: logger.error(f"3Commas: {error['msg']}") PairLocks.lock_pair( pair=pair, until=datetime.now(timezone.utc) + timedelta(minutes=1), reason="Send 3c buy order" ) return False
def __init__(self, config): self.p3cw = Py3CW( key=config.api_key, secret=config.api_secret, request_options={ "request_timeout": 10, "nr_of_retries": 1, "retry_status_codes": [502], }, )
def __init__(self): self.db_object = MongoConnection.App_mongo_connect() # API key & Secret Key self.key = 'API_Key to replaced here' self.secret = 'Secret_key to be replaced here' # py3wc Object self.py3cw = Py3CW(self.key, self.secret) # Argument input_file parser = argparse.ArgumentParser() parser.add_argument('--input_file', type=str, default='', help='Default - ""') parser.add_argument('--force', type=bool, default=False, help='Default - False') args = vars(parser.parse_args()) print("Input arguments:") print(args) print("*" * 40) self.input_file = args['input_file'] self.force = args['force'] self.abs_path = os.path.dirname(os.path.abspath(__file__)) self.bots_table_path = os.path.join(self.abs_path, "Bot_tables") self.file = os.path.join(self.bots_table_path, self.input_file) self.mandatory_arguments = [ 'Bot_name', 'Bot_id', "base_order_volume", "take_profit", "safety_order_volume", "martingale_volume_coefficient", "martingale_step_coefficient", "max_safety_orders", "active_safety_orders_count", "safety_order_step_percentage", "take_profit_type", "strategy_list", "stop_loss_percentage", "cooldown", "trailing_enabled", "trailing_deviation", 'New_pairs' ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from py3cw.request import Py3CW #playin around with 3commas api #this scripts assumes that you are trading USDT pairs. #put in you key and secret from 3commas key = '' secret = '' p3cw = Py3CW( key=key, secret=secret, request_options={ 'request_timeout': 10, 'nr_of_retries': 1, 'retry_status_codes': [502] } ) def getAccounts(): error, data = p3cw.request( entity='accounts', action='' ) accounts=[] for account in data: account_id = account['id'] exchange_name = account['name']
from py3cw.request import Py3CW p3cwDestination = Py3CW( key='e4a561f20fb44012a28f6a74aa32844abf2328cef80d4a678a5c9c40a60b930e', secret= '9a553d0b69094a1cbc59f779b4f50030ae90e27212e2e25667bf06c54412ee0a89fb025cbd600ebcef8c4b2ff0da08b71386aefadc8dd54dee098bd8994ef4f42de61bc2884d7a1f8c29720b3c54b619ac7188ff88172458355347e58547ecf70f45b8da' ) p3cwTarget = Py3CW( key='e9e2e1465c964a5b995bc4b8d03dd03080ffa02c47094ca6a25cf013246ea222', secret= '6f6b57ea96ec7a14aa03b2191ca580d7762ef228331c07c9572b44ddeb52f1999c15fa65d558b7a898a8b72cef2515e49dd86fb6985d35e163c7b4d0b788da39777d1607444e46d547a1733a8f57703097479d0d871e602ff597f853c6783f7e50f7c173' )
from py3cw.request import Py3CW p3cw = Py3CW( key='3e45e0cb611845a19bc053f4752090704b20f1085c2d4951b4606b99d11db935', secret= 'a0dc20cb712001b1bad8eb82d1e453b5b70042897d417fc4d3ba84efb734190d30759bd61c69df14032ddb1ee3eafbb923e95683c4114e65a35fee54e0420d2ad5902a5432c266273d7f7cdf3e07285b8ecdf5e431679b1c0a7a8f76b51c5b77a20aaac7' ) # Data from the bot error, data_from_bot = p3cw.request(entity='show', action='') # Checking if no error if not error: print(data_from_bot) # Udating Some value # 'active_safety_orders_count': '2',s into the bot """error, data = p3cw.request( entity='bots', action='update', action_id='1390329', payload={'name': 'AUTO TEST 1', 'pairs': ['BTC_ADA', 'BTC_ADX', 'BTC_AE', 'BTC_AGI', 'BTC_AION', 'BTC_ALGO', 'BTC_AMB', 'BTC_ANKR'], 'base_order_volume': '0.0002', 'take_profit': '2.5', 'safety_order_volume': '0.0002', 'martingale_volume_coefficient': '2', 'martingale_step_coefficient': '2', 'max_safety_orders': '2', 'safety_order_step_percentage': '2', 'take_profit_type': 'total', 'stop_loss_percentage' : 10,
import numpy as np import pandas as pd import requests from binance.client import Client from py3cw.request import Py3CW from tqdm import tqdm from enum import Enum from config import Config config = Config() p3cw = Py3CW( key=config.tc_key, secret=config.tc_secret, request_options={ "request_timeout": 10, "nr_of_retries": 1, "retry_status_codes": [502], }, ) def cmpFloat(a, b): return abs(a - b) < 0.01 def getPrice(client, symbol: str): if symbol in ["USDT"]: return 1 endTime = int(time.time() * 1000) # ['Open Time', 'Open', 'High', 'Low', 'Close', 'Volume', 'Close Time', '', '', '', '', '']
# -> max amount for one deal divided by factor = base order max_deals = bot['max_active_deals'] usd_for_bot = account_usd_value * BOTS[name] / 100 base_order = usd_for_bot / max_deals / factor safety_order = base_order * 2 print("Bot uses: " + str(BOTS[name]) + "% of $" + str(account_usd_value) + " =>> $" + str(usd_for_bot)) print("Old BO: " + bot['base_order_volume'] + " Old SO: " + bot['safety_order_volume'] + " New BO: " + str(base_order) + " New SO: " + str(safety_order)) # set new base order and safety and write bot bot['base_order_volume'] = str(base_order) bot['safety_order_volume'] = str(safety_order) write_input = input( "Do you want to write the new Base and Safety Orders? Y/N ") if write_input.lower() == "y" or write_input.lower() == "yes": writeBot(bot) print("Bot Settings updated") else: print("read only no update") # main p3cw = Py3CW(key=API_KEY, secret=API_SECRET) updateBots()