Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Add Volume to QuoteBar

Open ebengtso opened this issue 7 years ago • 14 comments

QuoteBar does not provide volumes, but my broker Oanda provides volumes, and since all instruments are managed as QuoteBar, I dont have access to volumes in Lean.

Is it possible to add this feature?

ebengtso avatar Jan 26 '18 18:01 ebengtso

Did you try "USDJPY_vol" I saw that somewhere work as a symbol for fxcm data... Sorry I can't remember where.

worthy7 avatar Jan 31 '18 05:01 worthy7

No, I haven’t tried that. As workaround, My broker Oanda provides interfaces, so I can retrieve it from there during live trades.

Nevertheless, my logic says that it would be helpful for everyone if it’s be embedded in the QuoteBar, when available.

ebengtso avatar Jan 31 '18 09:01 ebengtso

@ebengtso Yea I'm aware. But getting volume and syncing it with data is cumbersome on the backend (I talked about this already), and not everyone needs the volume, so that's why it's the way it is. My opinion is actually that volume shouldn't be in anything (stocks or forex or whatever) and should be it's own indicator/data feed, but yea....

Anyway it's in the university for FXCM, BasicTemplateFxcmVolumeAlgorithm You know, you could make us an OandA version if you just copy and paste all related FxcmVolume code (It's all there in the ToolBox) :+1:

worthy7 avatar Feb 01 '18 02:02 worthy7

@ebengtso Oh, there is already a OandaDownloader, perhaps it can be extended with whatever volume changes you made?

worthy7 avatar Feb 01 '18 05:02 worthy7

I thought that a coherent solution with tradebar and quotebar both hosting volumes would make sense.

Can you elaborate more about the sync issue with data? The volumes for Oanda are provided together with prices in a single shot, so I don’t understand the issue.

ebengtso avatar Feb 01 '18 15:02 ebengtso

Yea sorry, I don't know the details. @jaredbroad

worthy7 avatar Feb 02 '18 00:02 worthy7

I'm not sure adding 'volume' to quote bar makes complete sense. I understand that oanda provides this data, but at it's core, a quote bar doesn't have any volume.

mchandschuh avatar Jul 06 '18 09:07 mchandschuh

@ebengtso Can you please point out where you are seeing Volume in OandA's software?

worthy7 avatar Jul 06 '18 10:07 worthy7

sorry for delaying my reply. i've been away from trading lately, but now i'm back to the market.

Please find below an example of output from Oanda's instrument API. The volumes provided are Oanda trades only.

https://developer.oanda.com/rest-live-v20/instrument-ep/

