Serving the Quantitative Finance Community

ISayMoo
Posts: 2368
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

I'll post the code some time soon. It will be Open Source.
How's it going here? we would like to test it.
Precise, step-by-step documentation is essential.
It's something I tinker with in my spare time

ISayMoo
Posts: 2368
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

Cool. Is this public domain and can we use it for our ML project?
There ya go.

Cuchulainn
Posts: 64109
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Re: Python tricks

Cool. Is this public domain and can we use it for our ML project?
There ya go.
Great, thank you very much. I will relate it to the hinterland.
Will also send you our pybind11 - C++ checklist.

ISayMoo
Posts: 2368
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

Thanks. Let me know if you have any questions.

Cuchulainn
Posts: 64109
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Re: Python tricks

Anyone tries scipy {DE, brute, basin hopping, shgo} global optimisation as an alternative to ANN?

Severe test is Eggholder function; find global _and_ all locals

tagoma
Topic Author
Posts: 18470
Joined: February 21st, 2010, 12:58 pm

### Re: Python tricks

There have been quite a lot of developments in recent python versions. Is there a proper construct that would be like a class with no (or very basic) methods, and only (mainly) with attributes (anemic construct?). In C++, I would go for struct, I think (adding drama here; drama sells, right?). My use case is a Order object that would have security, size, order_type, and other such attributes.
All constructive comments/recommendations on this much welcome.
Thank you very much.

Cuchulainn
Posts: 64109
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Re: Python tricks

Classes in  Python are not prize-winning TBH.

By a struct do you mean all data is public by default like in C++?

Plan B: Put Order in a module having attributes, def statements and bind functions.

In fact, this approach of breaking a software system into loosely-coupled and cohesive modules leads to code that is more maintainable than code using OOP.

tagoma
Topic Author
Posts: 18470
Joined: February 21st, 2010, 12:58 pm

### Re: Python tricks

Classes in  Python are not prize-winning TBH.

By a struct do you mean all data is public by default like in C++?

Plan B: Put Order in a module having attributes, def statements and bind functions.
Thank you Cuchulainn.
Yes, you guessed it right. I would like all data is public e.g. the Book class will need to access data in that construct Order e.g. to check whether there already is an opened position for that security, and everything else...
Note: I'm keeping this order/book management code very light. It is not "real" trading position management system. It is aimed at handling some risk/capital/positions constraints of a RL trading agent (my related question in another Wilmott forum, recently).

Peniel
Posts: 59
Joined: April 8th, 2006, 9:46 am

### Re: Python tricks

There have been quite a lot of developments in recent python versions. Is there a proper construct that would be like a class with no (or very basic) methods, and only (mainly) with attributes (anemic construct?). In C++, I would go for struct, I think (adding drama here; drama sells, right?). My use case is a Order object that would have security, size, order_type, and other such attributes.
All constructive comments/recommendations on this much welcome.
Thank you very much.
maybe dataclass?

tagoma
Topic Author
Posts: 18470
Joined: February 21st, 2010, 12:58 pm

### Re: Python tricks

There have been quite a lot of developments in recent python versions. Is there a proper construct that would be like a class with no (or very basic) methods, and only (mainly) with attributes (anemic construct?). In C++, I would go for struct, I think (adding drama here; drama sells, right?). My use case is a Order object that would have security, size, order_type, and other such attributes.
All constructive comments/recommendations on this much welcome.
Thank you very much.
maybe dataclass?
Thank you for this suggestion @Peniel. I wasn't aware of dataclasses. I'm looking into it now,

ISayMoo
Posts: 2368
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

Seconding Peniel. dataclasses are the way to go now.

katastrofa
Posts: 9918
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Python tricks

Tagoma says that he wants a C++ struct-like type and you're recommending a type of a mutable object?

Alright, it's (frozen=True)
dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=True)

Cuchulainn
Posts: 64109
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Re: Python tricks

There have been quite a lot of developments in recent python versions. Is there a proper construct that would be like a class with no (or very basic) methods, and only (mainly) with attributes (anemic construct?). In C++, I would go for struct, I think (adding drama here; drama sells, right?). My use case is a Order object that would have security, size, order_type, and other such attributes.
All constructive comments/recommendations on this much welcome.
Thank you very much.
maybe dataclass?
Can you give a sales pitch as this library looks like cargo cult at first glance. In other words, what's the compelling reason for using it?

Nice to see you again, @Peniel (your $e^5$ thread was a gem, but it suffered a fate worse than that of Dresden, i.e. FUBAR).

Cuchulainn
Posts: 64109
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

### Re: Python tricks

At the end of the day, tagoma seems to be traditional data modelling ... SQL etc.?
COBOL is better. I'm kind of serious (Python is replacing Java for COBOL API)

https://pypi.org/project/cobutils/

tech python libraries are in C++, Fortran

Python wasn't built for DB, but COBOL was.

why not? save a lot of messing around. BTW I'll have you know I was a Michael Jackson certified COBOL programmer in 1980, using _real_ computers!

Software savvy 1980s >> 2020
https://en.wikipedia.org/wiki/Michael_A._Jackson

ISayMoo
Posts: 2368
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

Cool. Is this public domain and can we use it for our ML project?
There ya go.
Great, thank you very much. I will relate it to the hinterland.
Will also send you our pybind11 - C++ checklist.
Any thoughts on how to generate HTML documentation automatically for pybind11-generated Python modules? For C++ I do with Doxygen, but I don't know how to handle binary Python wrappers.
 ABOUT WILMOTT

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...

 JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...