@orderly.network/hooks 1.3.2 → 1.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (351) hide show
  1. package/esm/dataProvider.d.ts.map +1 -1
  2. package/esm/dataProvider.js +0 -2
  3. package/esm/dataProvider.js.map +1 -1
  4. package/esm/index.d.ts +4 -3
  5. package/esm/index.d.ts.map +1 -1
  6. package/esm/index.js +4 -3
  7. package/esm/index.js.map +1 -1
  8. package/esm/orderly/orderlyHooks.d.ts +3 -2
  9. package/esm/orderly/orderlyHooks.d.ts.map +1 -1
  10. package/esm/orderly/orderlyHooks.js +3 -2
  11. package/esm/orderly/orderlyHooks.js.map +1 -1
  12. package/esm/orderly/useCollateral.js +2 -2
  13. package/esm/orderly/useCollateral.js.map +1 -1
  14. package/esm/orderly/useMarginRatio.js +1 -1
  15. package/esm/orderly/useMarginRatio.js.map +1 -1
  16. package/esm/orderly/useMaxQty.js +2 -2
  17. package/esm/orderly/useMaxQty.js.map +1 -1
  18. package/esm/orderly/useOrderEntry.d.ts.map +1 -1
  19. package/esm/orderly/useOrderEntry.js +15 -12
  20. package/esm/orderly/useOrderEntry.js.map +1 -1
  21. package/esm/orderly/useOrderEntryNext/index.d.ts +1 -0
  22. package/esm/orderly/useOrderEntryNext/index.d.ts.map +1 -0
  23. package/esm/orderly/useOrderEntryNext/index.js +2 -0
  24. package/esm/orderly/useOrderEntryNext/index.js.map +1 -0
  25. package/esm/orderly/{useOrderStream.d.ts → useOrderStream/useOrderStream.d.ts} +19 -12
  26. package/esm/orderly/useOrderStream/useOrderStream.d.ts.map +1 -0
  27. package/esm/orderly/{useOrderStream.js → useOrderStream/useOrderStream.js} +91 -26
  28. package/esm/orderly/useOrderStream/useOrderStream.js.map +1 -0
  29. package/esm/orderly/{usePositionStream.d.ts → usePositionStream/usePositionStream.d.ts} +1 -1
  30. package/esm/orderly/usePositionStream/usePositionStream.d.ts.map +1 -0
  31. package/esm/orderly/{usePositionStream.js → usePositionStream/usePositionStream.js} +30 -22
  32. package/esm/orderly/usePositionStream/usePositionStream.js.map +1 -0
  33. package/esm/orderly/usePositionStream/utils.d.ts +8 -0
  34. package/esm/orderly/usePositionStream/utils.d.ts.map +1 -0
  35. package/esm/orderly/usePositionStream/utils.js +34 -0
  36. package/esm/orderly/usePositionStream/utils.js.map +1 -0
  37. package/esm/orderly/usePrivateDataObserver.d.ts.map +1 -1
  38. package/esm/orderly/usePrivateDataObserver.js +30 -43
  39. package/esm/orderly/usePrivateDataObserver.js.map +1 -1
  40. package/esm/orderly/useTakeProfitAndStopLoss/__test__/useTakeProfitAndStopLoss.test.d.ts +1 -0
  41. package/esm/orderly/useTakeProfitAndStopLoss/__test__/useTakeProfitAndStopLoss.test.d.ts.map +1 -0
  42. package/esm/orderly/useTakeProfitAndStopLoss/__test__/utils.test.d.ts +2 -0
  43. package/esm/orderly/useTakeProfitAndStopLoss/__test__/utils.test.d.ts.map +1 -0
  44. package/esm/orderly/useTakeProfitAndStopLoss/index.d.ts +32 -0
  45. package/esm/orderly/useTakeProfitAndStopLoss/index.d.ts.map +1 -0
  46. package/esm/orderly/useTakeProfitAndStopLoss/index.js +23 -0
  47. package/esm/orderly/useTakeProfitAndStopLoss/index.js.map +1 -0
  48. package/esm/orderly/useTakeProfitAndStopLoss/useTPSL.d.ts +59 -0
  49. package/esm/orderly/useTakeProfitAndStopLoss/useTPSL.d.ts.map +1 -0
  50. package/esm/orderly/useTakeProfitAndStopLoss/useTPSL.js +211 -0
  51. package/esm/orderly/useTakeProfitAndStopLoss/useTPSL.js.map +1 -0
  52. package/esm/orderly/useTakeProfitAndStopLoss/utils.d.ts +70 -0
  53. package/esm/orderly/useTakeProfitAndStopLoss/utils.d.ts.map +1 -0
  54. package/esm/orderly/useTakeProfitAndStopLoss/utils.js +226 -0
  55. package/esm/orderly/useTakeProfitAndStopLoss/utils.js.map +1 -0
  56. package/esm/services/orderCreator/__test__/limitOrderCreator.test.d.ts +2 -0
  57. package/esm/services/orderCreator/__test__/limitOrderCreator.test.d.ts.map +1 -0
  58. package/esm/services/orderCreator/__test__/orderCreator.test.d.ts +2 -0
  59. package/esm/services/orderCreator/__test__/orderCreator.test.d.ts.map +1 -0
  60. package/esm/services/orderCreator/__test__/stopLimitOrderCreator.test.d.ts +2 -0
  61. package/esm/services/orderCreator/__test__/stopLimitOrderCreator.test.d.ts.map +1 -0
  62. package/esm/services/orderCreator/__test__/stopMarketOrderCreator.test.d.ts +2 -0
  63. package/esm/services/orderCreator/__test__/stopMarketOrderCreator.test.d.ts.map +1 -0
  64. package/esm/services/orderCreator/__test__/tpslOrderCreator.test.d.ts +2 -0
  65. package/esm/services/orderCreator/__test__/tpslOrderCreator.test.d.ts.map +1 -0
  66. package/esm/services/orderCreator/__test__/tpslPositionOrderCreator.test.d.ts +2 -0
  67. package/esm/services/orderCreator/__test__/tpslPositionOrderCreator.test.d.ts.map +1 -0
  68. package/esm/services/orderCreator/baseAlgoCreator.d.ts +22 -0
  69. package/esm/services/orderCreator/baseAlgoCreator.d.ts.map +1 -0
  70. package/esm/services/orderCreator/baseAlgoCreator.js +57 -0
  71. package/esm/services/orderCreator/baseAlgoCreator.js.map +1 -0
  72. package/esm/services/orderCreator/baseCreator.d.ts +14 -0
  73. package/esm/services/orderCreator/baseCreator.d.ts.map +1 -0
  74. package/esm/services/orderCreator/baseCreator.js +92 -0
  75. package/esm/services/orderCreator/baseCreator.js.map +1 -0
  76. package/esm/services/orderCreator/factory.d.ts +7 -0
  77. package/esm/services/orderCreator/factory.d.ts.map +1 -0
  78. package/esm/services/orderCreator/factory.js +45 -0
  79. package/esm/services/orderCreator/factory.js.map +1 -0
  80. package/esm/services/orderCreator/fokCreator.d.ts +4 -0
  81. package/esm/services/orderCreator/fokCreator.d.ts.map +1 -0
  82. package/esm/services/orderCreator/fokCreator.js +5 -0
  83. package/esm/services/orderCreator/fokCreator.js.map +1 -0
  84. package/esm/services/orderCreator/generalCreator.d.ts +8 -0
  85. package/esm/services/orderCreator/generalCreator.d.ts.map +1 -0
  86. package/esm/services/orderCreator/generalCreator.js +15 -0
  87. package/esm/services/orderCreator/generalCreator.js.map +1 -0
  88. package/esm/services/orderCreator/interface.d.ts +23 -0
  89. package/esm/services/orderCreator/interface.d.ts.map +1 -0
  90. package/esm/services/orderCreator/interface.js +3 -0
  91. package/esm/services/orderCreator/interface.js.map +1 -0
  92. package/esm/services/orderCreator/iocCreator.d.ts +4 -0
  93. package/esm/services/orderCreator/iocCreator.d.ts.map +1 -0
  94. package/esm/services/orderCreator/iocCreator.js +5 -0
  95. package/esm/services/orderCreator/iocCreator.js.map +1 -0
  96. package/esm/services/orderCreator/limitOrderCreator.d.ts +8 -0
  97. package/esm/services/orderCreator/limitOrderCreator.d.ts.map +1 -0
  98. package/esm/services/orderCreator/limitOrderCreator.js +69 -0
  99. package/esm/services/orderCreator/limitOrderCreator.js.map +1 -0
  100. package/esm/services/orderCreator/marketOrderCreator.d.ts +24 -0
  101. package/esm/services/orderCreator/marketOrderCreator.d.ts.map +1 -0
  102. package/esm/services/orderCreator/marketOrderCreator.js +18 -0
  103. package/esm/services/orderCreator/marketOrderCreator.js.map +1 -0
  104. package/esm/services/orderCreator/postOnlyCreator.d.ts +4 -0
  105. package/esm/services/orderCreator/postOnlyCreator.d.ts.map +1 -0
  106. package/esm/services/orderCreator/postOnlyCreator.js +5 -0
  107. package/esm/services/orderCreator/postOnlyCreator.js.map +1 -0
  108. package/esm/services/orderCreator/stopLimitOrderCreator.d.ts +11 -0
  109. package/esm/services/orderCreator/stopLimitOrderCreator.d.ts.map +1 -0
  110. package/esm/services/orderCreator/stopLimitOrderCreator.js +84 -0
  111. package/esm/services/orderCreator/stopLimitOrderCreator.js.map +1 -0
  112. package/esm/services/orderCreator/stopMarketOrderCreator.d.ts +30 -0
  113. package/esm/services/orderCreator/stopMarketOrderCreator.d.ts.map +1 -0
  114. package/esm/services/orderCreator/stopMarketOrderCreator.js +46 -0
  115. package/esm/services/orderCreator/stopMarketOrderCreator.js.map +1 -0
  116. package/esm/services/orderCreator/tpslOrderCreator.d.ts +32 -0
  117. package/esm/services/orderCreator/tpslOrderCreator.d.ts.map +1 -0
  118. package/esm/services/orderCreator/tpslOrderCreator.js +88 -0
  119. package/esm/services/orderCreator/tpslOrderCreator.js.map +1 -0
  120. package/esm/services/orderCreator/tpslPositionOrderCreator.d.ts +33 -0
  121. package/esm/services/orderCreator/tpslPositionOrderCreator.d.ts.map +1 -0
  122. package/esm/services/orderCreator/tpslPositionOrderCreator.js +74 -0
  123. package/esm/services/orderCreator/tpslPositionOrderCreator.js.map +1 -0
  124. package/esm/services/orderMerge/algoOrderMergeHandler.d.ts +9 -0
  125. package/esm/services/orderMerge/algoOrderMergeHandler.d.ts.map +1 -0
  126. package/esm/services/orderMerge/algoOrderMergeHandler.js +38 -0
  127. package/esm/services/orderMerge/algoOrderMergeHandler.js.map +1 -0
  128. package/esm/services/orderMerge/baseMergeHandler.d.ts +22 -0
  129. package/esm/services/orderMerge/baseMergeHandler.d.ts.map +1 -0
  130. package/esm/services/orderMerge/baseMergeHandler.js +160 -0
  131. package/esm/services/orderMerge/baseMergeHandler.js.map +1 -0
  132. package/esm/services/orderMerge/interface.d.ts +8 -0
  133. package/esm/services/orderMerge/interface.d.ts.map +1 -0
  134. package/esm/services/orderMerge/interface.js +3 -0
  135. package/esm/services/orderMerge/interface.js.map +1 -0
  136. package/esm/services/orderMerge/regularOrderMergeHandler.d.ts +8 -0
  137. package/esm/services/orderMerge/regularOrderMergeHandler.d.ts.map +1 -0
  138. package/esm/services/orderMerge/regularOrderMergeHandler.js +15 -0
  139. package/esm/services/orderMerge/regularOrderMergeHandler.js.map +1 -0
  140. package/esm/usePoster.d.ts +3 -0
  141. package/esm/usePoster.d.ts.map +1 -1
  142. package/esm/usePoster.js +3 -1
  143. package/esm/usePoster.js.map +1 -1
  144. package/esm/utils/createOrder.d.ts +0 -55
  145. package/esm/utils/createOrder.d.ts.map +1 -1
  146. package/esm/utils/createOrder.js +0 -334
  147. package/esm/utils/createOrder.js.map +1 -1
  148. package/esm/utils/fokCreator.d.ts +1 -0
  149. package/esm/utils/fokCreator.d.ts.map +1 -0
  150. package/esm/utils/fokCreator.js +2 -0
  151. package/esm/utils/fokCreator.js.map +1 -0
  152. package/esm/utils/index.d.ts +5 -0
  153. package/esm/utils/index.d.ts.map +1 -0
  154. package/esm/utils/index.js +6 -0
  155. package/esm/utils/index.js.map +1 -0
  156. package/esm/utils/order.d.ts +2 -0
  157. package/esm/utils/order.d.ts.map +1 -0
  158. package/esm/utils/order.js +3 -0
  159. package/esm/utils/order.js.map +1 -0
  160. package/esm/utils/swr.d.ts +3 -1
  161. package/esm/utils/swr.d.ts.map +1 -1
  162. package/esm/utils/swr.js +123 -89
  163. package/esm/utils/swr.js.map +1 -1
  164. package/esm/utils/ws.d.ts +2 -0
  165. package/esm/utils/ws.d.ts.map +1 -0
  166. package/esm/utils/ws.js +9 -0
  167. package/esm/utils/ws.js.map +1 -0
  168. package/esm/version.d.ts +1 -1
  169. package/esm/version.d.ts.map +1 -1
  170. package/esm/version.js +2 -2
  171. package/esm/version.js.map +1 -1
  172. package/lib/dataProvider.d.ts.map +1 -1
  173. package/lib/dataProvider.js +0 -2
  174. package/lib/dataProvider.js.map +1 -1
  175. package/lib/index.d.ts +4 -3
  176. package/lib/index.d.ts.map +1 -1
  177. package/lib/index.js +10 -3
  178. package/lib/index.js.map +1 -1
  179. package/lib/orderly/orderlyHooks.d.ts +3 -2
  180. package/lib/orderly/orderlyHooks.d.ts.map +1 -1
  181. package/lib/orderly/orderlyHooks.js +6 -2
  182. package/lib/orderly/orderlyHooks.js.map +1 -1
  183. package/lib/orderly/useCollateral.js +2 -2
  184. package/lib/orderly/useCollateral.js.map +1 -1
  185. package/lib/orderly/useMarginRatio.js +1 -1
  186. package/lib/orderly/useMarginRatio.js.map +1 -1
  187. package/lib/orderly/useMaxQty.js +2 -2
  188. package/lib/orderly/useMaxQty.js.map +1 -1
  189. package/lib/orderly/useOrderEntry.d.ts.map +1 -1
  190. package/lib/orderly/useOrderEntry.js +14 -12
  191. package/lib/orderly/useOrderEntry.js.map +1 -1
  192. package/lib/orderly/useOrderEntryNext/index.d.ts +1 -0
  193. package/lib/orderly/useOrderEntryNext/index.d.ts.map +1 -0
  194. package/lib/orderly/useOrderEntryNext/index.js +3 -0
  195. package/lib/orderly/useOrderEntryNext/index.js.map +1 -0
  196. package/lib/orderly/{useOrderStream.d.ts → useOrderStream/useOrderStream.d.ts} +19 -12
  197. package/lib/orderly/useOrderStream/useOrderStream.d.ts.map +1 -0
  198. package/lib/orderly/{useOrderStream.js → useOrderStream/useOrderStream.js} +89 -25
  199. package/lib/orderly/useOrderStream/useOrderStream.js.map +1 -0
  200. package/lib/orderly/{usePositionStream.d.ts → usePositionStream/usePositionStream.d.ts} +1 -1
  201. package/lib/orderly/usePositionStream/usePositionStream.d.ts.map +1 -0
  202. package/lib/orderly/{usePositionStream.js → usePositionStream/usePositionStream.js} +30 -22
  203. package/lib/orderly/usePositionStream/usePositionStream.js.map +1 -0
  204. package/lib/orderly/usePositionStream/utils.d.ts +8 -0
  205. package/lib/orderly/usePositionStream/utils.d.ts.map +1 -0
  206. package/lib/orderly/usePositionStream/utils.js +55 -0
  207. package/lib/orderly/usePositionStream/utils.js.map +1 -0
  208. package/lib/orderly/usePrivateDataObserver.d.ts.map +1 -1
  209. package/lib/orderly/usePrivateDataObserver.js +28 -41
  210. package/lib/orderly/usePrivateDataObserver.js.map +1 -1
  211. package/lib/orderly/useTakeProfitAndStopLoss/__test__/useTakeProfitAndStopLoss.test.d.ts +1 -0
  212. package/lib/orderly/useTakeProfitAndStopLoss/__test__/useTakeProfitAndStopLoss.test.d.ts.map +1 -0
  213. package/lib/orderly/useTakeProfitAndStopLoss/__test__/utils.test.d.ts +2 -0
  214. package/lib/orderly/useTakeProfitAndStopLoss/__test__/utils.test.d.ts.map +1 -0
  215. package/lib/orderly/useTakeProfitAndStopLoss/index.d.ts +32 -0
  216. package/lib/orderly/useTakeProfitAndStopLoss/index.d.ts.map +1 -0
  217. package/lib/orderly/useTakeProfitAndStopLoss/index.js +33 -0
  218. package/lib/orderly/useTakeProfitAndStopLoss/index.js.map +1 -0
  219. package/lib/orderly/useTakeProfitAndStopLoss/useTPSL.d.ts +59 -0
  220. package/lib/orderly/useTakeProfitAndStopLoss/useTPSL.d.ts.map +1 -0
  221. package/lib/orderly/useTakeProfitAndStopLoss/useTPSL.js +218 -0
  222. package/lib/orderly/useTakeProfitAndStopLoss/useTPSL.js.map +1 -0
  223. package/lib/orderly/useTakeProfitAndStopLoss/utils.d.ts +70 -0
  224. package/lib/orderly/useTakeProfitAndStopLoss/utils.d.ts.map +1 -0
  225. package/lib/orderly/useTakeProfitAndStopLoss/utils.js +252 -0
  226. package/lib/orderly/useTakeProfitAndStopLoss/utils.js.map +1 -0
  227. package/lib/services/orderCreator/__test__/limitOrderCreator.test.d.ts +2 -0
  228. package/lib/services/orderCreator/__test__/limitOrderCreator.test.d.ts.map +1 -0
  229. package/lib/services/orderCreator/__test__/orderCreator.test.d.ts +2 -0
  230. package/lib/services/orderCreator/__test__/orderCreator.test.d.ts.map +1 -0
  231. package/lib/services/orderCreator/__test__/stopLimitOrderCreator.test.d.ts +2 -0
  232. package/lib/services/orderCreator/__test__/stopLimitOrderCreator.test.d.ts.map +1 -0
  233. package/lib/services/orderCreator/__test__/stopMarketOrderCreator.test.d.ts +2 -0
  234. package/lib/services/orderCreator/__test__/stopMarketOrderCreator.test.d.ts.map +1 -0
  235. package/lib/services/orderCreator/__test__/tpslOrderCreator.test.d.ts +2 -0
  236. package/lib/services/orderCreator/__test__/tpslOrderCreator.test.d.ts.map +1 -0
  237. package/lib/services/orderCreator/__test__/tpslPositionOrderCreator.test.d.ts +2 -0
  238. package/lib/services/orderCreator/__test__/tpslPositionOrderCreator.test.d.ts.map +1 -0
  239. package/lib/services/orderCreator/baseAlgoCreator.d.ts +22 -0
  240. package/lib/services/orderCreator/baseAlgoCreator.d.ts.map +1 -0
  241. package/lib/services/orderCreator/baseAlgoCreator.js +67 -0
  242. package/lib/services/orderCreator/baseAlgoCreator.js.map +1 -0
  243. package/lib/services/orderCreator/baseCreator.d.ts +14 -0
  244. package/lib/services/orderCreator/baseCreator.d.ts.map +1 -0
  245. package/lib/services/orderCreator/baseCreator.js +102 -0
  246. package/lib/services/orderCreator/baseCreator.js.map +1 -0
  247. package/lib/services/orderCreator/factory.d.ts +7 -0
  248. package/lib/services/orderCreator/factory.d.ts.map +1 -0
  249. package/lib/services/orderCreator/factory.js +54 -0
  250. package/lib/services/orderCreator/factory.js.map +1 -0
  251. package/lib/services/orderCreator/fokCreator.d.ts +4 -0
  252. package/lib/services/orderCreator/fokCreator.d.ts.map +1 -0
  253. package/lib/services/orderCreator/fokCreator.js +15 -0
  254. package/lib/services/orderCreator/fokCreator.js.map +1 -0
  255. package/lib/services/orderCreator/generalCreator.d.ts +8 -0
  256. package/lib/services/orderCreator/generalCreator.d.ts.map +1 -0
  257. package/lib/services/orderCreator/generalCreator.js +25 -0
  258. package/lib/services/orderCreator/generalCreator.js.map +1 -0
  259. package/lib/services/orderCreator/interface.d.ts +23 -0
  260. package/lib/services/orderCreator/interface.d.ts.map +1 -0
  261. package/lib/services/orderCreator/interface.js +6 -0
  262. package/lib/services/orderCreator/interface.js.map +1 -0
  263. package/lib/services/orderCreator/iocCreator.d.ts +4 -0
  264. package/lib/services/orderCreator/iocCreator.d.ts.map +1 -0
  265. package/lib/services/orderCreator/iocCreator.js +15 -0
  266. package/lib/services/orderCreator/iocCreator.js.map +1 -0
  267. package/lib/services/orderCreator/limitOrderCreator.d.ts +8 -0
  268. package/lib/services/orderCreator/limitOrderCreator.d.ts.map +1 -0
  269. package/lib/services/orderCreator/limitOrderCreator.js +79 -0
  270. package/lib/services/orderCreator/limitOrderCreator.js.map +1 -0
  271. package/lib/services/orderCreator/marketOrderCreator.d.ts +24 -0
  272. package/lib/services/orderCreator/marketOrderCreator.d.ts.map +1 -0
  273. package/lib/services/orderCreator/marketOrderCreator.js +28 -0
  274. package/lib/services/orderCreator/marketOrderCreator.js.map +1 -0
  275. package/lib/services/orderCreator/postOnlyCreator.d.ts +4 -0
  276. package/lib/services/orderCreator/postOnlyCreator.d.ts.map +1 -0
  277. package/lib/services/orderCreator/postOnlyCreator.js +15 -0
  278. package/lib/services/orderCreator/postOnlyCreator.js.map +1 -0
  279. package/lib/services/orderCreator/stopLimitOrderCreator.d.ts +11 -0
  280. package/lib/services/orderCreator/stopLimitOrderCreator.d.ts.map +1 -0
  281. package/lib/services/orderCreator/stopLimitOrderCreator.js +93 -0
  282. package/lib/services/orderCreator/stopLimitOrderCreator.js.map +1 -0
  283. package/lib/services/orderCreator/stopMarketOrderCreator.d.ts +30 -0
  284. package/lib/services/orderCreator/stopMarketOrderCreator.d.ts.map +1 -0
  285. package/lib/services/orderCreator/stopMarketOrderCreator.js +56 -0
  286. package/lib/services/orderCreator/stopMarketOrderCreator.js.map +1 -0
  287. package/lib/services/orderCreator/tpslOrderCreator.d.ts +32 -0
  288. package/lib/services/orderCreator/tpslOrderCreator.d.ts.map +1 -0
  289. package/lib/services/orderCreator/tpslOrderCreator.js +94 -0
  290. package/lib/services/orderCreator/tpslOrderCreator.js.map +1 -0
  291. package/lib/services/orderCreator/tpslPositionOrderCreator.d.ts +33 -0
  292. package/lib/services/orderCreator/tpslPositionOrderCreator.d.ts.map +1 -0
  293. package/lib/services/orderCreator/tpslPositionOrderCreator.js +83 -0
  294. package/lib/services/orderCreator/tpslPositionOrderCreator.js.map +1 -0
  295. package/lib/services/orderMerge/algoOrderMergeHandler.d.ts +9 -0
  296. package/lib/services/orderMerge/algoOrderMergeHandler.d.ts.map +1 -0
  297. package/lib/services/orderMerge/algoOrderMergeHandler.js +48 -0
  298. package/lib/services/orderMerge/algoOrderMergeHandler.js.map +1 -0
  299. package/lib/services/orderMerge/baseMergeHandler.d.ts +22 -0
  300. package/lib/services/orderMerge/baseMergeHandler.d.ts.map +1 -0
  301. package/lib/services/orderMerge/baseMergeHandler.js +170 -0
  302. package/lib/services/orderMerge/baseMergeHandler.js.map +1 -0
  303. package/lib/services/orderMerge/interface.d.ts +8 -0
  304. package/lib/services/orderMerge/interface.d.ts.map +1 -0
  305. package/lib/services/orderMerge/interface.js +6 -0
  306. package/lib/services/orderMerge/interface.js.map +1 -0
  307. package/lib/services/orderMerge/regularOrderMergeHandler.d.ts +8 -0
  308. package/lib/services/orderMerge/regularOrderMergeHandler.d.ts.map +1 -0
  309. package/lib/services/orderMerge/regularOrderMergeHandler.js +25 -0
  310. package/lib/services/orderMerge/regularOrderMergeHandler.js.map +1 -0
  311. package/lib/usePoster.d.ts +3 -0
  312. package/lib/usePoster.d.ts.map +1 -1
  313. package/lib/usePoster.js +3 -1
  314. package/lib/usePoster.js.map +1 -1
  315. package/lib/utils/createOrder.d.ts +0 -55
  316. package/lib/utils/createOrder.d.ts.map +1 -1
  317. package/lib/utils/createOrder.js +3 -375
  318. package/lib/utils/createOrder.js.map +1 -1
  319. package/lib/utils/fokCreator.d.ts +1 -0
  320. package/lib/utils/fokCreator.d.ts.map +1 -0
  321. package/lib/utils/fokCreator.js +3 -0
  322. package/lib/utils/fokCreator.js.map +1 -0
  323. package/lib/utils/index.d.ts +5 -0
  324. package/lib/utils/index.d.ts.map +1 -0
  325. package/lib/utils/index.js +36 -0
  326. package/lib/utils/index.js.map +1 -0
  327. package/lib/utils/order.d.ts +2 -0
  328. package/lib/utils/order.d.ts.map +1 -0
  329. package/lib/utils/order.js +6 -0
  330. package/lib/utils/order.js.map +1 -0
  331. package/lib/utils/swr.d.ts +3 -1
  332. package/lib/utils/swr.d.ts.map +1 -1
  333. package/lib/utils/swr.js +128 -89
  334. package/lib/utils/swr.js.map +1 -1
  335. package/lib/utils/ws.d.ts +2 -0
  336. package/lib/utils/ws.d.ts.map +1 -0
  337. package/lib/utils/ws.js +19 -0
  338. package/lib/utils/ws.js.map +1 -0
  339. package/lib/version.d.ts +1 -1
  340. package/lib/version.d.ts.map +1 -1
  341. package/lib/version.js +2 -2
  342. package/lib/version.js.map +1 -1
  343. package/package.json +9 -7
  344. package/esm/orderly/useOrderStream.d.ts.map +0 -1
  345. package/esm/orderly/useOrderStream.js.map +0 -1
  346. package/esm/orderly/usePositionStream.d.ts.map +0 -1
  347. package/esm/orderly/usePositionStream.js.map +0 -1
  348. package/lib/orderly/useOrderStream.d.ts.map +0 -1
  349. package/lib/orderly/useOrderStream.js.map +0 -1
  350. package/lib/orderly/usePositionStream.d.ts.map +0 -1
  351. package/lib/orderly/usePositionStream.js.map +0 -1
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ calculateHelper: function() {
13
+ return calculateHelper;
14
+ },
15
+ offsetPercentageToPrice: function() {
16
+ return offsetPercentageToPrice;
17
+ },
18
+ offsetToPrice: function() {
19
+ return offsetToPrice;
20
+ },
21
+ pnlToPrice: function() {
22
+ return pnlToPrice;
23
+ },
24
+ priceToOffset: function() {
25
+ return priceToOffset;
26
+ },
27
+ priceToOffsetPercentage: function() {
28
+ return priceToOffsetPercentage;
29
+ },
30
+ priceToPnl: function() {
31
+ return priceToPnl;
32
+ }
33
+ });
34
+ const _types = require("@orderly.network/types");
35
+ const _utils = require("@orderly.network/utils");
36
+ function offsetToPrice(inputs) {
37
+ const { qty, offset, entryPrice, orderType, orderSide } = inputs;
38
+ if (!offset) return;
39
+ if (orderSide === _types.OrderSide.BUY) {
40
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
41
+ return new _utils.Decimal(entryPrice).add(new _utils.Decimal(offset)).toNumber();
42
+ }
43
+ return new _utils.Decimal(entryPrice).minus(new _utils.Decimal(offset)).toNumber();
44
+ }
45
+ if (orderSide === _types.OrderSide.SELL) {
46
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
47
+ return new _utils.Decimal(entryPrice).minus(new _utils.Decimal(offset)).toNumber();
48
+ }
49
+ return new _utils.Decimal(entryPrice).add(new _utils.Decimal(offset)).toNumber();
50
+ }
51
+ }
52
+ function priceToOffset(inputs, options = {}) {
53
+ const { qty, price, entryPrice, orderType, orderSide } = inputs;
54
+ const { symbol } = options;
55
+ let decimal;
56
+ if (orderSide === _types.OrderSide.BUY) {
57
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
58
+ decimal = new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice));
59
+ }
60
+ decimal = new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice));
61
+ }
62
+ if (orderSide === _types.OrderSide.SELL) {
63
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
64
+ decimal = new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice));
65
+ }
66
+ decimal = new _utils.Decimal(entryPrice).minus(new _utils.Decimal(price));
67
+ }
68
+ if (symbol) {
69
+ return decimal.abs().todp(symbol.quote_dp, 4).toNumber();
70
+ }
71
+ return decimal.abs().toNumber();
72
+ }
73
+ function offsetPercentageToPrice(inputs) {
74
+ const { qty, percentage, entryPrice, orderType, orderSide } = inputs;
75
+ if (!percentage) return;
76
+ if (orderSide === _types.OrderSide.BUY) {
77
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
78
+ return new _utils.Decimal(1).add(new _utils.Decimal(percentage)).mul(new _utils.Decimal(entryPrice)).toNumber();
79
+ }
80
+ return new _utils.Decimal(1).minus(new _utils.Decimal(percentage)).mul(new _utils.Decimal(entryPrice)).toNumber();
81
+ }
82
+ if (orderSide === _types.OrderSide.SELL) {
83
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
84
+ return new _utils.Decimal(1).minus(new _utils.Decimal(percentage)).mul(new _utils.Decimal(entryPrice)).toNumber();
85
+ }
86
+ return new _utils.Decimal(1).add(new _utils.Decimal(percentage)).mul(new _utils.Decimal(entryPrice)).toNumber();
87
+ }
88
+ }
89
+ function priceToOffsetPercentage(inputs) {
90
+ const { qty, price, entryPrice, orderType, orderSide } = inputs;
91
+ if (orderSide === _types.OrderSide.BUY) {
92
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
93
+ return new _utils.Decimal(price).div(new _utils.Decimal(entryPrice)).minus(1).toNumber();
94
+ }
95
+ return new _utils.Decimal(1).minus(new _utils.Decimal(price).div(new _utils.Decimal(entryPrice))).toNumber();
96
+ }
97
+ if (orderSide === _types.OrderSide.SELL) {
98
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
99
+ return new _utils.Decimal(1).minus(new _utils.Decimal(price).div(new _utils.Decimal(entryPrice))).toNumber();
100
+ }
101
+ return new _utils.Decimal(price).div(new _utils.Decimal(entryPrice)).minus(1).toNumber();
102
+ }
103
+ }
104
+ function pnlToPrice(inputs) {
105
+ const { qty, pnl, entryPrice, orderType, orderSide } = inputs;
106
+ ;
107
+ if (!pnl) {
108
+ return;
109
+ }
110
+ if (orderSide === _types.OrderSide.BUY) {
111
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
112
+ return new _utils.Decimal(entryPrice).plus(new _utils.Decimal(pnl).div(new _utils.Decimal(qty))).toNumber();
113
+ }
114
+ return new _utils.Decimal(entryPrice).add(new _utils.Decimal(pnl).div(new _utils.Decimal(qty))).toNumber();
115
+ }
116
+ if (orderSide === _types.OrderSide.SELL) {
117
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
118
+ return new _utils.Decimal(entryPrice).add(new _utils.Decimal(pnl).div(new _utils.Decimal(qty))).toNumber();
119
+ }
120
+ return new _utils.Decimal(entryPrice).add(new _utils.Decimal(pnl).div(new _utils.Decimal(qty))).toNumber();
121
+ }
122
+ }
123
+ function priceToPnl(inputs, options = {}) {
124
+ const { qty, price, entryPrice, orderType, orderSide } = inputs;
125
+ const { symbol } = options;
126
+ let decimal = _utils.zero;
127
+ if (orderSide === _types.OrderSide.BUY) {
128
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
129
+ decimal = new _utils.Decimal(qty).mul(new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice)));
130
+ }
131
+ decimal = new _utils.Decimal(qty).mul(new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice)));
132
+ }
133
+ if (orderSide === _types.OrderSide.SELL) {
134
+ if (orderType === _types.AlgoOrderType.TAKE_PROFIT) {
135
+ decimal = new _utils.Decimal(qty).mul(new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice)));
136
+ }
137
+ decimal = new _utils.Decimal(qty).mul(new _utils.Decimal(price).minus(new _utils.Decimal(entryPrice)));
138
+ }
139
+ if (symbol) {
140
+ return decimal.todp(symbol.quote_dp, 4).toNumber();
141
+ }
142
+ return decimal.toNumber();
143
+ }
144
+ function calculateHelper(key, inputs, options = {}) {
145
+ const { symbol } = options;
146
+ // if not need to be computed, return the value directly
147
+ if (key !== "quantity" && key !== "tp_trigger_price" && key !== "sl_trigger_price" && key !== "tp_pnl" && key !== "sl_pnl" && key !== "tp_offset" && key !== "sl_offset" && key !== "tp_offset_percentage" && key !== "sl_offset_percentage") {
148
+ return {
149
+ [key]: inputs.value
150
+ };
151
+ }
152
+ const orderType = key.startsWith("tp_") ? _types.AlgoOrderType.TAKE_PROFIT : _types.AlgoOrderType.STOP_LOSS;
153
+ const keyPrefix = key.slice(0, 3);
154
+ let qty = Number(key === "quantity" ? inputs.value : inputs.qty);
155
+ if (qty === 0) return {
156
+ [`${keyPrefix}trigger_price`]: "",
157
+ // [`${keyPrefix}offset`]: "",
158
+ // [`${keyPrefix}offset_percentage`]: "",
159
+ [`${keyPrefix}pnl`]: "",
160
+ [key]: inputs.value
161
+ };
162
+ let trigger_price, offset, offset_percentage, pnl;
163
+ switch(key){
164
+ case "tp_trigger_price":
165
+ case "sl_trigger_price":
166
+ {
167
+ trigger_price = inputs.value;
168
+ // if trigger price is empty and the key is `*_trigger_price`, reset the offset and pnl
169
+ if (inputs.value === "") {
170
+ return {
171
+ [`${keyPrefix}trigger_price`]: trigger_price,
172
+ [`${keyPrefix}offset`]: "",
173
+ [`${keyPrefix}offset_percentage`]: "",
174
+ [`${keyPrefix}pnl`]: ""
175
+ };
176
+ }
177
+ break;
178
+ }
179
+ case "tp_pnl":
180
+ case "sl_pnl":
181
+ {
182
+ pnl = inputs.value;
183
+ trigger_price = pnlToPrice({
184
+ qty,
185
+ pnl: Number(inputs.value),
186
+ entryPrice: inputs.entryPrice,
187
+ orderSide: inputs.orderSide,
188
+ orderType
189
+ });
190
+ break;
191
+ }
192
+ case "tp_offset":
193
+ case "sl_offset":
194
+ {
195
+ offset = inputs.value;
196
+ trigger_price = offsetToPrice({
197
+ qty,
198
+ offset: Number(inputs.value),
199
+ entryPrice: inputs.entryPrice,
200
+ orderSide: inputs.orderSide,
201
+ orderType: key === "tp_offset" ? _types.AlgoOrderType.TAKE_PROFIT : _types.AlgoOrderType.STOP_LOSS
202
+ });
203
+ break;
204
+ }
205
+ case "tp_offset_percentage":
206
+ case "sl_offset_percentage":
207
+ {
208
+ offset_percentage = inputs.value;
209
+ trigger_price = offsetPercentageToPrice({
210
+ qty,
211
+ percentage: Number(inputs.value),
212
+ entryPrice: inputs.entryPrice,
213
+ orderSide: inputs.orderSide,
214
+ orderType
215
+ });
216
+ break;
217
+ }
218
+ }
219
+ if (!trigger_price) return {
220
+ [`${keyPrefix}trigger_price`]: "",
221
+ [`${keyPrefix}offset`]: "",
222
+ [`${keyPrefix}offset_percentage`]: "",
223
+ [`${keyPrefix}pnl`]: "",
224
+ [key]: inputs.value
225
+ };
226
+ return {
227
+ [`${keyPrefix}trigger_price`]: symbol ? new _utils.Decimal(Number(trigger_price)).todp(symbol.quote_dp, 4).toNumber() : trigger_price,
228
+ [`${keyPrefix}offset`]: offset ?? priceToOffset({
229
+ qty,
230
+ price: Number(trigger_price),
231
+ entryPrice: inputs.entryPrice,
232
+ orderSide: inputs.orderSide,
233
+ orderType
234
+ }, options),
235
+ [`${keyPrefix}offset_percentage`]: offset_percentage ?? priceToOffsetPercentage({
236
+ qty,
237
+ price: Number(trigger_price),
238
+ entryPrice: inputs.entryPrice,
239
+ orderSide: inputs.orderSide,
240
+ orderType
241
+ }),
242
+ [`${keyPrefix}pnl`]: pnl ?? priceToPnl({
243
+ qty,
244
+ price: Number(trigger_price),
245
+ entryPrice: inputs.entryPrice,
246
+ orderSide: inputs.orderSide,
247
+ orderType
248
+ }, options)
249
+ };
250
+ }
251
+
252
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/orderly/useTakeProfitAndStopLoss/utils.ts"],"sourcesContent":["import { API, OrderSide, PositionSide } from \"@orderly.network/types\";\nimport { OrderType } from \"@orderly.network/types\";\nimport { AlgoOrderType } from \"@orderly.network/types\";\nimport { Decimal, zero } from \"@orderly.network/utils\";\n\nexport type UpdateOrderKey =\n | \"tp_trigger_price\"\n | \"tp_offset_percentage\"\n | \"tp_pnl\"\n | \"tp_offset\"\n | \"quantity\"\n | \"sl_trigger_price\"\n | \"sl_offset_percentage\"\n | \"sl_pnl\"\n | \"sl_offset\";\n\n/**\n * offset -> TP/SL price\n */\nexport function offsetToPrice(inputs: {\n qty: number;\n offset: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n}) {\n const { qty, offset, entryPrice, orderType, orderSide } = inputs;\n\n if (!offset) return;\n\n if (orderSide === OrderSide.BUY) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(entryPrice).add(new Decimal(offset)).toNumber();\n }\n\n return new Decimal(entryPrice).minus(new Decimal(offset)).toNumber();\n }\n\n if (orderSide === OrderSide.SELL) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(entryPrice).minus(new Decimal(offset)).toNumber();\n }\n\n return new Decimal(entryPrice).add(new Decimal(offset)).toNumber();\n }\n}\n\nexport function priceToOffset(\n inputs: {\n qty: number;\n price: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n },\n options: { symbol?: API.SymbolExt } = {}\n) {\n const { qty, price, entryPrice, orderType, orderSide } = inputs;\n const { symbol } = options;\n let decimal: Decimal;\n\n if (orderSide === OrderSide.BUY) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n decimal = new Decimal(price).minus(new Decimal(entryPrice));\n }\n\n decimal = new Decimal(price).minus(new Decimal(entryPrice));\n }\n\n if (orderSide === OrderSide.SELL) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n decimal = new Decimal(price).minus(new Decimal(entryPrice));\n }\n\n decimal = new Decimal(entryPrice).minus(new Decimal(price));\n }\n\n if (symbol) {\n return decimal!.abs().todp(symbol.quote_dp, 4).toNumber();\n }\n\n return decimal!.abs().toNumber();\n}\n\nexport function offsetPercentageToPrice(inputs: {\n qty: number;\n percentage: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n}) {\n const { qty, percentage, entryPrice, orderType, orderSide } = inputs;\n\n if (!percentage) return;\n\n if (orderSide === OrderSide.BUY) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(1)\n .add(new Decimal(percentage))\n .mul(new Decimal(entryPrice))\n .toNumber();\n }\n\n return new Decimal(1)\n .minus(new Decimal(percentage))\n .mul(new Decimal(entryPrice))\n .toNumber();\n }\n\n if (orderSide === OrderSide.SELL) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(1)\n .minus(new Decimal(percentage))\n .mul(new Decimal(entryPrice))\n .toNumber();\n }\n\n return new Decimal(1)\n .add(new Decimal(percentage))\n .mul(new Decimal(entryPrice))\n .toNumber();\n }\n}\n\nexport function priceToOffsetPercentage(inputs: {\n qty: number;\n price: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n}) {\n const { qty, price, entryPrice, orderType, orderSide } = inputs;\n\n if (orderSide === OrderSide.BUY) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(price)\n .div(new Decimal(entryPrice))\n .minus(1)\n .toNumber();\n }\n\n return new Decimal(1)\n .minus(new Decimal(price).div(new Decimal(entryPrice)))\n .toNumber();\n }\n\n if (orderSide === OrderSide.SELL) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(1)\n .minus(new Decimal(price).div(new Decimal(entryPrice)))\n .toNumber();\n }\n\n return new Decimal(price).div(new Decimal(entryPrice)).minus(1).toNumber();\n }\n}\n\n/**\n * pnl -> TP/SL price\n */\nexport function pnlToPrice(inputs: {\n qty: number;\n pnl: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n}) {\n const { qty, pnl, entryPrice, orderType, orderSide } = inputs;\n\n console.log(\"pnlToPrice\", inputs);\n\n if (!pnl) {\n return;\n }\n\n if (orderSide === OrderSide.BUY) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(entryPrice)\n .plus(new Decimal(pnl).div(new Decimal(qty)))\n .toNumber();\n }\n\n return new Decimal(entryPrice)\n .add(new Decimal(pnl).div(new Decimal(qty)))\n .toNumber();\n }\n if (orderSide === OrderSide.SELL) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n return new Decimal(entryPrice)\n .add(new Decimal(pnl).div(new Decimal(qty)))\n .toNumber();\n }\n\n return new Decimal(entryPrice)\n .add(new Decimal(pnl).div(new Decimal(qty)))\n .toNumber();\n }\n}\n\n/**\n * TP/SL price -> pnl\n */\nexport function priceToPnl(\n inputs: {\n qty: number;\n price: number;\n entryPrice: number;\n orderSide: OrderSide;\n orderType: AlgoOrderType;\n },\n options: { symbol?: API.SymbolExt } = {}\n): number {\n const { qty, price, entryPrice, orderType, orderSide } = inputs;\n const { symbol } = options;\n let decimal = zero;\n\n if (orderSide === OrderSide.BUY) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n decimal = new Decimal(qty).mul(\n new Decimal(price).minus(new Decimal(entryPrice))\n );\n }\n\n decimal = new Decimal(qty).mul(\n new Decimal(price).minus(new Decimal(entryPrice))\n );\n }\n\n if (orderSide === OrderSide.SELL) {\n if (orderType === AlgoOrderType.TAKE_PROFIT) {\n decimal = new Decimal(qty).mul(\n new Decimal(price).minus(new Decimal(entryPrice))\n );\n }\n\n decimal = new Decimal(qty).mul(\n new Decimal(price).minus(new Decimal(entryPrice))\n );\n }\n\n if (symbol) {\n return decimal.todp(symbol.quote_dp, 4).toNumber();\n }\n\n return decimal.toNumber();\n}\n\nexport function calculateHelper(\n key: string,\n inputs: {\n key: string;\n value: string | number;\n entryPrice: number;\n qty: number;\n orderSide: OrderSide;\n },\n options: { symbol?: API.SymbolExt } = {}\n) {\n const { symbol } = options;\n // if not need to be computed, return the value directly\n if (\n key !== \"quantity\" &&\n key !== \"tp_trigger_price\" &&\n key !== \"sl_trigger_price\" &&\n key !== \"tp_pnl\" &&\n key !== \"sl_pnl\" &&\n key !== \"tp_offset\" &&\n key !== \"sl_offset\" &&\n key !== \"tp_offset_percentage\" &&\n key !== \"sl_offset_percentage\"\n ) {\n return {\n [key]: inputs.value,\n };\n }\n\n const orderType = key.startsWith(\"tp_\")\n ? AlgoOrderType.TAKE_PROFIT\n : AlgoOrderType.STOP_LOSS;\n const keyPrefix = key.slice(0, 3);\n\n let qty = Number(key === \"quantity\" ? inputs.value : inputs.qty);\n\n if (qty === 0)\n return {\n [`${keyPrefix}trigger_price`]: \"\",\n // [`${keyPrefix}offset`]: \"\",\n // [`${keyPrefix}offset_percentage`]: \"\",\n [`${keyPrefix}pnl`]: \"\",\n [key]: inputs.value,\n };\n\n let trigger_price, offset, offset_percentage, pnl;\n\n switch (key) {\n case \"tp_trigger_price\":\n case \"sl_trigger_price\": {\n trigger_price = inputs.value;\n // if trigger price is empty and the key is `*_trigger_price`, reset the offset and pnl\n if (inputs.value === \"\") {\n return {\n [`${keyPrefix}trigger_price`]: trigger_price,\n [`${keyPrefix}offset`]: \"\",\n [`${keyPrefix}offset_percentage`]: \"\",\n [`${keyPrefix}pnl`]: \"\",\n };\n }\n break;\n }\n\n case \"tp_pnl\":\n case \"sl_pnl\": {\n pnl = inputs.value;\n trigger_price = pnlToPrice({\n qty,\n pnl: Number(inputs.value),\n entryPrice: inputs.entryPrice,\n orderSide: inputs.orderSide,\n orderType,\n });\n break;\n }\n\n case \"tp_offset\":\n case \"sl_offset\": {\n offset = inputs.value;\n trigger_price = offsetToPrice({\n qty,\n offset: Number(inputs.value),\n entryPrice: inputs.entryPrice,\n orderSide: inputs.orderSide,\n orderType:\n key === \"tp_offset\"\n ? AlgoOrderType.TAKE_PROFIT\n : AlgoOrderType.STOP_LOSS,\n });\n break;\n }\n\n case \"tp_offset_percentage\":\n case \"sl_offset_percentage\": {\n offset_percentage = inputs.value;\n trigger_price = offsetPercentageToPrice({\n qty,\n percentage: Number(inputs.value),\n entryPrice: inputs.entryPrice,\n orderSide: inputs.orderSide,\n orderType,\n });\n break;\n }\n }\n\n if (!trigger_price)\n return {\n [`${keyPrefix}trigger_price`]: \"\",\n [`${keyPrefix}offset`]: \"\",\n [`${keyPrefix}offset_percentage`]: \"\",\n [`${keyPrefix}pnl`]: \"\",\n [key]: inputs.value,\n };\n\n return {\n [`${keyPrefix}trigger_price`]: symbol\n ? new Decimal(Number(trigger_price)).todp(symbol.quote_dp, 4).toNumber()\n : trigger_price,\n [`${keyPrefix}offset`]:\n offset ??\n priceToOffset(\n {\n qty,\n price: Number(trigger_price!),\n entryPrice: inputs.entryPrice,\n orderSide: inputs.orderSide,\n orderType,\n },\n options\n ),\n [`${keyPrefix}offset_percentage`]:\n offset_percentage ??\n priceToOffsetPercentage({\n qty,\n price: Number(trigger_price!),\n entryPrice: inputs.entryPrice,\n orderSide: inputs.orderSide,\n orderType,\n }),\n [`${keyPrefix}pnl`]:\n pnl ??\n priceToPnl(\n {\n qty,\n price: Number(trigger_price!),\n entryPrice: inputs.entryPrice,\n orderSide: inputs.orderSide,\n orderType,\n },\n options\n ),\n };\n}\n"],"names":["calculateHelper","offsetPercentageToPrice","offsetToPrice","pnlToPrice","priceToOffset","priceToOffsetPercentage","priceToPnl","inputs","qty","offset","entryPrice","orderType","orderSide","OrderSide","BUY","AlgoOrderType","TAKE_PROFIT","Decimal","add","toNumber","minus","SELL","options","price","symbol","decimal","abs","todp","quote_dp","percentage","mul","div","pnl","plus","zero","key","value","startsWith","STOP_LOSS","keyPrefix","slice","Number","trigger_price","offset_percentage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAuPgBA,eAAe;eAAfA;;IAnKAC,uBAAuB;eAAvBA;;IAjEAC,aAAa;eAAbA;;IA6IAC,UAAU;eAAVA;;IAjHAC,aAAa;eAAbA;;IA6EAC,uBAAuB;eAAvBA;;IA8EAC,UAAU;eAAVA;;;uBA1M6B;uBAGf;AAgBvB,SAASJ,cAAcK,MAM7B;IACC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,UAAU,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGL;IAE1D,IAAI,CAACE,QAAQ;IAEb,IAAIG,cAAcC,gBAAS,CAACC,GAAG,EAAE;QAC/B,IAAIH,cAAcI,oBAAa,CAACC,WAAW,EAAE;YAC3C,OAAO,IAAIC,cAAO,CAACP,YAAYQ,GAAG,CAAC,IAAID,cAAO,CAACR,SAASU,QAAQ;QAClE;QAEA,OAAO,IAAIF,cAAO,CAACP,YAAYU,KAAK,CAAC,IAAIH,cAAO,CAACR,SAASU,QAAQ;IACpE;IAEA,IAAIP,cAAcC,gBAAS,CAACQ,IAAI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P,OACA1B,WACE;YACEE;YACAe,OAAOkB,OAAOC;YACdhC,YAAYH,OAAOG,UAAU;YAC7BE,WAAWL,OAAOK,SAAS;YAC3BD;QACF,GACAW;IAEN;AACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=limitOrderCreator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitOrderCreator.test.d.ts","sourceRoot":"","sources":["../../../../src/services/orderCreator/__test__/limitOrderCreator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=orderCreator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderCreator.test.d.ts","sourceRoot":"","sources":["../../../../src/services/orderCreator/__test__/orderCreator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stopLimitOrderCreator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopLimitOrderCreator.test.d.ts","sourceRoot":"","sources":["../../../../src/services/orderCreator/__test__/stopLimitOrderCreator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stopMarketOrderCreator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopMarketOrderCreator.test.d.ts","sourceRoot":"","sources":["../../../../src/services/orderCreator/__test__/stopMarketOrderCreator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tpslOrderCreator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tpslOrderCreator.test.d.ts","sourceRoot":"","sources":["../../../../src/services/orderCreator/__test__/tpslOrderCreator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tpslPositionOrderCreator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tpslPositionOrderCreator.test.d.ts","sourceRoot":"","sources":["../../../../src/services/orderCreator/__test__/tpslPositionOrderCreator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { AlgoOrderEntity } from "@orderly.network/types";
2
+ import { OrderCreator, ValuesDepConfig } from "./interface";
3
+ import { AlgoOrderRootType } from "@orderly.network/types";
4
+ export type AlgoOrderUpdateEntity = {
5
+ trigger_price?: number;
6
+ order_id: number;
7
+ quantity?: number;
8
+ is_activated?: boolean;
9
+ };
10
+ export declare abstract class BaseAlgoOrderCreator<T extends AlgoOrderEntity<AlgoOrderRootType.POSITIONAL_TP_SL | AlgoOrderRootType.TP_SL>> implements OrderCreator<T> {
11
+ abstract create(values: T, config: ValuesDepConfig): T;
12
+ /**
13
+ * base validate
14
+ */
15
+ validate(values: Partial<T>, config: ValuesDepConfig): Promise<{
16
+ [P in keyof T]?: {
17
+ type: string;
18
+ message: string;
19
+ };
20
+ }>;
21
+ }
22
+ //# sourceMappingURL=baseAlgoCreator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseAlgoCreator.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/baseAlgoCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,YAAY,EAEZ,eAAe,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,8BAAsB,oBAAoB,CACxC,CAAC,SAAS,eAAe,CACvB,iBAAiB,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,KAAK,CAC7D,CACD,YAAW,YAAY,CAAC,CAAC,CAAC;IAE1B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,CAAC;IAEtD;;OAEG;IACH,QAAQ,CACN,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC;SACR,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YACf,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB;KACF,CAAC;CAsEH"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "BaseAlgoOrderCreator", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return BaseAlgoOrderCreator;
9
+ }
10
+ });
11
+ const _types = require("@orderly.network/types");
12
+ class BaseAlgoOrderCreator {
13
+ /**
14
+ * base validate
15
+ */ validate(values, config) {
16
+ const result = Object.create(null);
17
+ return Promise.resolve().then(()=>{
18
+ const { tp_trigger_price, sl_trigger_price, side } = values;
19
+ const qty = Number(values.quantity);
20
+ const maxQty = config.maxQty;
21
+ if (!isNaN(qty) && qty > maxQty) {
22
+ result.quantity = {
23
+ message: `Quantity must be less than ${config.maxQty}`
24
+ };
25
+ }
26
+ if (Number(tp_trigger_price) < 0) {
27
+ result.tp_trigger_price = {
28
+ message: `TP Price must be greater than 0`
29
+ };
30
+ }
31
+ if (Number(sl_trigger_price) < 0) {
32
+ result.sl_trigger_price = {
33
+ message: `SL Price must be greater than 0`
34
+ };
35
+ }
36
+ // there need use position side to validate
37
+ // so if order's side is buy, then position's side is sell
38
+ if (side === _types.OrderSide.BUY) {
39
+ if (!!sl_trigger_price && Number(sl_trigger_price) >= config.markPrice) {
40
+ result.sl_trigger_price = {
41
+ message: `SL price must be less than ${config.markPrice}`
42
+ };
43
+ }
44
+ if (!!tp_trigger_price && Number(tp_trigger_price) <= config.markPrice) {
45
+ result.tp_trigger_price = {
46
+ message: `TP price must be greater than ${config.markPrice}`
47
+ };
48
+ }
49
+ }
50
+ if (side === _types.OrderSide.SELL) {
51
+ if (!!sl_trigger_price && Number(sl_trigger_price) <= config.markPrice) {
52
+ result.sl_trigger_price = {
53
+ message: `SL price must be greater than ${config.markPrice}`
54
+ };
55
+ }
56
+ if (!!tp_trigger_price && Number(tp_trigger_price) >= config.markPrice) {
57
+ result.tp_trigger_price = {
58
+ message: `TP price must be less than ${config.markPrice}`
59
+ };
60
+ }
61
+ }
62
+ return Object.keys(result).length > 0 ? result : null;
63
+ });
64
+ }
65
+ }
66
+
67
+ //# sourceMappingURL=baseAlgoCreator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/orderCreator/baseAlgoCreator.ts"],"sourcesContent":["import { AlgoOrderEntity, OrderSide } from \"@orderly.network/types\";\nimport {\n OrderCreator,\n OrderFormEntity,\n ValuesDepConfig,\n VerifyResult,\n} from \"./interface\";\nimport { AlgoOrderRootType } from \"@orderly.network/types\";\n\nexport type AlgoOrderUpdateEntity = {\n trigger_price?: number;\n order_id: number;\n quantity?: number;\n is_activated?: boolean;\n};\n\nexport abstract class BaseAlgoOrderCreator<\n T extends AlgoOrderEntity<\n AlgoOrderRootType.POSITIONAL_TP_SL | AlgoOrderRootType.TP_SL\n >\n> implements OrderCreator<T>\n{\n abstract create(values: T, config: ValuesDepConfig): T;\n\n /**\n * base validate\n */\n validate(\n values: Partial<T>,\n config: ValuesDepConfig\n ): Promise<{\n [P in keyof T]?: {\n type: string;\n message: string;\n };\n }> {\n const result = Object.create(null);\n return Promise.resolve().then(() => {\n const { tp_trigger_price, sl_trigger_price, side } = values;\n\n const qty = Number(values.quantity);\n const maxQty = config.maxQty;\n if (!isNaN(qty) && qty > maxQty) {\n result.quantity = {\n message: `Quantity must be less than ${config.maxQty}`,\n };\n }\n\n if (Number(tp_trigger_price) < 0) {\n result.tp_trigger_price = {\n message: `TP Price must be greater than 0`,\n };\n }\n\n if (Number(sl_trigger_price) < 0) {\n result.sl_trigger_price = {\n message: `SL Price must be greater than 0`,\n };\n }\n\n // there need use position side to validate\n // so if order's side is buy, then position's side is sell\n if (side === OrderSide.BUY) {\n if (\n !!sl_trigger_price &&\n Number(sl_trigger_price) >= config.markPrice\n ) {\n result.sl_trigger_price = {\n message: `SL price must be less than ${config.markPrice}`,\n };\n }\n\n if (\n !!tp_trigger_price &&\n Number(tp_trigger_price) <= config.markPrice\n ) {\n result.tp_trigger_price = {\n message: `TP price must be greater than ${config.markPrice}`,\n };\n }\n }\n\n if (side === OrderSide.SELL) {\n if (\n !!sl_trigger_price &&\n Number(sl_trigger_price) <= config.markPrice\n ) {\n result.sl_trigger_price = {\n message: `SL price must be greater than ${config.markPrice}`,\n };\n }\n\n if (\n !!tp_trigger_price &&\n Number(tp_trigger_price) >= config.markPrice\n ) {\n result.tp_trigger_price = {\n message: `TP price must be less than ${config.markPrice}`,\n };\n }\n }\n\n return Object.keys(result).length > 0 ? result : null;\n });\n }\n}\n"],"names":["BaseAlgoOrderCreator","validate","values","config","result","Object","create","Promise","resolve","then","tp_trigger_price","sl_trigger_price","side","qty","Number","quantity","maxQty","isNaN","message","OrderSide","BUY","markPrice","SELL","keys","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgBsBA;;;eAAAA;;;uBAhBqB;AAgBpC,MAAeA;IAQpB;;GAEC,GACDC,SACEC,MAAkB,EAClBC,MAAuB,EAMtB;QACD,MAAMC,SAASC,OAAOC,MAAM,CAAC;QAC7B,OAAOC,QAAQC,OAAO,GAAGC,IAAI,CAAC;YAC5B,MAAM,EAAEC,gBAAgB,EAAEC,gBAAgB,EAAEC,IAAI,EAAE,GAAGV;YAErD,MAAMW,MAAMC,OAAOZ,OAAOa,QAAQ;YAClC,MAAMC,SAASb,OAAOa,MAAM;YAC5B,IAAI,CAACC,MAAMJ,QAAQA,MAAMG,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AAM,GAAG,IAAIpB,SAAS;QACnD;IACF;AACF"}
@@ -0,0 +1,14 @@
1
+ import { OrderEntity } from "@orderly.network/types";
2
+ import { OrderCreator, OrderFormEntity, ValuesDepConfig, VerifyResult } from "./interface";
3
+ export declare abstract class BaseOrderCreator<T> implements OrderCreator<T> {
4
+ abstract create(values: T, config?: ValuesDepConfig): T;
5
+ abstract validate(values: T, config: ValuesDepConfig): Promise<VerifyResult>;
6
+ baseOrder(data: OrderEntity): OrderEntity;
7
+ baseValidate(values: OrderFormEntity, configs: ValuesDepConfig): Promise<VerifyResult>;
8
+ totalToQuantity(order: {
9
+ order_quantity?: number | string;
10
+ total?: string | number;
11
+ order_price?: string | number;
12
+ }, config: ValuesDepConfig): OrderEntity;
13
+ }
14
+ //# sourceMappingURL=baseCreator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseCreator.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/baseCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,8BAAsB,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC;IAEvD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAE5E,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IA+BzC,YAAY,CACV,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC;IAoFxB,eAAe,CACb,KAAK,EAAE;QACL,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC/B,EACD,MAAM,EAAE,eAAe,GACtB,WAAW;CAaf"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "BaseOrderCreator", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return BaseOrderCreator;
9
+ }
10
+ });
11
+ const _types = require("@orderly.network/types");
12
+ const _utils = require("@orderly.network/utils");
13
+ const _createOrder = require("../../utils/createOrder");
14
+ class BaseOrderCreator {
15
+ baseOrder(data) {
16
+ const order = {
17
+ symbol: data.symbol,
18
+ order_type: data.order_type === _types.OrderType.LIMIT ? !!data.order_type_ext ? data.order_type_ext : data.order_type : data.order_type,
19
+ side: data.side,
20
+ reduce_only: data.reduce_only,
21
+ order_quantity: data.order_quantity,
22
+ total: data.total
23
+ };
24
+ if (data.visible_quantity === 0) {
25
+ order.visible_quantity = data.visible_quantity;
26
+ }
27
+ return order;
28
+ }
29
+ baseValidate(values, configs) {
30
+ const errors = {};
31
+ const { maxQty, symbol } = configs;
32
+ let { order_quantity, total, order_price, reduce_only } = values;
33
+ const { min_notional } = symbol;
34
+ if (!order_quantity) {
35
+ // calculate order_quantity from total
36
+ if (total && order_price) {
37
+ const { quote_dp } = configs.symbol;
38
+ const totalNumber = new _utils.Decimal(total);
39
+ const qty = totalNumber.dividedBy(order_price).toFixed(quote_dp);
40
+ order_quantity = qty;
41
+ }
42
+ }
43
+ if (!order_quantity) {
44
+ errors.order_quantity = {
45
+ type: "required",
46
+ message: "quantity is required"
47
+ };
48
+ } else {
49
+ // need to use MaxQty+base_max, base_min to compare
50
+ const { base_min, quote_dp, base_dp } = configs.symbol;
51
+ const qty = new _utils.Decimal(order_quantity);
52
+ if (qty.lt(base_min)) {
53
+ errors.order_quantity = {
54
+ type: "min",
55
+ message: `quantity must be greater than ${new _utils.Decimal(base_min).todp(base_dp)}`
56
+ };
57
+ // errors.order_quantity = `quantity must be greater than ${base_min}`;
58
+ } else if (qty.gt(maxQty)) {
59
+ errors.order_quantity = {
60
+ type: "max",
61
+ message: `quantity must be less than ${new _utils.Decimal(maxQty).todp(base_dp)}`
62
+ };
63
+ }
64
+ }
65
+ if (!!total) {
66
+ const { quote_max, quote_min, quote_dp } = configs.symbol;
67
+ const totalNumber = new _utils.Decimal(total);
68
+ if (totalNumber.lt(quote_min)) {
69
+ errors.total = {
70
+ type: "min",
71
+ message: `Quantity must be at least ${new _utils.Decimal(quote_min).todp(quote_dp)}`
72
+ };
73
+ } else if (totalNumber.gt(quote_max)) {
74
+ errors.total = {
75
+ type: "max",
76
+ message: `Quantity should be less or equal than ${new _utils.Decimal(quote_max).todp(quote_dp)}`
77
+ };
78
+ }
79
+ }
80
+ const notionalHintStr = (0, _createOrder.checkNotional)(order_price, order_quantity, min_notional);
81
+ if (notionalHintStr !== undefined && reduce_only !== true) {
82
+ errors.total = {
83
+ type: "min",
84
+ message: notionalHintStr
85
+ };
86
+ }
87
+ return Promise.resolve(errors);
88
+ }
89
+ totalToQuantity(order, config) {
90
+ // if order_quantity is not set but total is set, calculate order_quantity from total
91
+ if (!order.order_quantity && order.total && order.order_price) {
92
+ const { base_dp } = config.symbol;
93
+ const totalNumber = new _utils.Decimal(order.total);
94
+ const qty = totalNumber.div(order.order_price).toDecimalPlaces(base_dp);
95
+ order.order_quantity = qty.toNumber();
96
+ delete order.total;
97
+ }
98
+ return order;
99
+ }
100
+ }
101
+
102
+ //# sourceMappingURL=baseCreator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/orderCreator/baseCreator.ts"],"sourcesContent":["import { OrderEntity, OrderType } from \"@orderly.network/types\";\nimport {\n OrderCreator,\n OrderFormEntity,\n ValuesDepConfig,\n VerifyResult,\n} from \"./interface\";\nimport { Decimal } from \"@orderly.network/utils\";\nimport { checkNotional } from \"../../utils/createOrder\";\n\nexport abstract class BaseOrderCreator<T> implements OrderCreator<T> {\n abstract create(values: T, config?: ValuesDepConfig): T;\n\n abstract validate(values: T, config: ValuesDepConfig): Promise<VerifyResult>;\n\n baseOrder(data: OrderEntity): OrderEntity {\n const order: Pick<\n OrderEntity,\n | \"symbol\"\n | \"order_type\"\n | \"side\"\n | \"reduce_only\"\n | \"order_quantity\"\n | \"total\"\n | \"visible_quantity\"\n > = {\n symbol: data.symbol!,\n order_type:\n data.order_type === OrderType.LIMIT\n ? !!data.order_type_ext\n ? data.order_type_ext\n : data.order_type\n : data.order_type,\n side: data.side,\n reduce_only: data.reduce_only!,\n order_quantity: data.order_quantity!,\n total: data.total,\n };\n\n if (data.visible_quantity === 0) {\n order.visible_quantity = data.visible_quantity;\n }\n\n return order as OrderEntity;\n }\n\n baseValidate(\n values: OrderFormEntity,\n configs: ValuesDepConfig\n ): Promise<VerifyResult> {\n const errors: {\n [P in keyof OrderEntity]?: { type: string; message: string };\n } = {};\n\n const { maxQty, symbol } = configs;\n\n let { order_quantity, total, order_price, reduce_only } = values;\n\n const { min_notional } = symbol;\n\n if (!order_quantity) {\n // calculate order_quantity from total\n if (total && order_price) {\n const { quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n const qty = totalNumber.dividedBy(order_price).toFixed(quote_dp);\n order_quantity = qty;\n }\n }\n\n if (!order_quantity) {\n errors.order_quantity = {\n type: \"required\",\n message: \"quantity is required\",\n };\n } else {\n // need to use MaxQty+base_max, base_min to compare\n const { base_min, quote_dp, base_dp } = configs.symbol;\n const qty = new Decimal(order_quantity);\n if (qty.lt(base_min)) {\n errors.order_quantity = {\n type: \"min\",\n message: `quantity must be greater than ${new Decimal(base_min).todp(\n base_dp\n )}`,\n };\n // errors.order_quantity = `quantity must be greater than ${base_min}`;\n } else if (qty.gt(maxQty)) {\n errors.order_quantity = {\n type: \"max\",\n message: `quantity must be less than ${new Decimal(maxQty).todp(\n base_dp\n )}`,\n };\n }\n }\n\n if (!!total) {\n const { quote_max, quote_min, quote_dp } = configs.symbol;\n const totalNumber = new Decimal(total);\n if (totalNumber.lt(quote_min)) {\n errors.total = {\n type: \"min\",\n message: `Quantity must be at least ${new Decimal(quote_min).todp(\n quote_dp\n )}`,\n };\n } else if (totalNumber.gt(quote_max)) {\n errors.total = {\n type: \"max\",\n message: `Quantity should be less or equal than ${new Decimal(\n quote_max\n ).todp(quote_dp)}`,\n };\n }\n }\n\n const notionalHintStr = checkNotional(\n order_price,\n order_quantity,\n min_notional\n );\n\n if (notionalHintStr !== undefined && reduce_only !== true) {\n errors.total = {\n type: \"min\",\n message: notionalHintStr,\n };\n }\n\n return Promise.resolve(errors);\n }\n\n totalToQuantity(\n order: {\n order_quantity?: number | string;\n total?: string | number;\n order_price?: string | number;\n },\n config: ValuesDepConfig\n ): OrderEntity {\n // if order_quantity is not set but total is set, calculate order_quantity from total\n if (!order.order_quantity && order.total && order.order_price) {\n const { base_dp } = config.symbol;\n const totalNumber = new Decimal(order.total);\n const qty = totalNumber.div(order.order_price).toDecimalPlaces(base_dp);\n order.order_quantity = qty.toNumber();\n\n delete order.total;\n }\n\n return order as OrderEntity;\n }\n}\n"],"names":["BaseOrderCreator","baseOrder","data","order","symbol","order_type","OrderType","LIMIT","order_type_ext","side","reduce_only","order_quantity","total","visible_quantity","baseValidate","values","configs","errors","maxQty","order_price","min_notional","quote_dp","totalNumber","Decimal","qty","dividedBy","toFixed","type","message","base_min","base_dp","lt","todp","gt","quote_max","quote_min","notionalHintStr","checkNotional","undefined","Promise","resolve","totalToQuantity","config","div","toDecimalPlaces","toNumber"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAUsBA;;;eAAAA;;;uBAViB;uBAOf;6BACM;AAEvB,MAAeA;IAKpBC,UAAUC,IAAiB,EAAe;QACxC,MAAMC,QASF;YACFC,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AAMY,MAAMF,YAAYqB,GAAG,CAACxC,MAAMgB,WAAW,EAAEyB,eAAe,CAACd;YAC/D3B,MAAMQ,cAAc,GAAGa,IAAIqB,QAAQ;YAEnC,OAAO1C,MAAMS,KAAK;QACpB;QAEA,OAAOT;IACT;AACF"}
@@ -0,0 +1,7 @@
1
+ import { OrderType } from "@orderly.network/types";
2
+ import { OrderCreator } from "./interface";
3
+ import { AlgoOrderRootType } from "@orderly.network/types";
4
+ export declare class OrderFactory {
5
+ static create(type: OrderType | AlgoOrderRootType): OrderCreator<any>;
6
+ }
7
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/services/orderCreator/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D,qBAAa,YAAY;IACvB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC;CAgCtE"}