{ "candles": [ { "ask": { "c": "1.31469", "h": "1.31520", "l": "1.31467", "o": "1.31509" }, "bid": { "c": "1.31454", "h": "1.31502", "l": "1.31450", "o": "1.31493" }, "complete": true, "time": "2016-10-17T15:00:00.000000000Z", "volume": 70 },

Oanda provide the volumes, so would be a shame not to use them. However, ultimately I don't want to use Oanda volumes because it does not reflect the market, but I want to retrieve volumes from the original futures contract that Oanda is mirroring, in my case the instruments are commodities listed on CME.

I understand that Quotes are not Trade, but many times we have market data mixed with quote data, and to keep it practical, it would be great to not complicate the architecture in sake of purity.

In meanwhile, I have two options: add volume to quotebar in my lean fork, or create a new indicator for swap and fetch data from oanda, cme, others.

erikbengtson avatar Feb 10 '19 11:02 erikbengtson

@erikbengtson Hey, welcome back. I still think making an OandAVolume is the right way to go for now.

worthy7 avatar Feb 11 '19 06:02 worthy7

Hi,

Here is a custom OandaDownloader and OandaVolume custom data

https://github.com/ebengtso/quant/tree/master/OandaDataProvider

ebengtso avatar Feb 17 '19 19:02 ebengtso

any opinion about this feature request?

I would like to implement the brokerage Saxo Bank and without this functionality I have to double the data flows, one to retrieve the bid/ask and another one to retrieve complementary information via indicators. Technically it's not a good architecture, and there is a risk of non synchronized Quote data against indicator data.

What I would like to do is to enrich the Bar indicator with a custom object, that every time we retrieve the quote from the broker, we complete the QuoteBar object with a custom object containing the additional information we have received.

As outsider, it's looks for me that we just need to add a generic Object to the QuoteBar so that any brokerage implementation can put whatever data they want there. Maybe its not that simple, any thoughts?

Please check these 3 snippets with samples of complementary data.

  1. when I get quotes, I can retrieve volumes traded for the instrument at the exchange. It's not broker volumes, dark pools or whatever. These figures are provided by the broker based on free or payed subscriptions.

See this example - price info:

{ "Data": [ { "AssetType": "FxSpot", "DisplayAndFormat": { "Currency": "AUD", "Decimals": 4, "Description": "British Pound/Australian Dollar", "Format": "AllowDecimalPips", "OrderDecimals": 4, "Symbol": "GBPAUD" }, "HistoricalChanges": { "PercentChange1Month": 1.21, "PercentChange2Months": 2.95, "PercentChange3Months": 1.85, "PercentChange6Months": -1.83, "PercentChangeDaily": 0.22, "PercentChangeWeekly": 1.67 }, "InstrumentPriceDetails": { "IsMarketOpen": true, "ShortTradeDisabled": false, "ValueDate": "2017-05-19" }, "LastUpdated": "0001-01-01T00:00:00Z", "PriceInfo": { "High": 1.09117, "Low": 1.08853, "NetChange": 0.00048, "PercentChange": 0.04 }, "PriceInfoDetails": { "AskSize": 1000000.0, "BidSize": 1000000.0, "LastClose": 1.08932, "LastTraded": 0.0, "LastTradedSize": 0.0, "Open": 0.0, "Volume": 0.0 }, "Quote": { "Amount": 100000, "Ask": 1.74948, "Bid": 1.74858, "DelayedByMinutes": 15, "ErrorCode": "None", "Mid": 1.74903, "PriceTypeAsk": "Indicative", "PriceTypeBid": "Indicative" }, "Uic": 22 }, { "AssetType": "FxSpot", "DisplayAndFormat": { "Currency": "CAD", "Decimals": 4, "Description": "British Pound/Canadian Dollar", "Format": "AllowDecimalPips", "OrderDecimals": 4, "Symbol": "GBPCAD" }, "InstrumentPriceDetails": { "IsMarketOpen": true, "ShortTradeDisabled": false, "ValueDate": "2017-05-19" }, "LastUpdated": "0001-01-01T00:00:00Z", "Quote": { "Amount": 100000, "Ask": 1.76278, "Bid": 1.76198, "DelayedByMinutes": 15, "ErrorCode": "None", "Mid": 1.76238, "PriceTypeAsk": "Indicative", "PriceTypeBid": "Indicative" }, "Uic": 23 } ] }

Also, please check this another example, I can also retrieve Market Depth Level 2, again it's a payed subscription

{ "Ask": [ 1.76671, 1.76676, 1.76706 ], "AskOrders": [ 0.0, 0.0, 0.0 ], "AskSize": [ 4000000.0, 7000000.0, 10000000.0 ], "Bid": [ 1.76591, 1.76586, 1.76556 ], "BidOrders": [ 0.0, 0.0, 0.0 ], "BidSize": [ 4000000.0, 7000000.0, 10000000.0 ], "Level2PriceFeed": false, "NoOfBids": 3, "NoOfOffers": 3, "UsingOrders": false }

  1. Here is additional options data.

{ "ContextId": "20211113100758607", "Format": "application/json", "InactivityTimeout": 30, "ReferenceId": "IP61042", "RefreshRate": 1000, "Snapshot": { "AssetType": "FxSpot", "DisplayAndFormat": { "Currency": "AUD", "Decimals": 4, "Description": "British Pound/Australian Dollar", "Format": "AllowDecimalPips", "StrikeDecimals": 4, "StrikeFormat": "Normal", "Symbol": "GBPAUD" }, "HistoricalChanges": { "PercentChange1Month": 5.57, "PercentChange2Months": 5.83, "PercentChange3Months": 3.73, "PercentChange6Months": 6.49, "PercentChangeDaily": 0.2, "PercentChangeWeekly": 0.88 }, "InstrumentPriceDetails": { "AverageVolume": 12345000.0, "Barrier": 1.0, "ExpiryDate": "2017-06-01", "IsMarketOpen": true, "LowerBarrier": -2.0, "MidForwardPrice": 1.71992423552514, "ShortTradeDisabled": false, "SpotAsk": 1.71782, "SpotBid": 1.71692, "SpotDate": "2017-06-03", "SpreadStrikePriceLower": 11.0, "SpreadStrikePriceUpper": 12.0, "StrikePrice": 1.7175, "UpperBarrier": 4.0, "ValueDate": "2017-06-05" }, "LastUpdated": "2017-05-01T00:00:00Z", "Quote": { "Amount": 100000, "Ask": 0.02257, "Bid": 0.01962, "DelayedByMinutes": 15, "ErrorCode": "None", "Mid": 0.0210958157864443, "PriceTypeAsk": "Indicative", "PriceTypeBid": "Indicative", "RFQState": "None" }, "Uic": 22 }, "State": "Active", "Tag": "PAGE1" }

ebengtso avatar Nov 20 '21 16:11 ebengtso

Should I use Slices? It seems that it's capable to host any data there. Can I create a brokerage and use slices instead of the quotebars or traderbas?

Thanks

ebengtso avatar Nov 20 '21 16:11 ebengtso

Would like to see this implemented as well in QuoteBar if it's still in the pipeline. I believe Oanda's API still provides volume data so why not? Despite it being broker/client tick "volume" and not true volume of FOREX markets, could still be a moderately useful data source.

adamvvu avatar May 24 '22 06:05 adamvvu