-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go support base models #3651
base: master
Are you sure you want to change the base?
Go support base models #3651
Conversation
- implements some helper funcs from js/base/functions, - type JSONTime time.Time allowing string unix epoch (un)marshal, - other small helpers
some structs use custom json unmarshallers to cover for some inconsistencies among exchanges
this is a client implementation for https://github.com/franz-see/ccxt-rest
First of, thx for your effort! You did a really great job! And this PR is a good candidate for merging. We might indeed make a typed version of it to be the source for transpiling into all other languages.
The client itself is ok, however, I would not build it into the lib, instead, I would keep the client a standalone package, and would kink to it from our examples, if you don't mind.
I will look carefully into the above inconsistencies and yes, there might a need for more unification in certain cases. We'll figure it out with your help, no worries.
Glad your pointed that out, will consider a better solution, for sure. One thing that caught my eye after a brief overview is that the naming (the case of letters in particular) differs somewhat from what we have in the base code and in our docs, so, i wanted to ask whether you're ok to stick with the "camelCased" properties within type-structs (first symbol in lowercase) ? I will review the code more closely asap and will raise questions if any or will suggest edits in code, if i find that necessary. Anyways, we will get through this and will merge, hopefully, soon. Thanks so much again! |
Thanks for the quick feedback, happy to help!
No problem it makes sense, I can submit it to
Unfortunately it's not an option in go, first letter's case carry the exported/unexported aspect of any identifier in go : https://golang.org/ref/spec#Exported_identifiers. It would essentially make everything private and only usable inside |
it is now a test suite for the Exchange interface to be imported and called by implementations : ccxt.TestExchange(t, x)
as per @kroitor suggestion, it will live in its own package
Awesome, I'd love to work on the transpiller, but I need to get better at go first. What is the type system in go? And would we be able to achieve this, without the need to go back and use typescript, since I fear it will make it much more verbose. @kroitor int -> |
@frosty00 I'm clueless about the transpiling mechanisms and requirements honestly, but If I can help in any way please shoot I just went through this page https://code.tutsplus.com/tutorials/deep-dive-into-the-go-type-system--cms-29065 it gives a good overview of the language specs and is a quick read |
@rkjdid take a look at https://github.com/ccxt/ccxt/blob/master/transpile.js It is a pretty extraordinary file that contains all the regex needed to convert to subset of js into python and php. We will have to decide on which types represent which js types then write regexs so that all of the methods of that type are converted into an equivelent statement / method. For example a simple regex to convert python to js might be.
|
Yep, my story is the same )
I think it's very much Java/C++-alike. Though, I'm not 100% sure yet. Looks like a common subset of OOP to me at first glance.
Yep, I'm for the path of least resistance as well, ts → ( go | js | py | php | ... )
No
Do you mean assoc arrays / dicts / objects (
Do you mean flat arrays ( |
Second time in this repo – wrong Frosty! :) |
@frosty oops, my bad, sorry for disturbing, but you're always welcome here anyways ) |
@frosty00 we also have a obj = { 'foo': 1, 'bar': 'abc' }
safeFloat (obj, 'foo') // returns 1.0
safeString (obj, 'foo') // returns '1'
safeFloat (obj, 'bar') // returns undefined / None / null, not a float value
safeString2 (obj, 'foo', 'bar', 'abc') // returns '1', 'abc' is the default
safeString2 (obj, 'qux', 'baz', 'abc') // returns 'abc', the default
safeString (obj, 'qux', 'baz') // returns 'baz' |
This is a proposition for the base models in golang (#1952), there is not much more except some of the functions from
js/base/functions
that I started implementing ingo/util
package, none of which are really used so farIt also includes a client for using with https://github.com/franz-see/ccxt-rest (ccxt-rest/ccxt-rest#4) and a basic test suite that allowed me to do some testing on a couple of exchanges
There are a few hacks on json umarshaller methods made as workarounds to type inconsistencies found in several
exchange.describe()
, maybe it calls for better unification instead (e.g.: https://github.com/ccxt/ccxt/pull/3651/files#diff-629598ca466fdfe7719fd853bcec60e1R45 and https://github.com/ccxt/ccxt/pull/3651/files#diff-629598ca466fdfe7719fd853bcec60e1R73 - basically I encountered both []string and string values on some fields). Some of the exchanges still cannot be instantiated because of other type inconsistencies in their base info (11 out of 129)I also remove the
emulated
value onexchange.has['feature']
dict in the last commit, to avoid having to deal with a 3-value bool, it clearly has repercussions on users so it needs to be taken into consideration. There are alternative approaches but that is the cleanest and simplest one for my purpose