Comments (4)
So works correctly for live trading. The free
and locked
balances are parsed from the live stream.
However for backtesting the SimulatedExchange
isn't tracking margin. An Instrument
object is able to calculation initial and maintenance margins, and so the calculation can be made at the exchange easily.
However how to track and report this info, as well as how it might relate to the AccountState
event I'm still thinking about...
from nautilus_trader.
it's great that you do without a backtest and test on a real account, so you've already found your alpha)
SimulatedExchange must do some calculations as a broker, how is an order with a stop loss for a backtest considered now?
we need to calculate the current value of the position and its changes at the kernel level on every data tick
in my opinion, in the simplest case, is need to calculate:
position.unrealized_pnl(price_of_data_type) or current_order_position_cost for all open positions, at the level of cython core (if it is doing at the level of a user def strategy this will greatly slow down the speed of the entire system) and after: init equity - (positions + holded in orders)
from nautilus_trader.
So currently unrealized pnl isn't calculated on every tick as that would be quite inefficient. This also relates to your other issue about tracking a max and min unrealized pnl over a positions life.
My thoughts right now is to provide this functionality with an optional component which can subscribe to position events and also ticks, possibly it could update in time snapshots or when certain thresholds are crossed.
from nautilus_trader.
I'm going to close this and roll the discussion into #248
from nautilus_trader.
Related Issues (20)
- Logger Output Not Printing to Console After Commit 120bc0e HOT 3
- Is there any feature that I can have restful api to request the open orders of the account? HOT 1
- Error when self.subscribe_order_book_snapshots(instrument_id=self.instrument_id,depth=20) and def on_order_book(self, order_book: OrderBook) -> None: HOT 4
- No lattency between ts_init and ts_event for quote_tick HOT 5
- AttributeError: 'nautilus_trader.model.orders.limit.LimitOrder' object has no attribute 'order_side'. HOT 1
- StreamingFeatherWriter doesn't honour include_types filter HOT 1
- Flush logging when terminating process to avoid truncating logs
- Support for multiple trading nodes on IB client HOT 2
- tutorial not working HOT 1
- More Streaming Configuration HOT 1
- Refactor/Upgrade vendored `tokio-tungstenite` logic HOT 1
- Failure to detect positions on IB (bug only present past version 1.183.0) HOT 3
- Backtest Equity with EOD bar data seems to be broken HOT 1
- Always 100ms lag to match time, it is not good for users what to get the snapshot asap, even the snapshot ts_event has some interval HOT 1
- Allow _get_last_price() to use bars if quote ticks are not subscribed
- Support of perpetual futures contract HOT 1
- Circular import error HOT 1
- Disposing BacktestEngine does not release all resources HOT 1
- Databento integration HOT 1
- Adapters development guide
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.