Comments (17)
Cool, will keep this in mind. I agree that performance increase totally worth the effort. This is the reason I ended up here after all 👍 .
I also use old fashion print statements, combined with temporary raise statements in order to be able to follow the stack trace.
from nautilus_trader.
Your solution is pretty elegant, well done! I guess we can close this PR.
from nautilus_trader.
Absolutely, let's extend the commission model.
from nautilus_trader.
@cjdsellers What is the purpose of using a rates dictionary in the commission calculator. Does commission changes from day to day for forex?
from nautilus_trader.
So for some brokers there are sometimes different commission rates for certain products e.g. CFDs, or even certain FX pairs. The rates dictionary allows you to model that. The calculator also allows you to set a default rate, so if there are no special cases then that will be the rate returned for any query.
from nautilus_trader.
Shall I remove the minimum
variable from the commission calculator since the rebates can be negative? Or leave it and convert it to a percentage instead?
from nautilus_trader.
Opened a WIP #50. Waiting for your feedback regarding the "minumum" value, but also feel free to comment on the PR.
from nautilus_trader.
So the minimum is for the TAKER side, when the commission is calculated it is sometimes the min(the calculation involving the notional value, some minimum defined value)
. For instance IB has a minimum per order for different asset classes https://interactivebrokers.com/en/index.php?f=1590&p=fx
Its probably pedantic because a decent sized trading operation is always going to be above the minimum, however this models the actual commission pricing structure most closely.
So I'd say we need to change the param name to minimum_taker
. Or even extract out a CommissionModel
base class. Then for implementations such as BitMEX which have no concept of a minimum we just won't have that parameter in the inheriting class.
I can leave it to you to come up with a cool solution for that, or simply just re-implement so the minimum is ignored for a MAKER, and I'll come up with something.
from nautilus_trader.
Ok, please have a look. For now I renamed it to minimum_taker
and ignored it for maker
from nautilus_trader.
Great, I think what I'll do now is extract a base class and create a GenericCommissionModel
which will include the minimum
param, and a MakerTakerCommissionModel
which includes seperate taker_rates
and maker_rates
as per BitMEX https://www.bitmex.com/app/fees.
from nautilus_trader.
Sounds good. Will the taker and taker rates be a dictionary which will hold the rates for all the exchanges or will it be up to strategy to configure the maker and taker rates in the MakerTakerCommissionModel
?
from nautilus_trader.
It'll hold the rates for all exchanges at this stage, because the Symbol
includes both the code
and venue
, we can throw them all in there. It'll be up to the user to create that dictionary in a sensible way somewhere before passing it in.
In the domain model, a Venue
can be an exchange, brokerage, wherever the trading takes place.
from nautilus_trader.
We could keep some hard coded rates somewhere also for ease of use.
from nautilus_trader.
Ok, looking forward to see the code. On a separate note, my experience with cython is limited and yours is pretty reach, I wonder if you know of a way to debug by placing breakpoints inside the cython code?
from nautilus_trader.
Ok, so I finished that refactoring. I've taken the rates out of the config dict because it depends on the type of commission model, it gets passed into a BacktestEngine
just after the fill_model
. So it's much more straight forward and extendable.
Thanks for setting up the extra testing there too. MakerTakerCommissionModel
works properly.
I renamed SimulatedBroker
to SimulatedMarket
and in general want to get away from the broker centric language throughout the platform too.
from nautilus_trader.
For Cython, it gets easier with some exposure. The performance increase is really worth the effort.
With debugging its a bit of a pain, you have to recompile all the extensions with LINE_TRACING = True
in the setup.py
Probably not what you want to do. I tend to just setup really methodical unit tests and work through the logic slowly, or the good old temporary print statements.
If you ever do need/want to recompile everything from scratch though. The easiest way is to run the cleanup.py
in the scripts folder. Then python setup.py build_ext --inplace
and everything will recompile.
from nautilus_trader.
A yes the temporary raise RuntimeError()
is a great technique to get that trace! or throw in a value to the message too.
from nautilus_trader.
Related Issues (20)
- Simplify msgspec encoding/decoding for NautilusConfig objects HOT 2
- Refactor the Interactive Brokers Client HOT 1
- ParquetDataCatalog: circular import in `nautilus_trader.config.common` HOT 1
- Feature Request: Automated Generation of Stub Files for Cython Modules in `nautilus_trader` HOT 2
- Portfolio Allocation Tutorial HOT 2
- issue with nautilus-ibapi? fixed by installing most recent IBApi version manually HOT 2
- Enhancement for BacktestEngine in Event-Driven Strategies HOT 2
- pandas: ValueError: The truth value of a Series is ambiguous
- Upgrade hyper dependency to 1.1.0 HOT 1
- Are there any tutorials for stock HOT 1
- KeyError in Binance Spot Instrument Provider HOT 1
- Catalog.query() leaks memory for QuoteTicks and TradeTicks HOT 3
- The example strategy in "Quickstart" document is not working HOT 3
- TWAP Execution broken with Streaming/Persistence HOT 1
- Logging V2 - optimizations and performance profiling
- Nautilus CFD Subscriber
- Binance Order Status EXPIRED_IN_MATCH HOT 3
- Issue serializing IB orders HOT 1
- TWAP Execution fails when number of shares is less than intervals HOT 2
- ParquetDataCatalog write_data takes a very long time HOT 1
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 nautilus_trader.