Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Bid / Ask in live trading

    Indicators/Strategies/Analyzers
    3
    5
    1880
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Taewoo Kim last edited by Taewoo Kim

      I read the FAQ on bid/ask :

      I want to trade using bid-ask prices
      
      Not a goal of this platform. You may still feed the prices to your own defined lines in the data feed and use them. See the documentation for extending data feeds.
      

      I did notice this example, but this is for local CSV files

      class BidAskCSV(btfeeds.GenericCSVData):
          linesoverride = True  # discard usual OHLC structure
          # datetime must be present and last
          lines = ('bid', 'ask', 'datetime')
          # datetime (always 1st) and then the desired order for
          params = (
              # (datetime, 0), # inherited from parent class
              ('bid', 1),  # default field pos 1
              ('ask', 2),  # default field pos 2
          )
      

      Are there examples of how this is done on live broker feed?

      I saw the oandatest.py example, but can't seem to tell how to reference openAsk, openBid, etc variables when args.bidask is passed

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @Taewoo Kim last edited by

        @Taewoo-Kim said in Bid / Ask in live trading:

        args.bidask is passed

        That argument is only telling the data feed which price group to use as reference for the tick price. The data feed can actually also ask for the midpoint. See: Docs - Data Feeds Reference, specifically the Oanda parameters.

        1 Reply Last reply Reply Quote 0
        • T
          Taewoo Kim last edited by

          SO i see this:

          useask (default: False)
          
          If True the ask part of the bidask prices will be used instead of the default use of bid
          

          Is there way to reference both bid AND ask as separate lines? I.e. is there a way I can reference soemthing like

          doSomething(self.datas[0].ask[0])
          

          and

          doSomething(self.datas[0].bid[0])
          

          Given the constraints of the BT framework, the only way I can think of is creating data streams

          data0 = store.getdata(dataname=conf_ini["general"]["oanda_currency"], **bid_params)
          data1 = store.getdata(dataname=conf_ini["general"]["oanda_currency"], **ask_params)
          

          But doesn't this require 2 streamer connections? According to Oanda,

          Two active rate stream connections per access token.
          

          Not to mention this seems kinda wasteful and prone to problems

          B 1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators @Taewoo Kim last edited by

            @Taewoo-Kim said in Bid / Ask in live trading:

            Is there way to reference both bid AND ask as separate lines? I.e. is there a way I can reference soemthing like
            doSomething(self.datas[0].ask[0])

            and
            doSomething(self.datas[0].bid[0])

            No.

            @Taewoo-Kim said in Bid / Ask in live trading:

            Given the constraints of the BT framework

            It's not a constraint. The design and functionality of the platform don't fit your expectations, which is entirely different.

            @Taewoo-Kim said in Bid / Ask in live trading:

            the only way I can think of is creating data streams
            data0 = store.getdata(dataname=conf_ini["general"]["oanda_currency"], **bid_params)
            data1 = store.getdata(dataname=conf_ini["general"]["oanda_currency"], **ask_params)

            But doesn't this require 2 streamer connections?

            Yes.

            1 Reply Last reply Reply Quote 0
            • Y
              YELNAr last edited by

              How to get bid and ask values on Interactive Brokers

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
              $(document).ready(function () { app.coldLoad(); }); }