/ LiveMode / src / adhoc / send.jl
send.jl
 1  
 2  function live_send_order(
 3      s::LiveStrategy{N,ExchangeID{:phemex}},
 4      ai::AssetInstance,
 5      t::Type{<:Order},
 6      args...;
 7      amount,
 8      price=lastprice(s, ai, t),
 9      stop_trigger=nothing,
10      profit_trigger=nothing,
11      stop_loss::Option{TriggerOrderTuple}=nothing,
12      take_profit::Option{TriggerOrderTuple}=nothing,
13      kwargs...,
14  ) where {N}
15      @price! ai stop_loss stop_trigger price profit_trigger take_profit
16      if t <: ReduceOnlyOrder
17          amount = min(ai.limits.amount.max, amount)
18      else
19          @amount! ai amount
20      end
21      invoke(live_send_order, Tuple{LiveStrategy,AssetInstance,Type{<:Order}}, s, ai, t, args...; amount, price, stop_trigger, profit_trigger, stop_loss, take_profit, kwargs...)
22  end
23  
24  function create_order_func(exc::Exchange{ExchangeID{:binance}}, func, args...; params=LittleDict{Py,Any}(), kwargs...)
25      postOnly = @pyconst "postOnly"
26      timeInForce = @pyconst "timeInForce"
27      if haskey(params, postOnly)
28          if pytruth(pop!(params, postOnly))
29              params[timeInForce] = @pyconst("PO")
30          end
31      end
32      _execfunc(func, args...; params, kwargs...)
33  end