Author

Topic: VB.Net and Exchange trading APIs (Read 165 times)

member
Activity: 210
Merit: 26
High fees = low BTC price
March 15, 2018, 09:26:32 AM
#4
Nothing wrong with using VB for the API's and it uses the same p-code as .NET C# but in
general it's easier to find C# example code than VB code.

I tend to use raw sockets instead of HttpWebRequest mainly because in multil-threaded  programs the
web-requests seems to block and using more than a few connections does nothing to speed things
up unless you go raw.

 
jr. member
Activity: 126
Merit: 3
Joe's Signatureless Challenge
March 14, 2018, 10:31:45 AM
#3
Hello
I am looking for VB.Net documentation and code examples for using Exchange trading APIs. I found something in C but not in VB.Net.
I wish I could read the info from my account and place trades.

Code:
    Public Sub coinprice()
        Try
            Dim request As HttpWebRequest
            Dim response As HttpWebResponse = Nothing
            Dim reader As StreamReader
            ServicePointManager.Expect100Continue = True
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

            request = DirectCast(WebRequest.Create("https://stocks.exchange/api2/ticker"), HttpWebRequest)

            response = DirectCast(request.GetResponse(), HttpWebResponse)
            reader = New StreamReader(response.GetResponseStream())

            Dim rawresp As String
            rawresp = reader.ReadToEnd()

            Dim array As JArray = JArray.Parse(rawresp)

            For Each item As JObject In array
                Dim name As String = If(item("market_name") Is Nothing, "", item("market_name").ToString())
                Dim email As String = If(item("last") Is Nothing, "", item("last").ToString())
                If name = "SUM_BTC" Then
                    Console.WriteLine("Name: " & name)
                    Console.WriteLine("Email: " & email)
                    coinpriceLabel.Text = email & " BTC"
                End If

            Next
        Catch ex As Exception
            Console.WriteLine(ex)
            coinpriceLabel.Text = "Too Many Connections"
        End Try
    End Sub

This works for me. The initial code was on stack exchange I think and I did some alterations myself. Its not finished so don't punish me for it looking hacky.

It also deals with too many connection attempts through an exception.

You will need to add this

Code:
Imports Newtonsoft.Json.Linq

and the appropriate reference
full member
Activity: 193
Merit: 121
Just digging around
March 14, 2018, 10:18:30 AM
#2
Hi,

.Net is not really handy for Bitcoin Sad

Most of the exchanges as far as I checked some kind of JSON interface. Simple HTTP from that.

Example
https://www.bitstamp.net/api/

newbie
Activity: 5
Merit: 0
March 14, 2018, 04:13:30 AM
#1
Hello
I am looking for VB.Net documentation and code examples for using Exchange trading APIs. I found something in C but not in VB.Net.
I wish I could read the info from my account and place trades.
Jump to: