erms2Models.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // Package models 211.2风险管理系统2020_期现套利
  2. package models
  3. import "time"
  4. // Hedgeinnertradedetail 对冲内部成交单表 - 导历史
  5. type Hedgeinnertradedetail struct {
  6. Tradeid int64 `json:"tradeid" xorm:"'TRADEID'" binding:"required"` // 成交单号(108+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
  7. Buyorsell int64 `json:"buyorsell" xorm:"'BUYORSELL'" binding:"required"` // 方向 - 0:买 1:卖
  8. Orderid int64 `json:"orderid" xorm:"'ORDERID'"` // 委托单号
  9. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  10. Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 账号ID
  11. Goodsid int64 `json:"goodsid" xorm:"'GOODSID'"` // 商品ID
  12. Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  13. Tradetime time.Time `json:"tradetime" xorm:"'TRADETIME'"` // 成交时间
  14. Tradeprice float64 `json:"tradeprice" xorm:"'TRADEPRICE'"` // 成交价格
  15. Tradeqty int64 `json:"tradeqty" xorm:"'TRADEQTY'"` // 成交数量
  16. Tradeamount float64 `json:"tradeamount" xorm:"'TRADEAMOUNT'"` // 成交金额(账户)
  17. Closepl float64 `json:"closepl" xorm:"'CLOSEPL'"` // 平仓盈亏(账户)
  18. Opencharge float64 `json:"opencharge" xorm:"'OPENCHARGE'"` // 建仓手续费(账户)
  19. Closecharge float64 `json:"closecharge" xorm:"'CLOSECHARGE'"` // 平仓手续费(账户)
  20. Tradetype int64 `json:"tradetype" xorm:"'TRADETYPE'"` // 成交类别 - 1:正常委托成交 2:风控斩仓成交 3:修正持仓成交 4:管理端斩仓成交
  21. Channelbuildtype int64 `json:"channelbuildtype" xorm:"'CHANNELBUILDTYPE'"` // 委托单据类型 0:无 1:建仓 2:平仓
  22. Closetype int64 `json:"closetype" xorm:"'CLOSETYPE'"` // 平仓方式 - 0:无 1:平今 2:平昨
  23. Hedgeflag int64 `json:"hedgeflag" xorm:"'HEDGEFLAG'"` // 投机套保标志 - 0:无 1:投机 2:套保 3:套利
  24. Openqty int64 `json:"openqty" xorm:"'OPENQTY'"` // 开仓数量(先建后平操作 需要记录)
  25. Closeqty int64 `json:"closeqty" xorm:"'CLOSEQTY'"` // 平仓数量(先建后平操作 需要记录)
  26. Status int64 `json:"status" xorm:"'STATUS'"` // 处理状态 - 1:待处理 2:已处理 3:处理失败
  27. Isreckoned int64 `json:"isreckoned" xorm:"'ISRECKONED'"` // 是否结算 - 0:未结算 1:已结算
  28. Openfeealgorithm int64 `json:"openfeealgorithm" xorm:"'OPENFEEALGORITHM'"` // 建仓手续费收取方式 1:比率 2:固定
  29. Openchargevalue float64 `json:"openchargevalue" xorm:"'OPENCHARGEVALUE'"` // 建仓手续费设置值
  30. Closefeealgorithm int64 `json:"closefeealgorithm" xorm:"'CLOSEFEEALGORITHM'"` // 平仓手续费收取方式 1:比率 2:固定
  31. Closechargevalue float64 `json:"closechargevalue" xorm:"'CLOSECHARGEVALUE'"` // 平仓手续费设置值
  32. Accountcurrencyid int64 `json:"accountcurrencyid" xorm:"'ACCOUNTCURRENCYID'"` // 账户币种ID
  33. Goodscurrencyid int64 `json:"goodscurrencyid" xorm:"'GOODSCURRENCYID'"` // 商品币种ID
  34. Curexchangerate float64 `json:"curexchangerate" xorm:"'CUREXCHANGERATE'"` // 当前汇率
  35. Opencharge2 float64 `json:"opencharge2" xorm:"'OPENCHARGE2'"` // 建仓手续费(商品)
  36. Closecharge2 float64 `json:"closecharge2" xorm:"'CLOSECHARGE2'"` // 平仓手续费(商品)
  37. Closepl2 float64 `json:"closepl2" xorm:"'CLOSEPL2'"` // 平仓盈亏(商品)
  38. Closepl3 float64 `json:"closepl3" xorm:"'CLOSEPL3'"` // 平仓盈亏(账户)(逐笔)
  39. Closepl4 float64 `json:"closepl4" xorm:"'CLOSEPL4'"` // 平仓盈亏(商品)(逐笔)
  40. Extenalopenfeealgorithm int64 `json:"extenalopenfeealgorithm" xorm:"'EXTENALOPENFEEALGORITHM'"` // 建仓手续费收取方式(外部配置) 1:比率 2:固定
  41. Extenalopenchargevalue float64 `json:"extenalopenchargevalue" xorm:"'EXTENALOPENCHARGEVALUE'"` // 建仓手续费设置值
  42. Extenalclosefeealgorithm int64 `json:"extenalclosefeealgorithm" xorm:"'EXTENALCLOSEFEEALGORITHM'"` // 平仓手续费收取方式 1:比率 2:固定
  43. Extenalclosechargevalue float64 `json:"extenalclosechargevalue" xorm:"'EXTENALCLOSECHARGEVALUE'"` // 平仓手续费设置值
  44. Extenalopencharge float64 `json:"extenalopencharge" xorm:"'EXTENALOPENCHARGE'"` // 建仓手续费(商品)(外部)
  45. Extenalclosecharge float64 `json:"extenalclosecharge" xorm:"'EXTENALCLOSECHARGE'"` // 平仓手续费(商品)(外部)
  46. Parentaccountid int64 `json:"parentaccountid" xorm:"'PARENTACCOUNTID'"` // 所属母账户
  47. Relatedouttradeid int64 `json:"relatedouttradeid" xorm:"'RELATEDOUTTRADEID'"` // 关联外部成交单ID
  48. }
  49. // TableName is HEDGE_INNERTRADEDETAIL
  50. func (Hedgeinnertradedetail) TableName() string {
  51. return "HEDGE_INNERTRADEDETAIL"
  52. }
  53. // Erms2astradedetails 期现套利期货成交单关联表
  54. type Erms2astradedetails struct {
  55. Asapplyid int64 `json:"asapplyid" xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID
  56. Outtradeid int64 `json:"outtradeid" xorm:"'OUTTRADEID'" binding:"required"` // 外部成交单ID(114+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
  57. Biztype int64 `json:"biztype" xorm:"'BIZTYPE'"` // 策略业务类型 - 1:正向套利 2:反向套利
  58. Detailtype int64 `json:"detailtype" xorm:"'DETAILTYPE'"` // 明细类型 - 1:套利对冲 2:期货换月 3:期货仓位调整
  59. Spotcontractid int64 `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 现货合同ID [1:套利对冲 为合同ID,2:期货换月\3:期货仓位调整时为0]
  60. Contracttype int64 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购合同 -1:销售合同
  61. Hedgegoodsid int64 `json:"hedgegoodsid" xorm:"'HEDGEGOODSID'"` // 对冲合约ID
  62. Buyorsell int64 `json:"buyorsell" xorm:"'BUYORSELL'"` // 买卖方向 - 0:买 1:卖 [成交单方向]
  63. Buildtype int64 `json:"buildtype" xorm:"'BUILDTYPE'"` // 开平标志- 0:无 1:开仓 2:平仓 [根据成交单方向及策略业务类型确定]正向套利 成交单:卖 开 成交单:买 平反向套利 成交单:买 开 成交单:卖 平
  64. Goodsgroupid int64 `json:"goodsgroupid" xorm:"'GOODSGROUPID'"` // 对冲品种ID[期货合约商品组ID]
  65. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 成交交易日(yyyyMMdd)
  66. Tradeprice float64 `json:"tradeprice" xorm:"'TRADEPRICE'"` // 成交价
  67. Tradelot float64 `json:"tradelot" xorm:"'TRADELOT'"` // 成交手数
  68. Agreeunit float64 `json:"agreeunit" xorm:"'AGREEUNIT'"` // 合约单位
  69. Tradeamount float64 `json:"tradeamount" xorm:"'TRADEAMOUNT'"` // 成交金额 = 成交价*成交手数*合约单位
  70. Tradecharge float64 `json:"tradecharge" xorm:"'TRADECHARGE'"` // 交易手续费
  71. Basisflag int64 `json:"basisflag" xorm:"'BASISFLAG'"` // 是否计入基差损益 - 0:不计入 1:计入 [明细类型:1\2为1,3:期货仓位调整是为0]
  72. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  73. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  74. }
  75. // TableName is ERMS2_ASTRADEDETAILS
  76. func (Erms2astradedetails) TableName() string {
  77. return "ERMS2_ASTRADEDETAILS"
  78. }
  79. // Erms2arbitragestrategy 期现套利策略表 - 导历史
  80. type Erms2arbitragestrategy struct {
  81. Asapplyid int64 `json:"asapplyid" xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID(702+Unix秒时间戳(10位)+xxxxxx)
  82. Asno string `json:"asno" xorm:"'ASNO'"` // 策略编号
  83. Biztype int64 `json:"biztype" xorm:"'BIZTYPE'"` // 业务类型 - 1:正向套利 -1:反向套利
  84. Userid int64 `json:"userid" xorm:"'USERID'"` // 所属机构
  85. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  86. Goodsgroupid int64 `json:"goodsgroupid" xorm:"'GOODSGROUPID'"` // 期货品种ID
  87. Spotquota float64 `json:"spotquota" xorm:"'SPOTQUOTA'"` // 现货额度
  88. Futurequote float64 `json:"futurequote" xorm:"'FUTUREQUOTE'"` // 期货额度
  89. Applybasis float64 `json:"applybasis" xorm:"'APPLYBASIS'"` // 申请基差
  90. Strategystatus int64 `json:"strategystatus" xorm:"'STRATEGYSTATUS'"` // 策略状态 - 0:未结束 1:已结束
  91. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  92. Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  93. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  94. Closetradedate string `json:"closetradedate" xorm:"'CLOSETRADEDATE'"` // 完结交易日(yyyyMMdd)
  95. Usedquota float64 `json:"usedquota" xorm:"'USEDQUOTA'"` // 已占用资金
  96. Futureqty float64 `json:"futureqty" xorm:"'FUTUREQTY'"` // 期货持仓数量
  97. Futureavgprice float64 `json:"futureavgprice" xorm:"'FUTUREAVGPRICE'"` // 期货建仓均价
  98. Futurepl float64 `json:"futurepl" xorm:"'FUTUREPL'"` // 期货总盈亏[结算更新]
  99. Pricedspotqty float64 `json:"pricedspotqty" xorm:"'PRICEDSPOTQTY'"` // 已定价现货数量
  100. Pricedspotqtynotax float64 `json:"pricedspotqtynotax" xorm:"'PRICEDSPOTQTYNOTAX'"` // 已定价现货不含税数量
  101. Spotavgprice float64 `json:"spotavgprice" xorm:"'SPOTAVGPRICE'"` // 现货均价
  102. Spotpl float64 `json:"spotpl" xorm:"'SPOTPL'"` // 现货总盈亏[结算更新]
  103. Netexposure float64 `json:"netexposure" xorm:"'NETEXPOSURE'"` // 单笔业务头寸净敞口 = 期货持仓数量 + 已定价现货不含税数量
  104. Netexposurerate float64 `json:"netexposurerate" xorm:"'NETEXPOSURERATE'"` // 净敞口比例 - 0:未结束 = (NetExposure/PriceSpotQtyNoTax) ; 已结束为0
  105. Totalpl float64 `json:"totalpl" xorm:"'TOTALPL'"` // 业务合计损益 = FuturePL + SpotPL [结算更新]
  106. Openbasis float64 `json:"openbasis" xorm:"'OPENBASIS'"` // 建仓基差
  107. Curbasis float64 `json:"curbasis" xorm:"'CURBASIS'"` // 当前基差[结算更新]
  108. Basischangepl float64 `json:"basischangepl" xorm:"'BASISCHANGEPL'"` // 基差变动损益[结算更新]
  109. Netexposurepl float64 `json:"netexposurepl" xorm:"'NETEXPOSUREPL'"` // 净敞口损益 = TotalPL - BasisChangePL[结算更新]
  110. Spotusedquota float64 `json:"spotusedquota" xorm:"'SPOTUSEDQUOTA'"` // 现货占用资金
  111. Futureopenqty float64 `json:"futureopenqty" xorm:"'FUTUREOPENQTY'"` // 期货开仓数量
  112. Futureopenamount float64 `json:"futureopenamount" xorm:"'FUTUREOPENAMOUNT'"` // 期货开仓金额
  113. Futurecloseqty float64 `json:"futurecloseqty" xorm:"'FUTURECLOSEQTY'"` // 期货平仓数量
  114. Futurecloseamount float64 `json:"futurecloseamount" xorm:"'FUTURECLOSEAMOUNT'"` // 期货平仓金额
  115. Spotbuyamount float64 `json:"spotbuyamount" xorm:"'SPOTBUYAMOUNT'"` // 现货采购金额
  116. Spotbuyqty float64 `json:"spotbuyqty" xorm:"'SPOTBUYQTY'"` // 现货采购数量
  117. Spotsellamount float64 `json:"spotsellamount" xorm:"'SPOTSELLAMOUNT'"` // 现货销售金额
  118. Spotsellqty float64 `json:"spotsellqty" xorm:"'SPOTSELLQTY'"` // 现货销售数量
  119. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  120. Asname string `json:"asname" xorm:"'ASNAME'"` // 策略名称
  121. }
  122. // TableName is ERMS2_ARBITRAGESTRATEGY
  123. func (Erms2arbitragestrategy) TableName() string {
  124. return "ERMS2_ARBITRAGESTRATEGY"
  125. }
  126. // Erms2spotcontract 现货合同表
  127. type Erms2spotcontract struct {
  128. Spotcontractid int64 `json:"spotcontractid" xorm:"'SPOTCONTRACTID'" binding:"required"` // 现货合同ID(701+Unix秒时间戳(10位)+xxxxxx)
  129. Tradedate string `json:"tradedate" xorm:"'TRADEDATE'"` // 交易日(yyyyMMdd)
  130. Contractno string `json:"contractno" xorm:"'CONTRACTNO'"` // 现货合同编号
  131. Contracttype int64 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购合同 -1:销售合同
  132. Areauserid int64 `json:"areauserid" xorm:"'AREAUSERID'"` // 所属机构
  133. Userid int64 `json:"userid" xorm:"'USERID'"` // 业务员用户ID
  134. Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'"` // 资金账户ID
  135. Customeruserid int64 `json:"customeruserid" xorm:"'CUSTOMERUSERID'"` // 客户ID
  136. Customeraccountid int64 `json:"customeraccountid" xorm:"'CUSTOMERACCOUNTID'"` // 客户资金账户ID
  137. Signdate time.Time `json:"signdate" xorm:"'SIGNDATE'"` // 签订日期
  138. Lastdate time.Time `json:"lastdate" xorm:"'LASTDATE'"` // 交货时间
  139. Contractattachment string `json:"contractattachment" xorm:"'CONTRACTATTACHMENT'"` // 合同附件
  140. Producttype int64 `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
  141. Deliverygoodsid int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
  142. Deliverygoodsdesc string `json:"deliverygoodsdesc" xorm:"'DELIVERYGOODSDESC'"` // 品种说明
  143. Warehouseid int64 `json:"warehouseid" xorm:"'WAREHOUSEID'"` // 仓库ID
  144. Wrfactortypeid int64 `json:"wrfactortypeid" xorm:"'WRFACTORTYPEID'"` // 仓单要素类型ID
  145. Contractqtychar string `json:"contractqtychar" xorm:"'CONTRACTQTYCHAR'"` // 合同数量\已订价数量 (用于显示)
  146. Spotprice float64 `json:"spotprice" xorm:"'SPOTPRICE'"` // 价格
  147. Contractamount float64 `json:"contractamount" xorm:"'CONTRACTAMOUNT'"` // 合同金额
  148. Marketid int64 `json:"marketid" xorm:"'MARKETID'"` // 市场ID
  149. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  150. Handlestatus int64 `json:"handlestatus" xorm:"'HANDLESTATUS'"` // 处理状态
  151. Contractqty float64 `json:"contractqty" xorm:"'CONTRACTQTY'"` // 合同数量(数值) (用于计算)
  152. Positionqty int64 `json:"positionqty" xorm:"'POSITIONQTY'"` // 头寸数量 - 合同数量去小数部分
  153. Paystatus int64 `json:"paystatus" xorm:"'PAYSTATUS'"` // 收付款状态 - 0:未支付 1:已收款 2:已付款
  154. Payremark string `json:"payremark" xorm:"'PAYREMARK'"` // 收付款备注
  155. Paydatetime time.Time `json:"paydatetime" xorm:"'PAYDATETIME'"` // 收付款更新时间
  156. Invoicestatus int64 `json:"invoicestatus" xorm:"'INVOICESTATUS'"` // 开收票状态 - 0:未开票 1:已开票
  157. Invoiceremark string `json:"invoiceremark" xorm:"'INVOICEREMARK'"` // 发票备注
  158. Invoiceatt string `json:"invoiceatt" xorm:"'INVOICEATT'"` // 发票附件
  159. Invoicedatetime time.Time `json:"invoicedatetime" xorm:"'INVOICEDATETIME'"` // 开收票更新时间
  160. Spotstatus int64 `json:"spotstatus" xorm:"'SPOTSTATUS'"` // 收发货状态 - 0:未交收 1:已发货 2:已发货
  161. Spotremark string `json:"spotremark" xorm:"'SPOTREMARK'"` // 收发货备注
  162. Spotdatetime time.Time `json:"spotdatetime" xorm:"'SPOTDATETIME'"` // 收发货更新时间
  163. Relatedqty float64 `json:"relatedqty" xorm:"'RELATEDQTY'"` // 已关联数量
  164. Contractstatus int64 `json:"contractstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态 - 0:未结束 1:已结束
  165. Closeremark string `json:"closeremark" xorm:"'CLOSEREMARK'"` // 结束备注
  166. Closetradedate string `json:"closetradedate" xorm:"'CLOSETRADEDATE'"` // 完结交易日(yyyyMMdd)
  167. Relatedstatus int64 `json:"relatedstatus" xorm:"'RELATEDSTATUS'"` // 关联完结状态 - 0:未结束 1:已结束
  168. Wrstandardid int64 `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 仓单标准ID(SEQ_WRSTANDARD)
  169. Invoiceopentime time.Time `json:"invoiceopentime" xorm:"'INVOICEOPENTIME'"` // 开票时间
  170. Closetype int64 `json:"closetype" xorm:"'CLOSETYPE'"` // 终止类型 - 1:违约 2:提前终止
  171. Closedate time.Time `json:"closedate" xorm:"'CLOSEDATE'"` // 终止日期
  172. }
  173. // TableName is ERMS2_SPOTCONTRACT
  174. func (Erms2spotcontract) TableName() string {
  175. return "ERMS2_SPOTCONTRACT"
  176. }
  177. // Erms2asaccount 期现套利资金账户表
  178. type Erms2asaccount struct {
  179. Asapplyid int64 `json:"asapplyid" xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID(702+Unix秒时间戳(10位)+xxxxxx)
  180. Accountid int64 `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"` // 资金账户
  181. Taaccounttype int64 `json:"taaccounttype" xorm:"'TAACCOUNTTYPE'"` // 账户类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号
  182. Taaccountbiztype int64 `json:"taaccountbiztype" xorm:"'TAACCOUNTBIZTYPE'"` // 账户业务类型 - 1:现货 2:期货
  183. }
  184. // TableName is ERMS2_ASACCOUNT
  185. func (Erms2asaccount) TableName() string {
  186. return "ERMS2_ASACCOUNT"
  187. }
  188. // Erms2asspotdetail 期现套利现货明细表 - 导历史
  189. type Erms2asspotdetail struct {
  190. Asapplyid int64 `json:"asapplyid" xorm:"'ASAPPLYID'" binding:"required"` // 策略申请ID
  191. Spotcontractid int64 `json:"spotcontractid" xorm:"'SPOTCONTRACTID'" binding:"required"` // 现货合同ID
  192. Contracttype int64 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 现货合同类型 - 1:采购合同 -1:销售合同
  193. Pricedspotqty float64 `json:"pricedspotqty" xorm:"'PRICEDSPOTQTY'"` // 已定价数量(合同数量 * 合同类型)
  194. Pricedspotqtynotax float64 `json:"pricedspotqtynotax" xorm:"'PRICEDSPOTQTYNOTAX'"` // 已定价不含税数量( 已定价数量 /(1+对冲税率))
  195. Vatrate float64 `json:"vatrate" xorm:"'VATRATE'"` // 税率
  196. Spotprice float64 `json:"spotprice" xorm:"'SPOTPRICE'"` // 价格
  197. Spotamount float64 `json:"spotamount" xorm:"'SPOTAMOUNT'"` // 收付款资金(合同金额 * 合同类型)
  198. Detailstatus int64 `json:"detailstatus" xorm:"'DETAILSTATUS'"` // 明细状态 - 0:未结束 1:已结束
  199. Futureqty float64 `json:"futureqty" xorm:"'FUTUREQTY'"` // 期货已对冲数量
  200. Futureamount float64 `json:"futureamount" xorm:"'FUTUREAMOUNT'"` // 期货成交金额
  201. Closetradedate string `json:"closetradedate" xorm:"'CLOSETRADEDATE'"` // 完结交易日(yyyyMMdd)
  202. Remark string `json:"remark" xorm:"'REMARK'"` // 备注
  203. Updatetime time.Time `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
  204. }
  205. // TableName is ERMS2_ASSPOTDETAIL
  206. func (Erms2asspotdetail) TableName() string {
  207. return "ERMS2_ASSPOTDETAIL"
  208. }