karlwancl / Trady

Trady is a handy library for computing technical indicators, and it targets to be an automated trading system that provides stock data feeding, indicator computing, strategy building and automatic trading. It is built based on .NET Standard 2.0.
https://lppkarl.github.io/Trady
Apache License 2.0
545 stars 185 forks source link

Refactored buy/sell calculation to allow for broker fee implementations #79

Closed irperez closed 5 years ago

irperez commented 5 years ago

@lppkarl

==Breaking Change!== I've refactored the runner a bit to allow anyone to add their own cost structure for any brokerage. I call this FeeCalculators. They are in their own namespace. I've put the default one in (FeeCalculator) which defaults to what was there originally. I've also added an InteractiveBrokersFeeCalculator which models their fee structure. This can be used as an example.

I put this in mainly because I saw that most brokerage firm fees were involved and very different per brokerage firm. And costs to me were something that should have more insight.

I've also exposed the cost within the Transaction object.

This also has some minor changes where I added some default values for some common indicators. I thought this might be a good practice to get into to make the library easier to consume.

This change should require another major version number increase to avoid issues with consumers. I was not able to keep the contract the same. The Premium & ExchangeFee components were so baked into the builder/runner. Now it's using SOLID principles and those bits are now have separation of concerns. See the backtests with fees as an example.

karlwancl commented 5 years ago

@irperez should i update the major version on this change then? I am going to update the versions if it's needed. Thanks.

irperez commented 5 years ago

This is definitely a breaking change, so we should update the major version.