1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] how to implement ask and bid price in entry price in backtesting.py

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I want to implement spread so I calculate the ask and bid price already

    class TestStrategy(Strategy):

    def next(self):
    current_price = self.data.Close[-1]
    current_spread = self.data.Spread[-1]
    current_signal = self.data.Signal[-1]


    # Calculate bid and ask prices using the spread in points
    bid_price = current_price - (current_spread * 0.001 / 2)
    ask_price = current_price + (current_spread * 0.001 / 2)

    if current_signal == 1:
    self.buy()

    if current_signal == -1:
    self.sell()


    how can I implement the ask and bid here the only arguments in self.buy and self.sell is

    def sell(self, *, size=.9999, limit=None, stop=None, sl=None, tp=None)
    def buy(self, *, size=.9999, limit=None, stop=None, sl=None, tp=None)

    Continue reading...

Compartilhe esta Página