Open The-Sal opened 1 month ago
Isn't that something you could calculate yourself with the technical analysis library? https://technical-analysis-library-in-python.readthedocs.io/en/latest/
So the issue say something like RSI on the 1m time frame, you need the last 14 periods (14 mins) to determine the current RSI. Say something like IBKR API (ibasync) they usually give data but it's delayed 15mins. So you cant calculate the current RSI since it's delayed by too much. So with this library we'd have the latest 'price' but not the other 14 periods to calculate RSI. Unless you buy market data from IBKR, or other brokers. You could technically wait 14 mins and wait for the data to populate from this library and then calculate it. But not live RSI straight away if that makes sense.
Ah, I guess that makes sense. I wanted so say that this was outside of the scope of this project. But some historical data for calculations would be useful. I'm not certain when I'll have the time to work on this, so I'll just write down how to make this work, and maybe someone would be as kind to implement this. Otherwise I'll pick it up when I have time.
For this data, you'd need to use the self.cs
session, which is already initiated within the library. When initiating a ticker, the following message should be sent to the websocket:
{
"m": "resolve_symbol",
p: [
self.cs,
"sds_sym_3",
"={\"adjustment\":\"splits\",\"currency-id\":\"USD\",\"session\":\"regular\",\"symbol\":\"BITSTAMP:BTCUSD\"}"
]
}
You have to change BITSTAMP:BTCUSD
to whatever ticker you're interested in. From my testing it eventually responds with a message that has a length over 450k (might be more or less if you test it). This message has multiple partial messages, you have to look through them and find the timescale_update
message. It will look like this:
{
"m": "timescale_update",
"p": [
"cs_********",
{
"sds_1": {
"node": "THIS DOESN'T MATTER",
"s": [
{
"i": 0,
"v": [
1726761960,
63248,
63263,
63217,
63263,
1.45475737
]
},
{
"i": 1,
"v": [
1726762020,
63276,
63307,
63269,
63298,
3.56578803
]
},
{
"i": 2,
"v": [
1726762080,
63298,
63329,
63298,
63324,
0.68806982
]
},
...
]
}
}
]
}
The values are the following (in order): EPOCH timestamp
, open
, high
, low
, close
, change
. For the last value, I'd like to think it's change %, already displayed in %. So 0.68806982
really is 0.6%. But I'm not certain about that one.
Some important things for implementing this:
history
should be addedhistory
is True
it will send the extra message in the authenticate()
functiontimescale_update
messages (just like forTicker()
)parseMessage()
function, like I did here beforeCool ˙ᵕ˙
Hi,
I was wondering if there was anyways to update the code to get things like RSI, MACD and other technicals that are based on the tick-by-tick prices and historic data. So get live RSI essentially.
Thanks!