Skip to content

blockchain.stellar.tradingbot #

fn new #

fn new(args_ StellarTradingBotArgs) !StellarTradingBot

Initialize the bot

enum StellarTradingBotOperation #

enum StellarTradingBotOperation {
	sell
	buy
}

struct StellarTradingBot #

struct StellarTradingBot {
mut:
	hclient stellar.HorizonClient // Horizon client
	sclient stellar.StellarClient // Stellar client
pub mut:
	account_secret  string // private key
	account_address string // public key

	selling_asset_code   string // asset to sell
	selling_asset_issuer string // issuer of the asset to sell
	selling_asset_type   string // type of the asset to sell
	buying_asset_code    string // asset to buy
	buying_asset_issuer  string // issuer of the asset to buy
	buying_asset_type    string // type of the asset to buy
	// selling stellar.OfferAssetType
	// buying  stellar.OfferAssetType

	buying_target_price  f64 // price to buy at
	selling_target_price f64 // price to sell at
	selling_amount       f64
	buying_amount        f64
	preserve             f64 // min balance to have in account
}

fn (StellarTradingBot) run #

fn (mut bot StellarTradingBot) run() !

Runs a specific operation (buy or sell) in a loop

struct StellarTradingBotArgs #

@[params]
struct StellarTradingBotArgs {
pub mut:
	account_secret string @[required] // The account secret

	selling_asset_code   string // asset to sell
	selling_asset_issuer string
	selling_asset_type   string
	buying_asset_code    string // asset to buy
	buying_asset_issuer  string
	buying_asset_type    string

	selling_target_price f64 @[required] // Your desired sell price
	selling_amount       f64
	buying_target_price  f64 @[required] // Your desired buy price
	buying_amount        f64
	network              stellar.StellarNetwork = .testnet
}