Back to Community
Latest Bid-Ask Spread CSV

I quickly hacked together this quick and dirty wrapper, and thought I would post it here to get some feedback before finalizing it.

This is the 15-minute delayed bid-ask spread in CSV format. I obviously don't have historical data, but I was thinking this could be useful for live-trading/paper-trading. Unfortunately fetch_csv only runs once before market open, so importing this into Quantopian will always give you the last spread from closing the day before, which will could vary quite a bit from other times of day. Nonetheless, you could use it to help get a rough estimation as to whether you'd be able to cross the bid-ask spread with your trades -- even if it's a bit off it's still better than having no info, I would think. Perhaps you could scale it according to volume.,SPY,VOO,RFV,AMZN,GOOG,GOOGL

I wish we had access to this live data feed in live-trading/paper-trading, even if it were 15-minute delayed.

Here's the source code (omg semi-colons!):

    die('Example usage:,AMD,BRK.B');

header("Content-type: text/csv");  
header("Content-Disposition: attachment; filename=last_spread.csv");

$results = json_decode(file_get_contents(''.$_GET['s']),TRUE)['results'];
echo 'date,symbol,spread'.PHP_EOL;  
    echo $results[$i]['updated_at'].',';  
    echo $results[$i]['symbol'].',';  
    echo round($results[$i]['ask_price']-$results[$i]['bid_price'],4);  
    echo PHP_EOL;