Jump to content

How to add Multitask UDF to existing .au3


marko001
 Share

Recommended Posts

Hi all guys, 

first of all, I also replied to @Chimp who created the Multitask UDF into #Example Script channel, so please don't blame me for this double post :)

 

I developed (supported by @Danyfirex) a tool to real-time monitor certain crypto assets, as in the image.

Right now I simply cycle 

	For $i = 0 To $MaxPairs - 1
		_RealTimePublicValue($s_TradingPlatform, $a_Pairs[$i][0], $a_Pairs[$i][1], $i)
	Next

and

Func _RealTimePublicValue($s_TradingPlatform, $Crypto, $LocalValue, $index) ; OHLC
	If $s_TradingPlatform = "Crypto.com" Then
		Local $pstring = $Crypto & "_" & $LocalValue
		Local $sResult = CryptoQueryPublic("get-ticker", "instrument_name=" & $pstring) ;Ticker
		$ask = _StringBetween($sResult, '"a":', ',')
		If IsArray($ask) Then
			$last = _StringBetween($sResult, '"a":', ',')
			$High = _StringBetween($sResult, '"h":', ',')
			$Low = _StringBetween($sResult, '"l":', ',')
			$Change = _StringBetween($sResult, '"c":', '}')
		Else
			_send("Pair " & $pstring & " not allowed, change currency", $giallo)
			Return
		EndIf
		_WriteToGui($pstring, $last[0] - $Change[0], $High[0], $Low[0], $last[0], $index)
	ElseIf $s_TradingPlatform = "Coinbase Pro" Then
		Local $pstring = $Crypto & "-" & $LocalValue
		Local $sResult = CoinbaseProQueryPublic("GET", "products/" & $pstring & "/stats") ; Stats
		$opening = _StringBetween($sResult, '"open":"', '"')
		If IsArray($opening) Then
;~ 			$opening = _StringBetween($sResult, '"open":"', '"')
			$High = _StringBetween($sResult, '"high":"', '"')
			$Low = _StringBetween($sResult, '"low":"', '"')
			$last = _StringBetween($sResult, '"last":"', '"')
		Else
			_send("Pair " & $pstring & " not allowed, change currency", $giallo)
			Return
		EndIf
		_WriteToGui($pstring, $opening[0], $High[0], $Low[0], $last[0], $index)
	EndIf
EndFunc   ;==>_RealTimePublicValue

and use _WriteToGui() to write all data into the GUI.

In this way the process is done in sequence. I would like to have it done in parallel for all my assets, since I would like to perform other actions (i.e. selling or buying) and now I have to wait all the cycle to complete. This leads in being stuck waiting the cycle. And it's not immediate since the call to Exchange may cost around .2 to .5 sec each pair i look for.

Thanks all for the support,

Marco

 

screenshot.1659.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...