---
# System prepended metadata

title: Command-line Trading Platform Spec

---

# Command-line Trading Platform Spec

This specification of command-line trading platform is based on the Alpaca API, which is the company provide API stock trading.

For example, if we implement this spec with nodejs:

![](https://i.imgur.com/xQUzfUy.png)


## Launching

```
$ npm install orangesky-cli

$ orangesky help

help      [command]
config    [key] [value]
account   [field]
positions [options]
portfolio [field]
signal    [status]

buy       <symbol> <qty> @<price> <account|*> [options]
sell      <symbol> <qty> @<price> <account|*> [options]
cancel    <symbol|order_id|*> <account|*> [options] 
close     <symbol|*> <account|*> [options]
orders    <account|*> [status]

```

## Config

![](https://i.imgur.com/UjuduYy.png)



```
$ orangesky config
accessKey: xxxxxxxxxxxx
secretKey: xxxxxxxxxxxxxxxxxxxxxxxx
To view a specific option type config <key>.

$ orangesky config accessKey
accessKey: xxxxxxxxxxxx
To set an option type config <key> <value>.

$ orangesky config accessKey abcd1234
accessKey: abcd1234
```


## Portfolio

```
$ orangesky portfolio list

Portfolio  Cash           Existing      Target
---------- -------------  ------------  ------------
P1         $ 13,322 USD   $ 5,423 USD   $ 7,423 USD    
P2         $ 13,322 USD   $ 5,423 USD   $ 7,423 USD    


$ orangesky portfolio P1

Holding Assets    Existing         Target
----------------  --------------   --------------
BTCUSD             7.6 ($ 34,553)  10 ($53,345)
ETHUSD             10.3 ($ 23,233) 20 ($23,453)

$ orangesky portfolio todos

To Do List
------------------------------------------------
1. The new signal was came from the SIGNAL_A yesterday
   You should buy 3.5 BTCUSD for account 1

cmd: orangesky buy 3.5 @ 50000 account_1 --signal SIGNAL_A
------------------------------------------------
2. The new signal was came from the SIGNAL_B yesterday
   You should sell 5.6 ETHUSD for account 2

cmd: orangesky sell 5.6 @ 4000 account_2 --signal SIGNAL_B

```

## Buy/Sell (with signal)

```
$ orangesky buy BTCUSD 2 @27 account_1 \
            --signal SIGNAL_A \
            
This price is higher than 99% BTCUSD prices since yesterday
This price is higher than 95% BTCUSD prices since 2021 May
are you sure? [Y/n]

This price is higher than 99.99% BTCUSD prices since 2021 May
are you sure the price=500000/volume=3 is right? [Y/n]
            
placed with order ID abcdef123456
```

## Orders

```
$ orangesky list --account ACCOUNT_1 --symbol USDTTWD

symbol   side  qty  price  state     signal    orderId
------   ----  ---  -----  --------  --------  ------------
USDTTWD  buy   1    27.3   accepted  SIGNAL_A  abcdef123456
```