Bid / Ask in live trading
-
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
-
@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. -
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
-
@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.
-
How to get bid and ask values on Interactive Brokers