So below is some really rough pseudo code and I haven't tried this yet because I won't have time until this evening. However maybe someone else can get to it first. I don't really like how I've seen cash handled in other Robinhood algorithms but I'm surprised I haven't seen this done before so maybe it won't work.
#Robinhood 3 day rule solution
initialize
context.bucket1= []
context.bucket2= []
context.bucket3= []
schedule before market opens
move values to the next bucket
clear bucket3
handle_data
cash = context.portfolio.cash - sum(context.bucket1) + sum(context.bucket2) + sum(context.bucket3)
#trading logic goes here.
#after a sell order
add earnings to context.bucket1