Good afternoon!
I'm relatively new to Rust and am planning to learn through creating a financial analysis project. Specifically, I'm using petgraph to treat financial entities as nodes in various undirected graphs to build a tool for users to explore more complicated trading relationships. Part of this process involves pulling financial indicators for various companies for the development of an MVP.
Getting healthy indicators is quite challenging from an API standpoint, and the amount of open-source Rust tools to do what I need is limited. However, Python has an incredible library called yfinance that on the surface, has more than enough standard functionality to get started. I do not need realtime, low-latency data. I just need data that aggregates from a daily view over the last week or so.
I've heard about using Py03 to call Python libraries in Rust, but for this particular use case I'm a little concerned that the performance of the user-defined graph will slow (especially as the graph gets larger and more analysis is warranted). Would Py03 still be a good choice for my project?
Thank you all very much for the help. Learning Rust so far has been a pleasure. 
If I understand, whether this performs well enough for you depends only on the Python library you're using and your performance requirements. I suggest doing performance testing with that library. This isn't related to Rust unless I'm misunderstanding your question.
1 Like
It seems like the performance risks would be:
- Overhead for function calls back and forth between Rust and Python
- Overhead translating data from Python objects to Rust
- Python's GIL becoming a bottleneck preventing Rust code from running concurrently.
My intuition is that none of that should actually be a problem in practice, compared to the time you spend waiting on the network (which is unavoidable).
But it is also just kind of a bunch of work. It sounds like your needs are fairly "batch". If that's right, I would start by having Rust run a Python script when it needs data; making the Python script spit out a JSON file, and then parsing the JSON file in Rust using serde or something. And go from there.
More or less. I would ideally like to run concurrent tasks, which would be hard with the GIL. I'm more asking for the performance overhead from translating Python code to Rust code at runtime. I assumed many developers have done similar tasks and was wondering if there were any other alternatives to Py03.
Yes, those were the risks I was thinking about!! And yes, my current implementation follows similar to batch processing. I'll look into having Rust run a Python script instead of dealing with function calls and objects. I'll update this thread with some basic benchmark tests incase anyone would like to take a further look.