Detecting Price and Volume Patterns with SQL and TimescaleDB

  Рет қаралды 18,592

Part Time Larry

Part Time Larry

Күн бұрын

Пікірлер
@parttimelarry
@parttimelarry 3 жыл бұрын
I'm starting a new channel on AI at youtube.com/@parttimeai, please subscribe! Source Code: github.com/hackingthemarkets/timescaledb-aiohttp-asyncpg
@AppFanUAE
@AppFanUAE 3 жыл бұрын
Thank you very much wow amazing
@Kate-ud2xc
@Kate-ud2xc 2 жыл бұрын
how interesting and informative! :) Thank you so much for the vedio!
@sakthiprasad6008
@sakthiprasad6008 3 жыл бұрын
Nice videos. Thanks for the intro to timescale DB. It was new to me. Previously i was using rank function to identify open and close values of the bar. with stock1 as (select *,rank() over (partition by symbol order by datetime asc) rnk1, --to_timestamp(cast(datetime/1000 as bigint)) at time zone 'america/new_york' CODAT, to_timestamp(floor(datetime/300000)*300) at time zone 'america/new_york' itvl from minutetable where 1=1 -- and to_timestamp(cast(datetime/1000 as bigint))::date in ('2020-01-07','2020-01-08') --And symbol in ('AAPL') order by symbol,datetime asc ) select a.symbol,b.open,c.close,a.mh high,a.ml low,a.vol volume,a.itvl datetime from (select min(rnk1) openrnk,max(rnk1) closernk,sum(volume) vol,symbol,max(high) mh,min(low) ml,itvl from stock1 group by symbol,itvl)a join (select open,symbol,itvl,rnk1,datetime from stock1 )b on a.symbol=b.symbol and a.openrnk=b.rnk1 join (select close,symbol,itvl,rnk1,datetime from stock1 )c on a.symbol=c.symbol and a.closernk=c.rnk1 order by symbol,a.itvl asc
@cetilly
@cetilly 3 жыл бұрын
Fantastic vid. Especially since I have a preference for putting all of the data logic in SQL, so it was good to see you introduce that. Also, you are an insanely fast typer.
@edwardhasekamp3104
@edwardhasekamp3104 3 жыл бұрын
thank you! my knowledge grows with every video. I love the TimeScaleDB!
@anmolpreet8959
@anmolpreet8959 3 жыл бұрын
Hey bud, Keep up the great works. You are awesome
@seans9168
@seans9168 3 жыл бұрын
This was the video I’ve been waiting for. Very nice examples, and great showcase of TSDB. Good call on switching to TimeScaleDB! This is the first time I’ve used Postgres and I have to say I’m really enjoying this RDBMS as a whole. After testing/using it for over a week now, I’m hooked!
@x.e.b.u
@x.e.b.u 3 жыл бұрын
Really enjoyed the video. Thank you for the video. at 38:25 did bring a smile to my face. I'd invested in the stock (Silvergate) back in November. It has been on a huge run courtesy of crypto probably. "Whisky coming your way"
@yourpersonaldatadealer2239
@yourpersonaldatadealer2239 3 жыл бұрын
I spent all day figuring this query out so expect it might help some others: -- Returns the latest two dates of data for all holdings (with two or more -- days' worth of data) in each ETF -- -- This ignores any newly added holdings for each ETF as these are handled -- separately and impair the date-paired analysis that is calculated via -- row-pairs in the Pandas Python library on the results of this query -- -- If you are wondering why we don't just use two dataframes (one from -- today and one from the previous day) and compare them as element-wise -- matrices, this is because holdings can move up or down in ETFs. This -- would cause anomalies within the analysis and so -- pairs were used to counteract this issue SELECT etf_id, holding_id, date, company, ticker, shares, market_value, weight_percentage FROM ( SELECT *, -- Count the number of rows for each combination row_number() over ( PARTITION BY etf_id, holding_id ORDER BY date DESC ) AS row_num FROM etf_holding WHERE (etf_id, holding_id) IN ( -- Select all holdings that have more than one days' worth of data as a subquery -- to filter out any new companies (identify added/removed companies in seperate query) SELECT etf_id, holding_id FROM etf_holding GROUP BY etf_id, holding_id HAVING count(*) > 1 ) ) AS temp_table WHERE -- Only return the latest two dates for each holding in each ETF row_num < 3;
@iamvazu2768
@iamvazu2768 3 жыл бұрын
Thank you larry, great video again
@kazimali07
@kazimali07 3 жыл бұрын
Your so smart :( I watching and learning so much!
@ragecagegroves
@ragecagegroves 3 жыл бұрын
Awesome vid PTL!
@sakthiprasad6008
@sakthiprasad6008 3 жыл бұрын
Also to find the out the SMAs we can use the below query select symbol,sma200,sma100,sma50,datetime from (select symbol,datetime,close, AVG(close) OVER (partition by symbol ORDER BY datetime asc ROWS 199 PRECEDING) AS sMA200, AVG(close) OVER (partition by symbol ORDER BY datetime asc ROWS 99 PRECEDING) AS sMA100, AVG(close) OVER (partition by symbol ORDER BY datetime asc ROWS 49 PRECEDING) AS sMA50 from (select symbol,open,close,high,low,volume,to_timestamp(cast(datetime/1000 as bigint))::date datetime FROM dailytable)b )a where --datetime='2020-07-21' and symbol='SPY'
@theSoumyachatterjee
@theSoumyachatterjee 3 жыл бұрын
This is really great! Thank you for this! Could you please help share your thoughts around identifying support and resistance levels for a particular stock algorithmically?
@IDRC3000
@IDRC3000 3 жыл бұрын
Really helpful and interesting topic! I will be awesome if you do a video talking about the books that you have read and recommend, also, how would you implement a NoSQL database for stock data analysis?
@ChopStixLoL
@ChopStixLoL 3 жыл бұрын
I'm predicting a breakout of views on this channel.
@paultenzer1361
@paultenzer1361 2 жыл бұрын
Me too. I think it’s hilarious how many people throw all their money away “trading” with the gurus. No one wants to put in the work, coding your own strategy’s is the only way to really understand trading.
@ballyoracle
@ballyoracle 3 жыл бұрын
another awesome video .. made my SAT :) .. i was wondering how to do live stream ... for these pattern .. while markets are open and send a buy and sell
@parttimelarry
@parttimelarry 3 жыл бұрын
See the videos where I use websockets for intraday calculations in a dataframe, there are some examples where I demonstrate this with crypto examples and no database. Also, if you want to use a database like this, you could have code that executes on INSERT (perhaps as a stored procedure), so that when a new bar of data is inserted, code runs to see if that bar triggered whatever signal you are detecting. Or in the full stack tutorial, I fetched price data every minute with a cron job, then ran my calculations in Python in this scheduled job and places trades then.
@ballyoracle
@ballyoracle 3 жыл бұрын
@@parttimelarry I will work on it .. I am catching up on ll this awesome content .... every day.... today straight 6 hours now .. my head is exploding with possibilities.. BTW .. i am not able to load the price table populate_prices.py ... throwing me error " --- raise RuntimeError( RuntimeError: asyncio.run() cannot be called from a running event loop "
@ballyoracle
@ballyoracle 3 жыл бұрын
@@parttimelarry Thank you Larry ! you are more than awesome .. thank you thank you thank you
@ewaschenko
@ewaschenko Жыл бұрын
Do you know how we can link two different timescales together? Lets say pull our data on 5 min candles? But also want a 30 min bucket. When we are iterating through our 5 min candles, how do we know which 30 min bucket to use? For example 9:35, there will be buckets 9:30 and 10:00. the 9:35 candles maps to the 9:30 bucket, but is there a way to get that mapping?
@raaapt0r
@raaapt0r 3 жыл бұрын
Hey dude amazing content, I noticed the full stack app on your website doesn't go past the fifth part, any reason? Could you share it? :)
@FinGeek4now
@FinGeek4now 3 жыл бұрын
Morning PTL, I was just wondering if you could do a video on using Google's Colab (which is what I use currently - its a cloud Jupyter notebook) as well as implementing Firestore (Firebase/NoSQL) within it?
@Norvieable
@Norvieable 3 жыл бұрын
Dawg!!! You awesome
@AppFanUAE
@AppFanUAE 3 жыл бұрын
You are amazing 👍🏼 can you please guide me from where i get the codes?
@codya326
@codya326 3 жыл бұрын
Hey how is it going Larry , I have been watching so many of your videos and havnt quite seen what ive been looking for but i have learned so much in my time doing so. I was wondering if there was any way to make a bot that put out signals on stock that might break out based off 2 or 3 factors like for example if the rsi is over sold and the macd is crossing then a notification will be sent over in option form to discord where a discord bot will post a specific call or put option for that particular stock. I appreciate any help and the videos man keep it up !
@Amit-et3ob
@Amit-et3ob 3 жыл бұрын
Great work mate.. Please add more Crypto content. Stocks seems sooo boomer now.
@StephenNavazio
@StephenNavazio 3 жыл бұрын
Oddly, Boomers know timeseries is just that. We appreciate any timeseries topics, Thanks PT Larry.
@erfanmallakin9596
@erfanmallakin9596 3 жыл бұрын
Hi Larry, I admire your knowledge, I have a strategy which cannot be written in pine script at the moment ( due to script restrictions) how I can get help to implement it in other languages 😀?
@oferz123
@oferz123 3 жыл бұрын
Hi, I have a column named 'sma'. How I update the sma values with the output from the moving average window function results ?
@TuranInsight
@TuranInsight 3 жыл бұрын
Given this context- lead() should be used with previous_value, while lag() is for next_value right? or does it change from situation to situation
@TuranInsight
@TuranInsight 3 жыл бұрын
just found my answer: It all depends on ONDER BY DAY DESC/ASC
@ohadkoren317
@ohadkoren317 3 жыл бұрын
Hey larry I got a question. I want my materialized views to be in sync with binance clock... which means that I want to have correlated intervals with binance. Do you know how can I achieve that with timescaledb?
@symosys
@symosys 3 жыл бұрын
Which IDE are you using for postgreSQL?
@parttimelarry
@parttimelarry 3 жыл бұрын
If you mean the database browser, I am using TablePlus. You can also check out pgAdmin4 if you prefer a web-based user interface.
@filipmunoz
@filipmunoz 3 жыл бұрын
Hello Part time Larry! I'm working on a crypto currency python trader and it's doing great. But I have one issue, the script trades about 100 times per 24h. In Binance trading fees this is very expensive. Do you know of any other trading platforms where it is possible to pay monthly fees instead, or another way to reduce API trading fees?
@jameswang6714
@jameswang6714 3 жыл бұрын
@larry Where is Buy me coffee link?
@nvlucho
@nvlucho 3 жыл бұрын
Are you more profitable as a trader or developer? Love your videos!
@CarlosSilombria
@CarlosSilombria 3 жыл бұрын
Excellent content mate. Do you (or anyone here) know who offers real-time data and/or historical (at least 1 min) of futures? I had a look to polygon,alpha vantage, twelvedata and as far as I check they don't offer futures. I'm looking for CME products: NQ (or NQ=F on yahoo, NQ1! on tradingview) RTY, ES (SPY500) etc. Thanks in advanced for any information.
@NoOne-dv8wl
@NoOne-dv8wl 3 жыл бұрын
I am not sure, but you might try IEX Cloud
@SniperUSMC
@SniperUSMC 3 жыл бұрын
Would be nice to find gaps (rather than fill in data), like the one at time mark 7 min 58 seconds where it has a GAP down, 98% of the time GAPS fill within about two to three weeks, as both of the GAPS in that time frame of video have done. Find GAPS, look for first green bar and BUY. Trading GAPS can be very profitable. What do you think?
@cfregis
@cfregis 2 жыл бұрын
Data gap and price gap are two different animals
@abcdefgh-kz8to
@abcdefgh-kz8to 3 жыл бұрын
Intro song ?
@samtheharvester6188
@samtheharvester6188 3 жыл бұрын
Please do this for crypto.
@cryptolicious3738
@cryptolicious3738 2 жыл бұрын
EPIC :D
@TuranInsight
@TuranInsight 3 жыл бұрын
Hi there! THank you so much for this incredible content! I wanna ask you if there is a small error here: ## select all closes for Friday vs. Previous Close SELECT stock_id, symbol, day, close, LAG (close,1) OVER (ORDER BY close ASC) AS previous_close FROM daily_bars JOIN stock ON stock.id = daily_bars.stock_id WHERE date(day) = '2021-02-05' ORDER BY stock_id, day; INstead of "(ORDER BY close asc) you should say( PARTITION BY stock_id ORDER BY day DESC) in order to get the previous close--- otherwise the query just puts up incorrect values( which I have confirmed myself dozens of times) which I dont know which date they are from? Let me know if i am missing something?
Async Price Data Load with aiohttp and asyncpg
20:29
Part Time Larry
Рет қаралды 12 М.
Tracking ARK Invest ETFs with Python and PostgreSQL
35:16
Part Time Larry
Рет қаралды 16 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Supertrend 3 - Detecting Uptrends and Downtrends with Python
21:52
Part Time Larry
Рет қаралды 33 М.
Creating Tables with PostgreSQL and TimescaleDB
27:39
Part Time Larry
Рет қаралды 19 М.
Finding Breakout Candidates with Python and Pandas
29:33
Part Time Larry
Рет қаралды 71 М.
Build a Real-Time Crypto Trading Bot in under 100 Lines of Code
1:10:19
Part Time Larry
Рет қаралды 477 М.
Pandas TA Tutorial
27:00
Part Time Larry
Рет қаралды 46 М.
Python and Redis Tutorial - Caching API Responses
32:26
Part Time Larry
Рет қаралды 57 М.
Build a TTM Squeeze Scanner in Python
53:30
Part Time Larry
Рет қаралды 35 М.
PyAlgoTrade Tutorial (Part 3) - Technicals, Analyzers, and Plotting
23:39
Supertrend Part 2 - Basic Bands in Python
26:34
Part Time Larry
Рет қаралды 28 М.
Interactive Brokers TWS API + TradingView Charts Python Tutorial (Updated)
1:21:40
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН