November 20, 2022 alon@alphaoverbeta.net

CSV Trader

 

A Python script will execute trades described in an Excel spreadsheet.

I saw a growing need among my clients to run trading from an Excell spreadsheet they made some time before the market opened and decided to open-source the script so anyone can enjoy it.

Basically, the CSV file ( which can be edited in Excel or any other CSV editor) contains the required parameters for the trade execution, these parameters are currently in the CSV file:

  • Symbol – the selected asset to trade, at the moment only stocks and ETFs are supported
  • Action – buy or sell the selected asset
  • Quantify – the size of the transaction, if a position already exists, and you issue the other side (say you sell an already existing long position) the broker will liquidate the position first.
  • Order Type – describes the order type sent to the broker, currently supporting market orders which are executed immediately and limit orders which are pending orders waiting for a better-than-current price to enter a trade.
  • Lmt Price – the selected asset limit price. The broker will wait until a better price than this value will show up in order to enter a trade.
  • Stop Loss – a stop loss value to use, leave this empty to ignore stop loss
  • Take Profit – a take profit target value to use, leave this empty to ignore stop loss

The supported broker is Alpaca, a paper account can be opened on their website, after that just copy the generated API keys into the config file of the script to connect and run it.

The script may run at any time of the day before or during the trading session to generate trades with the broker and can be used as a simple order batch processor instead of going one trade after the other manually

All I ask is that you use it smartly and provide feedback,

Alon

Here is the link to the github repo:

https://github.com/TradeProphet/csv_trader