GithubHelp home page GithubHelp logo

Comments (4)

cjdsellers avatar cjdsellers commented on May 20, 2024

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.

jpmediadev avatar jpmediadev commented on May 20, 2024

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.

cjdsellers avatar cjdsellers commented on May 20, 2024

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.

cjdsellers avatar cjdsellers commented on May 20, 2024

I'm going to close this and roll the discussion into #248

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.