Skip to content

Commit

Permalink
Improve example README
Browse files Browse the repository at this point in the history
  • Loading branch information
haxdds authored Jul 27, 2022
1 parent 352b611 commit 1d26f84
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ Some examples of request models corresponding to methods:
* ``GetOrdersRequest`` for ``TradingClient.get_orders()``
* ``CryptoLatestOrderbookRequest`` for ``CryptoHistoricalDataClient.get_crypto_latest_orderbook()``

**Usage Example**
**Request Models Usage Example**

To submit an order, you will need to provide a `MarketOrderRequest` object.
To get historical bar data for crypto, you will need to provide a ``CryptoBarsRequest`` object.

```python
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce
from alpaca.data.historical import CryptoHistoricalDataClient
from alpaca.data.requests import CryptoBarsRequest
from alpaca.data.timeframe import TimeFrame

client = TradingClient('api-key', 'secret-key')
# no keys required for crypto data
client = CryptoHistoricalDataClient()

request_params = MarketOrderRequest(
symbol="SPY",
qty=3,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY
)
request_params = CryptoBarsRequest(
symbol_or_symbols=["BTC/USD", "ETH/USD"],
timeframe=TimeFrame.Day,
start="2022-07-01"
)

client.submit_order(order_data=request_params)
bars = client.get_crypto_bars(request_params)
```

### Data Validation <a name="data-validation"></a>
Expand Down

0 comments on commit 1d26f84

Please sign in to comment.