Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
bot = SimpleBot()
bot.read_config("config.cfg")
pw.setNode(node=bot.node, chain=bot.chain)
pw.setMatcher(node=bot.matcher)
my_address = pw.Address(privateKey=bot.private_key)
waves_btc = pw.AssetPair(bot.amount_asset, bot.price_asset)
while True:
waves_balance = my_address.balance()
bot.log("Your balance is %18d" % waves_balance)
btc_balance = my_address.balance(bot.price_asset_id)
bot.log("Your balance is %18d" % btc_balance)
my_address.cancelOpenOrders(waves_btc)
order_book = waves_btc.orderbook()
best_bid = order_book["bids"][0]["price"]
best_ask = order_book["asks"][0]["price"]
spread_mean_price = ((best_bid + best_ask) // 2) * 10 ** (bot.price_asset.decimals - bot.amount_asset.decimals)
bid_price = spread_mean_price * (1 - bot.price_step)
ask_price = spread_mean_price * (1 + bot.price_step)
bid_amount = int((btc_balance / bid_price) * 10 ** pw.WAVES.decimals) - bot.order_fee
def main():
bot = SimpleBot()
bot.read_config("config.cfg")
pw.setNode(node=bot.node, chain=bot.chain)
pw.setMatcher(node=bot.matcher)
my_address = pw.Address(privateKey=bot.private_key)
waves_btc = pw.AssetPair(bot.amount_asset, bot.price_asset)
while True:
waves_balance = my_address.balance()
bot.log("Your balance is %18d" % waves_balance)
btc_balance = my_address.balance(bot.price_asset_id)
bot.log("Your balance is %18d" % btc_balance)
my_address.cancelOpenOrders(waves_btc)
order_book = waves_btc.orderbook()
best_bid = order_book["bids"][0]["price"]
best_ask = order_book["asks"][0]["price"]
spread_mean_price = ((best_bid + best_ask) // 2) * 10 ** (bot.price_asset.decimals - bot.amount_asset.decimals)
bid_price = spread_mean_price * (1 - bot.price_step)
ask_price = spread_mean_price * (1 + bot.price_step)
def main():
bot = SimpleBot()
bot.read_config("config.cfg")
pw.setNode(node=bot.node, chain=bot.chain)
pw.setMatcher(node=bot.matcher)
my_address = pw.Address(privateKey=bot.private_key)
waves_btc = pw.AssetPair(bot.amount_asset, bot.price_asset)
while True:
waves_balance = my_address.balance()
bot.log("Your balance is %18d" % waves_balance)
btc_balance = my_address.balance(bot.price_asset_id)
bot.log("Your balance is %18d" % btc_balance)
my_address.cancelOpenOrders(waves_btc)
order_book = waves_btc.orderbook()
best_bid = order_book["bids"][0]["price"]
best_ask = order_book["asks"][0]["price"]
spread_mean_price = ((best_bid + best_ask) // 2) * 10 ** (bot.price_asset.decimals - bot.amount_asset.decimals)
bid_price = spread_mean_price * (1 - bot.price_step)
ask_price = spread_mean_price * (1 + bot.price_step)
bid_amount = int((btc_balance / bid_price) * 10 ** pw.WAVES.decimals) - bot.order_fee
bot.log("Best_bid: {0}, best_ask: {1}, spread mean price: {2}".format(best_bid, best_ask, spread_mean_price))
def main():
bot = SimpleBot()
bot.read_config("config.cfg")
pw.setNode(node=bot.node, chain=bot.chain)
pw.setMatcher(node=bot.matcher)
my_address = pw.Address(privateKey=bot.private_key)
waves_btc = pw.AssetPair(bot.amount_asset, bot.price_asset)
while True:
waves_balance = my_address.balance()
bot.log("Your balance is %18d" % waves_balance)
btc_balance = my_address.balance(bot.price_asset_id)
bot.log("Your balance is %18d" % btc_balance)
my_address.cancelOpenOrders(waves_btc)
order_book = waves_btc.orderbook()
best_bid = order_book["bids"][0]["price"]
best_ask = order_book["asks"][0]["price"]
spread_mean_price = ((best_bid + best_ask) // 2) * 10 ** (bot.price_asset.decimals - bot.amount_asset.decimals)
bid_price = spread_mean_price * (1 - bot.price_step)
ask_price = spread_mean_price * (1 + bot.price_step)
bid_amount = int((btc_balance / bid_price) * 10 ** pw.WAVES.decimals) - bot.order_fee
my_address = pw.Address(privateKey=bot.private_key)
waves_btc = pw.AssetPair(bot.amount_asset, bot.price_asset)
while True:
waves_balance = my_address.balance()
bot.log("Your balance is %18d" % waves_balance)
btc_balance = my_address.balance(bot.price_asset_id)
bot.log("Your balance is %18d" % btc_balance)
my_address.cancelOpenOrders(waves_btc)
order_book = waves_btc.orderbook()
best_bid = order_book["bids"][0]["price"]
best_ask = order_book["asks"][0]["price"]
spread_mean_price = ((best_bid + best_ask) // 2) * 10 ** (bot.price_asset.decimals - bot.amount_asset.decimals)
bid_price = spread_mean_price * (1 - bot.price_step)
ask_price = spread_mean_price * (1 + bot.price_step)
bid_amount = int((btc_balance / bid_price) * 10 ** pw.WAVES.decimals) - bot.order_fee
bot.log("Best_bid: {0}, best_ask: {1}, spread mean price: {2}".format(best_bid, best_ask, spread_mean_price))
if bid_amount >= bot.min_amount:
bot.log("Post buy order with price: {0}, amount:{1}".format(bid_price, bid_amount))
my_address.buy(assetPair=waves_btc, amount=bid_amount, price=bid_price, matcherFee=bot.order_fee,
maxLifetime=bot.order_lifetime)
waves_balance, btc_balance = my_address.tradableBalance(waves_btc)
ask_amount = int(waves_balance) - bot.order_fee
if ask_amount >= bot.min_amount:
bot.log("Post sell order with price: {0}, ask amount: {1}".format(ask_price, ask_amount))
my_address.sell(assetPair=waves_btc, amount=ask_amount, price=ask_price, matcherFee=bot.order_fee,
maxLifetime=bot.order_lifetime)
bot.log("Sleep {0} seconds...".format(bot.seconds_to_sleep))
BLACKBOT = pw.Address(privateKey=PRIVATE_KEY)
log("-" * 80)
log(" Address : %s" % BLACKBOT.address)
log(" Amount Asset ID : %s" % amountAssetID)
log(" Price Asset ID : %s" % priceAssetID)
log("-" * 80)
log("")
except:
log("Error reading config file")
log("Exiting.")
exit(1)
pw.setNode(NODE, "mainnet")
pw.setMatcher(MATCHER)
PAIR = pw.AssetPair(pw.Asset(amountAssetID), pw.Asset(priceAssetID))
# grid list with GRID_LEVELS items. item n is the ID of the order placed at the price calculated with this formula
# price = int(basePrice * (1 + INTERVAL) ** (n - GRID_LEVELS / 2))
grid = ["-"] * GRID_LEVELS
log("Cancelling open orders...")
# cancel all open orders on the specified pair
BLACKBOT.cancelOpenOrders(PAIR)
log("Deleting order history...")
# delete order history on the specified pair
BLACKBOT.deleteOrderHistory(PAIR)
log("")
try:
self.log("Reading config file '{0}'".format(cfg_file))
config = configparser.RawConfigParser()
config.read(cfg_file)
self.node = config.get('main', 'node')
self.chain = config.get('main', 'network')
self.matcher = config.get('main', 'matcher')
self.order_fee = config.getint('main', 'order_fee')
self.order_lifetime = config.getint('main', 'order_lifetime')
self.private_key = config.get('account', 'private_key')
self.amount_asset_id = config.get('market', 'amount_asset')
self.amount_asset = pw.Asset(self.amount_asset_id)
self.price_asset_id = config.get('market', 'price_asset')
self.price_asset = pw.Asset(self.price_asset_id)
self.price_step = config.getfloat('market', 'price_step')
except OSError:
self.log("Error reading config file")
self.log("Exiting.")
exit(1)
ORDER_LIFETIME = config.getint('main', 'order_lifetime')
PRIVATE_KEY = config.get('account', 'private_key')
amountAssetID = config.get('market', 'amount_asset')
priceAssetID = config.get('market', 'price_asset')
INTERVAL = config.getfloat('grid', 'interval')
TRANCHE_SIZE = config.getint('grid', 'tranche_size')
FLEXIBILITY = config.getint('grid', 'flexibility')
GRID_LEVELS = config.getint('grid', 'grid_levels')
GRID_BASE = config.get('grid', 'base').upper()
GRID_TYPE = config.get('grid', 'type').upper()
LOGFILE = config.get('logging', 'logfile')
BLACKBOT = pw.Address(privateKey=PRIVATE_KEY)
log("-" * 80)
log(" Address : %s" % BLACKBOT.address)
log(" Amount Asset ID : %s" % amountAssetID)
log(" Price Asset ID : %s" % priceAssetID)
log("-" * 80)
log("")
except:
log("Error reading config file")
log("Exiting.")
exit(1)
pw.setNode(NODE, "mainnet")
pw.setMatcher(MATCHER)
PAIR = pw.AssetPair(pw.Asset(amountAssetID), pw.Asset(priceAssetID))
LOGFILE = config.get('logging', 'logfile')
BLACKBOT = pw.Address(privateKey=PRIVATE_KEY)
log("-" * 80)
log(" Address : %s" % BLACKBOT.address)
log(" Amount Asset ID : %s" % amountAssetID)
log(" Price Asset ID : %s" % priceAssetID)
log("-" * 80)
log("")
except:
log("Error reading config file")
log("Exiting.")
exit(1)
pw.setNode(NODE, "mainnet")
pw.setMatcher(MATCHER)
PAIR = pw.AssetPair(pw.Asset(amountAssetID), pw.Asset(priceAssetID))
# grid list with GRID_LEVELS items. item n is the ID of the order placed at the price calculated with this formula
# price = int(basePrice * (1 + INTERVAL) ** (n - GRID_LEVELS / 2))
grid = ["-"] * GRID_LEVELS
log("Cancelling open orders...")
# cancel all open orders on the specified pair
BLACKBOT.cancelOpenOrders(PAIR)
log("Deleting order history...")
# delete order history on the specified pair
BLACKBOT.deleteOrderHistory(PAIR)
BLACKBOT = pw.Address(privateKey=PRIVATE_KEY)
log("-" * 80)
log(" Address : %s" % BLACKBOT.address)
log(" Amount Asset ID : %s" % amountAssetID)
log(" Price Asset ID : %s" % priceAssetID)
log("-" * 80)
log("")
except:
log("Error reading config file")
log("Exiting.")
exit(1)
pw.setNode(NODE, "mainnet")
pw.setMatcher(MATCHER)
PAIR = pw.AssetPair(pw.Asset(amountAssetID), pw.Asset(priceAssetID))
# grid list with GRID_LEVELS items. item n is the ID of the order placed at the price calculated with this formula
# price = int(basePrice * (1 + INTERVAL) ** (n - GRID_LEVELS / 2))
grid = ["-"] * GRID_LEVELS
log("Cancelling open orders...")
# cancel all open orders on the specified pair
BLACKBOT.cancelOpenOrders(PAIR)
log("Deleting order history...")
# delete order history on the specified pair
BLACKBOT.deleteOrderHistory(PAIR)
log("")