Search the Community
Showing results for tags 'unix time'.
-
Here is helper function for working with bitstamp api. Its actually two functions but one is just to set your keys. It will handle the authentication and should be able to handle any of the other private functions available that use POST. The public GET functions dont require authentication so you dont need this for those. Those could simply use InetRead. I have included some examples that include showing how to use the currency pairs and request parameters so I think how to use all the rest of the api functions should be easy to understand. I found some new short and sweet Epoch \ Unix timestamp functions along the way too that I dont think anyone has posted yet and will just post below for easy copy/paste. Both are standalone and utilize magic number 11644473600. Credits to ward. This uses his curl udf which is a tad bit out of of date and requires the SSL verification to be disabled. Its not that big of a deal since your data is still encrypted, but obviously not preferred so just fyi. Be sure to keep an eye on the halving coming up soon (https://www.bitcoinblockhalf.com) I expect to see a lot of fluctuations and its easy to gain a good amount of bitcoin when the prices fall and rise as much as they do. If you have good luck and these functions helped you - feel free to donate to 1DwAsJ9hNNSwDXSiYyD9EkppuVgcBQMC8q https://www.bitstamp.net/api/ Bitstamp Example: #include <bitstamp.au3> ;Set your secret and api keys _BitstampAU3_SetKeys(" Your secret/private key goes here ", " Your API Key goes here ") ; ;Example getting Balance $json = _BitstampAU3("balance") ConsoleWrite($json & @CRLF) Json_Dump($json) ;Example getting Balance with currency_pair $json = _BitstampAU3("balance/btcusd") ConsoleWrite($json & @CRLF) Json_Dump($json) ;Example getting user_transactions with 3 request parameters $json = _BitstampAU3("user_transactions", "sort=asc&offset=2&limit=5") ConsoleWrite($json & @CRLF) Json_Dump($json) Unix Time Functions: ConsoleWrite(_UnixTime() & @CRLF) ConsoleWrite(_UnixTimeToLocal(_UnixTime()) & @CRLF) ; #FUNCTION# ==================================================================================================================== ; Description ...: Calculates number of seconds/milliseconds that have elapsed since the Unix epoch ; Parameters ....: $bMS - [optional] Set true to return timestamp as milliseconds ; Return values .: UTC/Epoch/Unix timestamp ; Author ........: Brian J Christy (Beege) ; Remarks .......: SystemTimeAsFileTime = number of 100-nanosecond intervals since January 1, 1601 ; 11644473600 = number of seconds between 1/1/1601 - 1/1/1970 ; unixtime = (seconds since January 1, 1601) - 11644473600 ; =============================================================================================================================== Func _UnixTime($bMS = False) Local $iUTC = (DllCall('kernel32.dll', 'none', 'GetSystemTimeAsFileTime', 'uint64*', 0)[1] / 10000000) - 11644473600 Return $bMS ? Floor($iUTC * 1000) : Floor($iUTC) EndFunc ;==>_UnixTime Func _UnixTimeToLocal($iUnixTime) Local $tSys = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "uint64*", (($iUnixTime + 11644473600) * 10000000), "struct*", DllStructCreate("word[8]"))[2] Local $tLT = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "ptr", Null, "struct*", $tSys, "struct*", DllStructCreate("word tm[8]"))[3] Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $tLT.tm(2), $tLT.tm(4), $tLT.tm(1), $tLT.tm(5), $tLT.tm(6), $tLT.tm(7)) EndFunc ;==>_UnixTimeLocal Bitstamp.zip