Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - joejoe

#1
newLISP in the real world / Re: replace help
November 14, 2024, 04:49:02 PM
Ok roger that, rrq.

I did not realize the interactive mode would display differently.

And thanks for the println tip, makes it much prettier.

Thanks again for clarification and detailed explanation!

Much appreciated.
#2
newLISP in the real world / Re: replace help
November 13, 2024, 10:04:40 AM
Side note, I managed to get a json output from the python file, which feeds nicely into
json-parse.

Of course, I am still curious how I should correctly swap the ' for a " in the
replace function.
#3
newLISP in the real world / Re: replace help
November 13, 2024, 09:49:59 AM
Thanks Ralph,

I am using this to get data from a python script:

(set 'a (exec "python3 go.py"))
So when it arrives to my nL script, it is a string inside of a list.

With your suggestion, I managed to get it to the string with this:

(set 'b (a 0))
and can then run this:

(replace "\'" b "\"")
Which returns this:

"{\"symbol\": \"BURT/USDT\", \"timestamp\": None, \"datetime\": None, \"high\": 0.002463, \"low\": 0.001605, \"bid\": None, \"bidVolume\": 1731397.09898224, \"ask\": None, \"askVolume\": 2732456.21823022, \"vwap\": None, \"open\": 0.002136, \"close\": 0.002051, \"last\": 0.002051, \"previousClose\": None, \"change\": -8.5e-05, \"percentage\": -3.9794007490636703, \"average\": 0.002093, \"baseVolume\": 10255192.67905658, \"quoteVolume\": None, \"markPrice\": None, \"indexPrice\": None, \"info\": {\"close\": \"0.002051\", \"high\": \"0.002463\", \"last\": \"0.002051\", \"low\": \"0.001605\", \"market\": \"BURTUSDT\", \"open\": \"0.002136\", \"period\": \"86400\", \"value\": \"21214.1562025586145\", \"volume\": \"10255192.67905658\", \"volume_buy\": \"1731397.09898224\", \"volume_sell\": \"2732456.21823022\"}}"
Is there an way to keep the "\" from appearing, as I was trying to escape the middle " ?

Much appreciated again!
#4
newLISP in the real world / replace help
November 12, 2024, 12:04:58 PM
Hi and thanks for guidance!

I am trying to format this into valid json so I can json-parse it:

("{'symbol': 'BURT/USDT', 'timestamp': 1731440509530, 'datetime': '2024-11-12T19:41:49.530Z', 'high': 0.00353408, 'low': 0.00208606, 'bid': None, 'bidVolume': None, 'ask': None, 'askVolume': None, 'vwap': None, 'open': 0.00303488, 'close': 0.00246695, 'last': 0.00246695, 'previousClose': None, 'change': -0.00056793, 'percentage': -18.71, 'average': 0.00275091, 'baseVolume': None, 'quoteVolume': 281487.40662491, 'info': {'s': 'burt_usdt', 't': '1731440509530', 'cv': '-0.00056793', 'cr': '-0.1871', 'o': '0.00303488', 'l': '0.00208606', 'h': '0.00353408', 'c': '0.00246695', 'q': '97965253', 'v': '281487.40662491'}, 'indexPrice': None, 'markPrice': None}")
From what I understand, I have to change the single quotes to double quotes and change None to null, in order for it to be valid json, below, which validates as correct json:

{"symbol": "BURT/USDT", "timestamp": 1731440509530, "datetime": "2024-11-12T19:41:49.530Z", "high": 0.00353408, "low": 0.00208606, "bid": null, "bidVolume": null, "ask": null, "askVolume": null, "vwap": null, "open": 0.00303488, "close": 0.00246695, "last": 0.00246695, "previousClose": null, "change": -0.00056793, "percentage": -18.71, "average": 0.00275091, "baseVolume": null, "quoteVolume": 281487.40662491, "info": {"s": "burt_usdt", "t": "1731440509530", "cv": "-0.00056793", "cr": "-0.1871", "o": "0.00303488", "l": "0.00208606", "h": "0.00353408", "c": "0.00246695", "q": "97965253", "v": "281487.40662491"}, "indexPrice": null, "markPrice": null}
Here is what I tried:

(set 'a '("{'symbol': 'BURT/USDT', 'timestamp': 1731439797068, 'datetime': '2024-11-12T19:29:57.068Z', 'high': 0.00353408, 'low': 0.00208606, 'bid': None, 'bidVolume': None, 'ask': None, 'askVolume': None, 'vwap': None, 'open': 0.00294771, 'close': 0.00248834, 'last': 0.00248834, 'previousClose': None, 'change': -0.00045937, 'percentage': -15.58, 'average': 0.00271802, 'baseVolume': None, 'quoteVolume': 281817.75855221, 'info': {'s': 'burt_usdt', 't': '1731439797068', 'cv': '-0.00045937', 'cr': '-0.1558', 'o': '0.00294771', 'l': '0.00208606', 'h': '0.00353408', 'c': '0.00248834', 'q': '97998750', 'v': '281817.75855221'}, 'indexPrice': None, 'markPrice': None}"))

(replace "\'" a "\"")  ; gave the below with no changes

("{'symbol': 'BURT/USDT', 'timestamp': 1731439797068, 'datetime': '2024-11-12T19:29:57.068Z', 'high': 0.00353408, 'low': 0.00208606, 'bid': None, 'bidVolume': None, 'ask': None, 'askVolume': None, 'vwap': None, 'open': 0.00294771, 'close': 0.00248834, 'last': 0.00248834, 'previousClose': None, 'change': -0.00045937, 'percentage': -15.58, 'average': 0.00271802, 'baseVolume': None, 'quoteVolume': 281817.75855221, 'info': {'s': 'burt_usdt', 't': '1731439797068', 'cv': '-0.00045937', 'cr': '-0.1558', 'o': '0.00294771', 'l': '0.00208606', 'h': '0.00353408', 'c': '0.00248834', 'q': '97998750', 'v': '281817.75855221'}, 'indexPrice': None, 'markPrice': None}")

Do I need to use regex for this or what would be the best approach to take? Thanks very much!
#5
newLISP in the real world / Re: hmac signatures
October 26, 2024, 03:36:08 PM
Gotcha,

Thanks for jogging the memory.

https://newlispfanclub.com/index.php?topic=4862.0

I will attempt to piece this together, much appreciated!

--jj
#6
newLISP in the real world / hmac signatures
October 26, 2024, 10:54:59 AM
Hi there,

I am looking to follow step 2 of the api hmac authentication where it generates a signature from the string of GET + urlbody + timestamp, as indicated here:

https://docs.coinex.com/api/v2/authorization

As I understand it, the string to encrypt should look like this:

GET/assets/spot/balance1729963117000

which hashes to this:

ea68fa414dd208129b72ee5f4dcf34fd4b2a2c83121616da3f4cca454bd8d6e6

I am constructing the string with similar code to this:

(set 'timestamp (date-value (now)))
(set 'timestamp (push "000" (string timestamp) -1))  ; convert timestamp to milliseconds
(set 'user "xxx")

(set 'urlbase "https://api.coinex.com/v2")
(set 'urlendpoint "/assets/spot/balance")

(set 'urlbody (string "GET" urlendpoint timestamp))
(set 'urlbodyhash (crypto:sha256 urlbody))
(set 'url (string urlbase urlendpoint))

(set 'call (string "curl -X 'GET' " url " -H 'Content-type: application/json' -H 'X-COINEX-KEY: " user "' -H 'X-COINEX-SIGN: " urlbodyhash "' -H 'X-COINEX-TIMESTAMP: " timestamp "'"))

And the formatted curl request looks like this:

curl -X 'GET' https://api.coinex.com/v2/assets/spot/balance -H 'Content-type: application/json' -H 'X-COINEX-KEY: xxx' -H 'X-COINEX-SIGN: ea68fa414dd208129b72ee5f4dcf34fd4b2a2c83121616da3f4cca454bd8d6e6' -H 'X-COINEX-TIMESTAMP: 1729963117000'

When this is submitted to the api, I get this response:

("{\"code\":25,\"data\":{},\"message\":\"Signature Incorrect\"}")
This is how the docs suggest to construct the string (in python I believe):

prepared_str = "GET"+"/v2/spot/balance"+"1700490703564"
Have I generated the string correctly? or any thought to why the signature fails?

Thanks very much in advance for any tips! :+)

And this is the python example signature generation:

https://github.com/coinexcom/coinex_api_demo/blob/feat-api-v2/python/api.py
#7
Thank you for porting the forum!

This is fantastic, and your work greatly appreciated itistoday!
#8
Thanks itistoday!



This would be a great contribution to nL!!
#9
newLISP in the real world / Re: ×tamp formatting
October 17, 2020, 12:51:50 AM
Thank you Kirill,


&timestamp=

made &timestamp=

Thanks for the magic direction!
#10
newLISP in the real world / ×tamp formatting
October 16, 2020, 10:33:16 PM
Hi,



When I do this from the nL command line interpreter:


> (println "&timestamp")
&timestamp
"&timestamp"


All good as expected.



When I am running it on a web server cgi script looking at it from my browser, I end up with this result:


×tamp

How do I preserve &timestamp if I am making a string, say to include in a url?



When the result is ×tamp instead of &timestamp in the url, things break.



It seems like when seen "&times", something is changing that to show × instead?



I have this at top of the cgi script:


(print "Content-Type: text/htmlrnrn")

Thanks very much!
#11
newLISP newS / Re: Forum is back again
September 26, 2020, 11:47:44 AM
Super big thanks to the forum admin!



The forum really propels the adoption of newLISP.



Would there be chance to re-add the Forum link to the nL home page?



It is such a resource, it seems more than worthy. Thanks again admin! :D
#12
Ok thanks Lutz and TedWalther!



I got json-parse to work just great w Lutz's suggestion to use exec and curl:


(json-parse (join (exec "curl 'https://www.mysite.com/my.json'")))

Much appreciated to both! :o)
#13
newLISP in the real world / get-url works on some sites
September 10, 2020, 11:12:54 PM
Hi,



I love get-url and what it makes available for coding!



It seems to work on some sites and others not so much.



I have never had any issue before with using get-url for http calls.



For example, on both nearlyfreespeech.net and my laptop, it hangs on some sites.



(get-url "http://newlisp.org">http://newlisp.org") -- works!

(get-url "http://nearlyfreespeech.net">http://nearlyfreespeech.net") -- doesnt't work!

(get-url "http://amazon.com">http://amazon.com") -- doesn't work!

(get-url "http://google.com">http://google.com") -- works!



When it doesn't work, it just hangs.



I am guessing this is a server blocking issue for get-url requests?



On my nearlyfreespeech server, the logs say:

[Fri Sep 11 05:52:46.179236 2020] [cgi:warn] [pid 6060:tid 34480497408] [client 174.16.51.59:0] AH01220: Timeout waiting for output from CGI script /fs6b/abc/public/go.cgi
[Fri Sep 11 05:52:46.179516 2020] [core:error] [pid 6060:tid 34480497408] (70007)The timeout specified has expired: [client 174.16.51.59:0] AH00574: ap_content_length_filter: apr_bucket_read() failed


newLISP v.10.7.1 32-bit on Linux IPv4/6 UTF-8 libffi

newLISP v.10.7.5 64-bit on BSD IPv4/6 UTF-8



Thank you much for any quick tips on this! :D
#14
newLISP in the real world / Re: using ref data
September 10, 2020, 10:30:50 PM
Thanks very much for all the exemplars!



ref and map seem to carry things out quite well!



Much appreciated!
#15
newLISP in the real world / using ref data
August 30, 2020, 03:07:07 AM
The ref and ref-all functions bring back an address or list of addresses.



As cormullion wrote in the nL wikibook:


(ref-all "Brian Eno" itunes-data)
;-> ((0 2 14 528 6 1) (0 2 16 3186 6 1) (0 2 16 3226 6 1))


What would be the best way to get that data instead of the numerical addresses?



Essentially, once I find the address is (0 2 14 528 6 1), how best would I get what it actually is, not the address?



So how best to get (0 2 16 3186 6 1) data?



Thank you!