I'm new to VB.NET and am not getting the syntax like I want.
Using this library: https://github.com/jjxtra/ExchangeSharp
I'm trying to iterate through open orders.
Dim openOrders As IEnumerable(Of ExchangeOrderResult) = api.GetOpenOrderDetails()
This doesn't give me an error, but anything I try and do with the variable it just says "invalid command" All of these don't work and I'm not sure how to iterate over this.
Console.WriteLine(openOrders.Count)
'also tried this
Dim enumerator As IEnumerator(Of ExchangeOrderResult) = openOrders.GetEnumerator
While (enumerator.MoveNext) 'crashes here
End While
I don't understand VB syntax and I've been searching for an hour or two, so I've given up for now. Any help appreciated!
I'm using the poloniex API.
This is the stack trace I'm getting from any example/attempt at this:
ExchangeSharp.APIException occurred HResult=0x80131500 Message=Invalid command. Source=ExchangeSharp StackTrace: at ExchangeSharp.ExchangePoloniexAPI.CheckError(JToken result) at ExchangeSharp.ExchangePoloniexAPI.MakePrivateAPIRequest(String command, Object[] parameters) at ExchangeSharp.ExchangePoloniexAPI.d__26.MoveNext() at ConsoleApp3.Module1.Main() in C:\Users\KMS10\source\repos\ConsoleApp3\ConsoleApp3\Module1.vb:line 42
Use For Each to iterate over an IEnumerable. Make sure you've imported System.Collections.Generic:
Dim openOrders As IEnumerable(Of ExchangeOrderResult) = api.GetOpenOrderDetails()
For Each openOrder In openOrders
...
Next
An enumerable is similar to a collection, except the only way to read the contents is to loop through it. VB.NET has the For Each...Next structure that can be used for this.
For Each item As ExchangeOrderResult In openOrders
' Do something with item variable
Next
User contributions licensed under CC BY-SA 3.0