public static async Task ExecuteStinkBid() { var authenticator = new Authenticator( "F5QR8MJE-HN5LH4WJ-8X9758YH-NDLRE7NJ", "0be35048de6102dfa9927504b4099aac222636f2dd96983f9713fe0c9b93d489f38ae08d9e3e3b4b3509ef77c182f9000a4b8b21c49d8af84ad0863c6937f932"); var client = new ApiHttpClient(authenticator); var balances = await client.Wallet.GetCompleteBalances(); var btcBalance = balances["BTC"]; var availableBtc = btcBalance.Available; var stinkBid = new StinkBid { AmountInBtc = 5m, BuyPrice = 0.00000001m, CurrencyPair = "BTC_ETH", }; var allowance = Math.Min(stinkBid.AmountInBtc, availableBtc); var rate = stinkBid.BuyPrice; var purchaseAmount = Math.Round(allowance / rate, 8); var orderNumber = await client.Trading.Buy(stinkBid.CurrencyPair, rate, purchaseAmount); var isCancelled = await client.Trading.CancelOrder(stinkBid.CurrencyPair, orderNumber); Console.WriteLine(isCancelled); }
public static async Task <ulong> ExecuteStinkBid(User user, StinkBid stinkBid) { var publicKey = user.PublicKey; var privateKey = user.PrivateKey; var authenticator = new Authenticator(publicKey, privateKey); var client = new ApiHttpClient(authenticator); var balances = await client.Wallet.GetCompleteBalances(); var btcBalance = balances["BTC"]; var availableBtc = btcBalance.Available; var allowance = Math.Min(stinkBid.AmountInBtc, availableBtc); var rate = stinkBid.BuyPrice; var purchaseAmount = Math.Round(allowance / rate, 8); var orderNumber = await client.Trading.Buy(stinkBid.CurrencyPair, rate, purchaseAmount); return(orderNumber); //var isCancelled = await client.Trading.CancelOrder(stinkBid.CurrencyPair, orderNumber); //Console.WriteLine(isCancelled); }
//TODO: ideally this should send the order to a queue service that actually makes the API calls static async void QueueOrder(User user, StinkBid stinkBid) { stinkBid.OrderStatus = StinkBidOrderStatus.Queued; var orderNumber = await TradeSubmitter.ExecuteStinkBid(user, stinkBid); if (orderNumber > 0) { stinkBid.OrderStatus = StinkBidOrderStatus.Submitted; Console.WriteLine(string.Format("Stinkbid submitted for {0} at {1}", stinkBid.CurrencyPair, stinkBid.BuyPrice)); } }
static async Task <Users> LoadUsers() { var users = new Users(); var mockUser = new User { PublicKey = "F5QR8MJE-HN5LH4WJ-8X9758YH-NDLRE7NJ", PrivateKey = "0be35048de6102dfa9927504b4099aac222636f2dd96983f9713fe0c9b93d489f38ae08d9e3e3b4b3509ef77c182f9000a4b8b21c49d8af84ad0863c6937f932", }; var mockStinkBid = new StinkBid { AmountInBtc = 5m, BuyPrice = 0.00000001m, CurrencyPair = "BTC_ETH", }; mockUser.StinkBids.StinkBids.Add(mockStinkBid.CurrencyPair, mockStinkBid); users.Add(mockUser); return(await Task.FromResult(users)); }