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)
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)
def gateway_pywaves_address(gateway_waves_address_secret: model.KeyPair, waves_node: str, waves_chain: str, waves_chain_id: Optional[str] = None):
"""Creates an address instance from the pywaves library that represents the Gateway waves address."""
pywaves.setNode(waves_node, waves_chain, waves_chain_id)
address = pywaves.Address(privateKey=gateway_waves_address_secret.secret)
if address.address != gateway_waves_address_secret.public:
raise ValueError("Gateway account private key doesn't match the address provided")
return address