GithubHelp home page GithubHelp logo

Comments (17)

scoriiu avatar scoriiu commented on June 1, 2024 1

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.

scoriiu avatar scoriiu commented on June 1, 2024 1

Your solution is pretty elegant, well done! I guess we can close this PR.

from nautilus_trader.

cjdsellers avatar cjdsellers commented on June 1, 2024

Absolutely, let's extend the commission model.

from nautilus_trader.

scoriiu avatar scoriiu commented on June 1, 2024

@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.

cjdsellers avatar cjdsellers commented on June 1, 2024

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.

scoriiu avatar scoriiu commented on June 1, 2024

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.

scoriiu avatar scoriiu commented on June 1, 2024

Opened a WIP #50. Waiting for your feedback regarding the "minumum" value, but also feel free to comment on the PR.

from nautilus_trader.

cjdsellers avatar cjdsellers commented on June 1, 2024

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.

scoriiu avatar scoriiu commented on June 1, 2024

Ok, please have a look. For now I renamed it to minimum_taker and ignored it for maker

from nautilus_trader.

cjdsellers avatar cjdsellers commented on June 1, 2024

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.

scoriiu avatar scoriiu commented on June 1, 2024

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.

cjdsellers avatar cjdsellers commented on June 1, 2024

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.

cjdsellers avatar cjdsellers commented on June 1, 2024

We could keep some hard coded rates somewhere also for ease of use.

from nautilus_trader.

scoriiu avatar scoriiu commented on June 1, 2024

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.

cjdsellers avatar cjdsellers commented on June 1, 2024

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.

cjdsellers avatar cjdsellers commented on June 1, 2024

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.

cjdsellers avatar cjdsellers commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.