Manual Trading

Before we schedule fx-bizday for live or paper trading, we'll run it manually to view the orders it would generate.

Account allocation

Before we can trade, we must allocate fx-bizday to one or more accounts, and specify how much of the account's capital to allocate. Open quantrocket.moonshot.allocations.yml, edit the account number to match your live or paper brokerage account, and edit the capital allocation percentage as desired.

If you don't already have a quantrocket.moonshot.allocations.yml in the /codeload directory (i.e. top level of the Jupyter file browser), you can execute the following command to copy it over. Otherwise, append the new allocation to your existing file.

In [1]:
# move file over unless it already exists
![ -e /codeload/quantrocket.moonshot.allocations.y*ml ] && echo 'oops, the file already exists!' || mv quantrocket.moonshot.allocations.yml /codeload/

Generate Moonshot orders

Now we can try to run Moonshot and generate orders. Depending on how recently you collected data and whether the market is currently open, you might get an error like the following:

In [2]:
!quantrocket moonshot trade 'fx-bizday'
msg: no 16:00:00 data found in prices DataFrame for signal date 2019-02-13, is the
  underlying data up-to-date? (max time for 2019-02-13 is 13:00:00)
status: error

Moonshot is trying to protect us from trading with stale data. For testing purposes we can work around this error by using the --review-date parameter to tell Moonshot to generate orders as if it were an earlier date and time. Set the review date to an earlier date and time that is within the date range of your data. Moonshot returns a CSV of orders, which we format for the terminal with csvlook:

In [3]:
!quantrocket moonshot trade 'fx-bizday' --review-date '2019-02-13 03:01:00' | csvlook
| Sid      | Account  | Action | OrderRef  | TotalQuantity | Exchange | OrderType | Tif |
| -------- | -------- | ------ | --------- | ------------- | -------- | --------- | --- |
| FXEURUSD | DU123456 | SELL   | fx-bizday |       922,546 | IDEALPRO | MKT       | DAY |

In the above example we simulate running the strategy just after 3 AM, which results in an order to sell EUR.USD.