Comments (5)
I think your workaround will work for your test case but it's look to me more like an ugly fix.
It's the Settings and Observable pattern that should be threadsafe and it is your program who needs to be aware of the objects you share between threads.
from qlnet.
I first came across Quantlib in the comments of an Investment Banks Quant Library “copied from the original quantlib”.. the most common reason to copy rather that use Quantlib is the mistake introducing Observable to assist the StatPro pricing service: a hack for to present price/yield functions independently without the need to pass a previously calculated value into a “price given yield” or “yield given price” function.
A proper quant library should be fully functional (with no side effects), but that will require a major re-write. The suggestion of spinlock is indeed a work-around for a pattern that should not be there.
I added spinlock_ in addition to bootstrapping_ (the fix to concurrency issue I was seeing) in order to avoid the side effect of duplicate observer notifications and co-mutation if more than one thread performs the same calculation (numeric consistency is questionable writing doubles on a 32-bit computer without interlocked exchange)
Given the marginal cost of plugging this problem, it is worth doing
from qlnet.
Hey @channell , thx for your PR , I agree with you about the uneeded pattern , what about working togheter to completly remove it from the library ? In the QLNet development we did several hack to avoid this problem with the only result to make the code ugly and difficult to read and without fixing the issue. Let me know if you have any idea on how to proceed.
from qlnet.
Hello @channell, @amaggiulli,
I've started a fork of QLNet moving to Visual Studio Code, .NET Core 3.1 and xUnit. You can find it here : https://github.com/OpenDerivatives/QLCore
I've removed the Observer & Observable pattern and so far it seems to work (only one test is not working but it is not working on original QLNet either and has been removed from tests), and some issues can still happen with ExchangeRateManager, but I'm looking into it.
There is still a lot to do on this fork. @amaggiulli do not hesitate to remove this message if it not appropriate and please let me know if the fork do not respect the original license.
from qlnet.
@tournierjc why not do that here as a major version? I mean, It's QLNet + refactoring + some more from QuantLib right?
from qlnet.
Related Issues (20)
- [REFACTO] Generalized Leg
- [BUG] GetHashCode of Date class - absent implementation HOT 1
- [BUG] Optimization method based on line search may return function value that does not correspond to current value HOT 2
- [FEATURE] Cleanup Project solution HOT 5
- [BUG] Missing bank holidays in calendar for Denmark
- Question: is it possible to use QLNet for generic MC pricing? HOT 2
- [BUG] False exception cause bootstrap failed because ts_.instruments_.Sort() does not work in Class:Iterativebootstrap, Method:initialize() HOT 1
- Use dotnet format instead of astyle HOT 1
- [BUG] Error in ActualActualISMA daycounter for long/short final periods HOT 5
- Question: Discrepancy between holidays in QLNet and QuantLib 1.21
- Net standard over net 6.0 HOT 10
- Fix .NET 7 compilation warnings
- [BUG] HOT 2
- Update Callable bonds with tests
- Add Bond Equivalent Yield calculation
- Add Compounded Then Simple calculation
- Determine early close date for US bond market calendar
- Update to .NET 8 HOT 3
- Update and refactor Asian engines
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qlnet.