Skip to content

Commit

Permalink
deploy: fe2457c
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Nov 27, 2023
1 parent 6709e02 commit b7b810e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1068,30 +1068,18 @@ <h2 id='placing-perp-order'>Placing Perp Order</h2><div class="highlight"><pre c
</code></pre></div><div class="highlight"><pre class="highlight python tab-python"><code><span class="kn">from</span> <span class="nn">driftpy.types</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">driftpy.constants.numeric_constants</span> <span class="kn">import</span> <span class="n">BASE_PRECISION</span><span class="p">,</span> <span class="n">PRICE_PRECISION</span>

<span class="n">subaccount_id</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">market_index</span> <span class="o">=</span> <span class="mi">0</span>

<span class="c1"># place order to long 1 SOL-PERP @ $21.88 (post only)
</span><span class="n">bid_params</span> <span class="o">=</span> <span class="n">OrderParams</span><span class="p">(</span>
</span><span class="n">order_params</span> <span class="o">=</span> <span class="n">OrderParams</span><span class="p">(</span>
<span class="n">order_type</span><span class="o">=</span><span class="n">OrderType</span><span class="p">.</span><span class="n">LIMIT</span><span class="p">(),</span>
<span class="n">market_type</span><span class="o">=</span><span class="n">MarketType</span><span class="p">.</span><span class="n">PERP</span><span class="p">(),</span>
<span class="n">direction</span><span class="o">=</span><span class="n">PositionDirection</span><span class="p">.</span><span class="n">LONG</span><span class="p">(),</span>
<span class="n">user_order_id</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">base_asset_amount</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="mi">1</span> <span class="o">*</span> <span class="n">BASE_PRECISION</span><span class="p">),</span>
<span class="n">price</span><span class="o">=</span><span class="mf">21.88</span> <span class="o">*</span> <span class="n">PRICE_PRECISION</span><span class="p">,</span>
<span class="n">base_asset_amount</span><span class="o">=</span><span class="n">drift_client</span><span class="p">.</span><span class="n">convert_to_perp_precision</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span>
<span class="n">price</span><span class="o">=</span><span class="n">drift_client</span><span class="p">.</span><span class="n">convert_to_price_precision</span><span class="p">(</span><span class="mf">21.88</span><span class="p">),</span>
<span class="n">market_index</span><span class="o">=</span><span class="n">market_index</span><span class="p">,</span>
<span class="n">reduce_only</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">post_only</span><span class="o">=</span><span class="n">PostOnlyParams</span><span class="p">.</span><span class="n">TRY_POST_ONLY</span><span class="p">(),</span>
<span class="n">immediate_or_cancel</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">trigger_price</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">trigger_condition</span><span class="o">=</span><span class="n">OrderTriggerCondition</span><span class="p">.</span><span class="n">ABOVE</span><span class="p">(),</span>
<span class="n">oracle_price_offset</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">auction_duration</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">max_ts</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">auction_start_price</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">auction_end_price</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">await</span> <span class="n">drift_client</span><span class="p">.</span><span class="n">get_place_perp_order</span><span class="p">(</span><span class="n">bid_order_params</span><span class="p">,</span> <span class="n">subaccount_id</span><span class="p">)</span>
<span class="k">await</span> <span class="n">drift_client</span><span class="p">.</span><span class="n">get_place_perp_order</span><span class="p">(</span><span class="n">order_params</span><span class="p">)</span>
</code></pre></div>
<table><thead>
<tr>
Expand Down Expand Up @@ -1208,6 +1196,18 @@ <h2 id='placing-spot-order'>Placing Spot Order</h2><div class="highlight"><pre c
<span class="p">}</span>

<span class="k">await</span> <span class="nx">driftClient</span><span class="p">.</span><span class="nx">placeSpotOrder</span><span class="p">(</span><span class="nx">orderParams</span><span class="p">);</span>
</code></pre></div><div class="highlight"><pre class="highlight python tab-python"><code>
<span class="n">market_index</span> <span class="o">=</span> <span class="mi">1</span>

<span class="n">order_params</span> <span class="o">=</span> <span class="n">OrderParams</span><span class="p">(</span>
<span class="n">order_type</span><span class="o">=</span><span class="n">OrderType</span><span class="p">.</span><span class="n">LIMIT</span><span class="p">(),</span>
<span class="n">direction</span><span class="o">=</span><span class="n">PositionDirection</span><span class="p">.</span><span class="n">LONG</span><span class="p">(),</span>
<span class="n">base_asset_amount</span><span class="o">=</span><span class="n">drift_client</span><span class="p">.</span><span class="n">convert_to_spot_precision</span><span class="p">(</span><span class="n">market_index</span><span class="p">,</span> <span class="mi">100</span><span class="p">),</span>
<span class="n">price</span><span class="o">=</span><span class="n">drift_client</span><span class="p">.</span><span class="n">convert_to_price_precision</span><span class="p">(</span><span class="mi">100</span><span class="p">),</span>
<span class="n">market_index</span><span class="o">=</span><span class="n">market_index</span><span class="p">,</span>
<span class="p">)</span>

<span class="k">await</span> <span class="n">driftClient</span><span class="p">.</span><span class="n">place_spot_order</span><span class="p">(</span><span class="n">order_params</span><span class="p">);</span>
</code></pre></div>
<table><thead>
<tr>
Expand Down

0 comments on commit b7b810e

Please sign in to comment.