Skip to content

Commit

Permalink
tweak python place order params
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Nov 27, 2023
1 parent 1e5c033 commit fe2457c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions source/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,30 +397,18 @@ await driftClient.placePerpOrder(orderParams);
from driftpy.types import *
from driftpy.constants.numeric_constants import BASE_PRECISION, PRICE_PRECISION

subaccount_id = 0
market_index = 0

# place order to long 1 SOL-PERP @ $21.88 (post only)
bid_params = OrderParams(
order_params = OrderParams(
order_type=OrderType.LIMIT(),
market_type=MarketType.PERP(),
direction=PositionDirection.LONG(),
user_order_id=0,
base_asset_amount=int(1 * BASE_PRECISION),
price=21.88 * PRICE_PRECISION,
base_asset_amount=drift_client.convert_to_perp_precision(1),
price=drift_client.convert_to_price_precision(21.88),
market_index=market_index,
reduce_only=False,
post_only=PostOnlyParams.TRY_POST_ONLY(),
immediate_or_cancel=False,
trigger_price=0,
trigger_condition=OrderTriggerCondition.ABOVE(),
oracle_price_offset=0,
auction_duration=None,
max_ts=None,
auction_start_price=None,
auction_end_price=None,
)
await drift_client.get_place_perp_order(bid_order_params, subaccount_id)
await drift_client.get_place_perp_order(order_params)
```

| Parameter | Description | Optional | Default |
Expand Down Expand Up @@ -457,6 +445,21 @@ const orderParams = {
await driftClient.placeSpotOrder(orderParams);
```

```python

market_index = 1

order_params = OrderParams(
order_type=OrderType.LIMIT(),
direction=PositionDirection.LONG(),
base_asset_amount=drift_client.convert_to_spot_precision(market_index, 100),
price=drift_client.convert_to_price_precision(100),
market_index=market_index,
)

await driftClient.place_spot_order(order_params);
```

| Parameter | Description | Optional | Default |
| ----------- | ----------- | -------- | ------- |
| orderType | The type of order e.g. market, limit | No | |
Expand Down

0 comments on commit fe2457c

Please sign in to comment.