/
models.go
756 lines (676 loc) · 26.5 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
package govortex
import (
"time"
"github.com/lib/pq"
)
type FullQuoteData struct {
Exchange string `json:"exchange"`
Token int `json:"token"`
LastTradeTime int `json:"last_trade_time"`
LastUpdateTime int `json:"last_update_time"`
LastTradePrice float64 `json:"last_trade_price"`
Volume int `json:"volume"`
AverageTradePrice float64 `json:"average_trade_price"`
TotalBuyQuantity int64 `json:"total_buy_quantity"`
TotalSellQuantity int64 `json:"total_sell_quantity"`
OpenInterest int `json:"open_interest"`
OpenPrice float64 `json:"open_price"`
HighPrice float64 `json:"high_price"`
LowPrice float64 `json:"low_price"`
ClosePrice float64 `json:"close_price"`
LastTradeQuantity int `json:"last_trade_quantity"`
Depth *QuoteDepth `json:"depth"`
DPRHigh float64 `json:"dpr_high"`
DPRLow float64 `json:"dpr_low"`
}
type OhlcvQuoteData struct {
Exchange string `json:"exchange"`
Token int `json:"token"`
LastTradePrice float64 `json:"last_trade_price"`
LastTradeTime int `json:"last_trade_time"`
Volume int `json:"volume"`
OpenPrice float64 `json:"open_price"`
HighPrice float64 `json:"high_price"`
LowPrice float64 `json:"low_price"`
ClosePrice float64 `json:"close_price"`
}
type LtpQuoteData struct {
Exchange string `json:"exchange"`
Token int `json:"token"`
LastTradePrice float64 `json:"last_trade_price"`
}
type QuoteResponse struct {
Status string `json:"status"`
Data map[string]interface{} `json:"data"`
}
type MarginResponse struct {
Status string `json:"status"`
Required float64 `json:"required_margin"`
Available float64 `json:"available_margin"`
}
type BasketMarginResponse struct {
Status string `json:"status"`
InitialMargin float64 `json:"initial_margin"`
RequiredMargin float64 `json:"required_margin"`
}
type FundsResponse struct {
NSE FundDetails `json:"nse"`
MCX FundDetails `json:"mcx"`
}
type HistoricalResponse struct {
S string `json:"s"`
T []int `json:"t"`
O []float64 `json:"o"`
H []float64 `json:"h"`
L []float64 `json:"l"`
C []float64 `json:"c"`
V []float64 `json:"v"`
}
type FundDetails struct {
Deposit float64 `json:"deposit"`
FundsTransferred float64 `json:"funds_transferred"`
Collateral float64 `json:"collateral"`
CreditForSale float64 `json:"credit_for_sale"`
OptionCreditForSale float64 `json:"option_credit_for_sale"`
LimitUtilization float64 `json:"limit_utilization"`
FundsWithdrawn float64 `json:"funds_withdrawn"`
MtmAndBookedLoss float64 `json:"mtm_and_booked_loss"`
BookedProfit float64 `json:"booked_profit"`
TotalTradingPower float64 `json:"total_trading_power"`
TotalUtilization float64 `json:"total_utilization"`
NetAvailable float64 `json:"net_available"`
}
type ExchangeDetails struct {
Token int `json:"token"`
Exchange string `json:"exchange"`
Symbol string `json:"symbol"`
}
type ExchangeDetail struct {
Token int `json:"token"`
Exchange ExchangeTypes `json:"exchange"`
Symbol string `json:"symbol"`
}
type Holding struct {
ISIN string `json:"isin"`
NSE *ExchangeDetail `json:"nse,omitempty"`
BSE *ExchangeDetail `json:"bse,omitempty"`
TotalFree int `json:"total_free"`
DPFree int `json:"dp_free"`
PoolFree int `json:"pool_free"`
T1Quantity int `json:"t1_quantity"`
AveragePrice float64 `json:"average_price"`
LastPrice float64 `json:"last_price"`
Product string `json:"product"`
CollateralQuantity int `json:"collateral_quantity"`
CollateralValue float64 `json:"collateral_value"`
}
type HoldingsResponse struct {
Status string `json:"status"`
Message string `json:"message,omitempty"`
Data []Holding `json:"data"`
}
type PositionResponse struct {
Status string `json:"status"`
Data NetDayPositions `json:"data"`
}
type NetDayPositions struct {
Net []PositionItem `json:"net"`
Day []PositionItem `json:"day"`
}
type PositionItem struct {
Exchange ExchangeTypes `json:"exchange"`
Symbol string `json:"symbol"`
ExpiryDate string `json:"expiry_date"`
OptionType OptionType `json:"option_type"`
StrikePrice float64 `json:"strike_price"`
Token int `json:"token"`
Product ProductTypes `json:"product"`
Quantity int `json:"quantity"`
OvernightBuyValue float64 `json:"overnight_buy_value"`
OvernightSellValue float64 `json:"overnight_sell_value"`
OvernightAveragePrice float64 `json:"overnight_average_price"`
LotSize int `json:"lot_size"`
Multiplier float64 `json:"multiplier"`
AveragePrice float64 `json:"average_price"`
Value float64 `json:"value"`
BuyValue float64 `json:"buy_value"`
SellValue float64 `json:"sell_value"`
BuyQuantity int `json:"buy_quantity"`
SellQuantity int `json:"sell_quantity"`
BuyPrice float64 `json:"buy_price"`
SellPrice float64 `json:"sell_price"`
}
type ConvertPositionResponse struct {
Status string `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
}
type TradeBookResponse struct {
Status string `json:"status"`
Trades []Trade `json:"trades"`
Metadata struct {
TotalRecords int `json:"total_records"`
} `json:"metadata"`
}
type Resolutions string
const (
ResolutionsMin1 Resolutions = "1"
ResolutionsMin2 Resolutions = "2"
ResolutionsMin3 Resolutions = "3"
ResolutionsMin4 Resolutions = "4"
ResolutionsMin5 Resolutions = "5"
ResolutionsMin10 Resolutions = "10"
ResolutionsMin15 Resolutions = "15"
ResolutionsMin30 Resolutions = "30"
ResolutionsMin45 Resolutions = "45"
ResolutionsMin60 Resolutions = "60"
ResolutionsMin120 Resolutions = "120"
ResolutionsMin180 Resolutions = "180"
ResolutionsMin240 Resolutions = "240"
ResolutionsDay Resolutions = "1D"
ResolutionsWeek Resolutions = "1W"
ResolutionsMonth Resolutions = "1M"
)
type MarginModes string
const (
MarginModeNew MarginModes = "NEW"
MarginModeMODIFY MarginModes = "MODIFY"
)
type QuoteModes string
const (
QuoteModesLTP QuoteModes = "ltp"
QuoteModesFULL QuoteModes = "full"
QuoteModesOHLCV QuoteModes = "ohlcv"
)
type ExchangeTypes string
const (
ExchangeTypesNSEFO ExchangeTypes = "NSE_FO"
ExchangeTypesNSEEQUITY ExchangeTypes = "NSE_EQ"
ExchangeTypesNSECURRENCY ExchangeTypes = "NSE_CD"
ExchangeTypesMCX ExchangeTypes = "MCX_FO"
)
type OrderStatus string
const (
OrderStatusPending OrderStatus = "PENDING"
OrderStausMiddlewarePending OrderStatus = "middleware_pending"
OrderStatusMiddlewareRejected OrderStatus = "middleware_rejected"
OrderStatusRejected OrderStatus = "REJECTED"
OrderStatusCancelled OrderStatus = "CANCELLED"
OrderStatusCompleted OrderStatus = "COMPLETED"
)
type TransactionTypes string
const (
TransactionTypesBUY TransactionTypes = "BUY"
TransactionTypesSELL TransactionTypes = "SELL"
)
type ProductTypes string
const (
ProductTypesIntraday ProductTypes = "INTRADAY"
ProductTypesDelivery ProductTypes = "DELIVERY"
ProductTypesMTF ProductTypes = "MTF"
)
type VarietyTypes string
const (
VarietyTypesRegularLimitOrder VarietyTypes = "RL"
VarietyTypesRegularMarketOrder VarietyTypes = "RL-MKT"
VarietyTypesStopLimitOrder VarietyTypes = "SL"
VarietyTypesStopMarketOrder VarietyTypes = "SL-MKT"
)
type ValidityTypes string
const (
ValidityTypesFullDay ValidityTypes = "DAY"
ValidityTypesImmediateOrCancel ValidityTypes = "IOC"
ValidityTypesAfterMarket ValidityTypes = "AMO"
)
type OrderBookResponse struct {
Status string `json:"status"`
Orders []Order `json:"orders"`
Metadata Metadata `json:"metadata"`
}
type Order struct {
OrderID string `json:"order_id"`
Exchange ExchangeTypes `json:"exchange"`
Token int `json:"token"`
OrderNumber string `json:"order_number"`
Status string `json:"status"`
ErrorReason string `json:"error_reason"`
TransactionType TransactionTypes `json:"transaction_type"`
Product ProductTypes `json:"product"`
Variety VarietyTypes `json:"variety"`
TotalQuantity int `json:"total_quantity"`
PendingQuantity int `json:"pending_quantity"`
TradedQuantity int `json:"traded_quantity"`
DisclosedQuantity int `json:"disclosed_quantity"`
DisclosedQuantityRemaining int `json:"disclosed_quantity_remaining"`
OrderPrice float64 `json:"order_price"`
TriggerPrice float64 `json:"trigger_price"`
TradedPrice float64 `json:"traded_price,omitempty"`
Validity ValidityTypes `json:"validity"`
Symbol string `json:"symbol"`
Series string `json:"series"`
InstrumentName InstrumentName `json:"instrument_name"`
ExpiryDate string `json:"expiry_date"`
StrikePrice float64 `json:"strike_price"`
OptionType OptionType `json:"option_type"`
LotSize int `json:"lot_size"`
OrderCreatedAt string `json:"order_created_at"`
InitiatedBy string `json:"initiated_by"`
ModifiedBy string `json:"modified_by"`
IsAMO bool `json:"is_amo"`
OrderIdentifier string `json:"order_identifier"`
TagsIds pq.Int32Array `json:"tags_ids"`
MiddlewareOrderId uint `json:"middleware_order_id"`
Iceberg *OrderBookIcebergInfo `json:"iceberg,omitempty"`
Gtt *OrderBookGttInfo `json:"gtt,omitempty"`
}
type OrderBookIcebergInfo struct {
IcebergOrderId string `json:"iceberg_order_id"`
IcebergSequence int `json:"iceberg_sequence"`
Legs int `json:"legs"`
}
type OrderBookGttInfo struct {
TriggerType GttTriggerType `json:"trigger_type"`
SlTriggerPercent *float64 `json:"sl_trigger_percent,omitempty"`
ProfitTriggerPercent *float64 `json:"profit_trigger_percent,omitempty"`
}
type LoginResponse struct {
Status string `json:"status"`
Data UserData `json:"data"`
}
type LogoutResponse struct {
Status string `json:"status"`
Response string `json:"response"`
}
type UserData struct {
AccessToken string `json:"access_token"`
UserName string `json:"user_name"`
LoginTime string `json:"login_time"`
Email string `json:"email"`
Mobile string `json:"mobile"`
Exchanges []string `json:"exchanges"`
ProductTypes []string `json:"product_types"`
Others struct {
UserCode string `json:"userCode"`
POA int `json:"POA"`
} `json:"others"`
UserID string `json:"user_id"`
TradingActive bool `json:"tradingActive"`
}
type OrderResponse struct {
Status string `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
Data struct {
OrderID string `json:"order_id"`
} `json:"data"`
}
type Trade struct {
OrderID string `json:"order_id"`
Exchange ExchangeTypes `json:"exchange"`
Token int `json:"token"`
TradeNo string `json:"trade_no"`
ExchangeOrderNo string `json:"exchange_order_no"`
TransactionType TransactionTypes `json:"transaction_type"`
Product ProductTypes `json:"product"`
Variety VarietyTypes `json:"variety"`
TradeQuantity int `json:"trade_quantity"`
TradePrice float64 `json:"trade_price"`
Symbol string `json:"symbol"`
Series string `json:"series"`
InstrumentName string `json:"instrument_name"`
ExpiryDate string `json:"expiry_date"`
StrikePrice float64 `json:"strike_price"`
OptionType OptionType `json:"option_type"`
TradedAt string `json:"traded_at"`
InitiatedBy string `json:"initiated_by"`
ModifiedBy string `json:"modified_by"`
OrderIdentifier string `json:"order_identifier"`
}
const (
Min1 Resolutions = "1"
Min2 Resolutions = "2"
Min3 Resolutions = "3"
Min4 Resolutions = "4"
Min5 Resolutions = "5"
Min10 Resolutions = "10"
Min15 Resolutions = "15"
Min30 Resolutions = "30"
Min45 Resolutions = "45"
Min60 Resolutions = "60"
Min120 Resolutions = "120"
Min180 Resolutions = "180"
Min240 Resolutions = "240"
Day1 Resolutions = "day"
Week1 Resolutions = "week"
Month1 Resolutions = "month"
)
type QuoteDepth struct {
Buy []QuoteEntry `json:"buy"`
Sell []QuoteEntry `json:"sell"`
}
type QuoteEntry struct {
Quantity int `json:"quantity"`
Price float64 `json:"price"`
Orders int `json:"orders"`
}
type MarketDepthResponse struct {
Status string `json:"status"`
Data QuoteDepth `json:"data"`
}
type OrderHistoryResponse struct {
Status string `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
Data []OrderHistory `json:"orders"`
Metadata Metadata `json:"metadata"`
}
type OrderHistory struct {
OrderID string `json:"order_id"`
Exchange ExchangeTypes `json:"exchange"`
Token int `json:"token"`
OrderNumber string `json:"order_number"`
Status string `json:"status"`
ErrorReason string `json:"error_reason"`
TransactionType TransactionTypes `json:"transaction_type"`
Product ProductTypes `json:"product"`
Variety VarietyTypes `json:"variety"`
TotalQuantity int `json:"total_quantity"`
PendingQuantity int `json:"pending_quantity"`
TradedQuantity int `json:"traded_quantity"`
DisclosedQuantity int `json:"disclosed_quantity"`
OrderPrice float64 `json:"order_price"`
TriggerPrice float64 `json:"trigger_price"`
Validity ValidityTypes `json:"validity"`
ValidityDays int `json:"validity_days"`
Symbol string `json:"symbol"`
Series string `json:"series"`
InstrumentName InstrumentName `json:"instrument_name"`
ExpiryDate string `json:"expiry_date"`
StrikePrice float64 `json:"strike_price"`
OptionType OptionType `json:"option_type"`
OrderCreatedAt string `json:"order_created_at"`
ExchangeOrderCreatedAt string `json:"exchange_order_created_at"`
InitiatedBy string `json:"initiated_by"`
ModifiedBy string `json:"modified_by"`
IsAMO bool `json:"is_amo"`
OrderIdentifier string `json:"order_identifier"`
}
type Metadata struct {
TotalRecords int `json:"total_records"`
}
type InstrumentName string
const (
InstrumentNameEqIndex InstrumentName = "EQIDX"
InstrumentNameCom InstrumentName = "COM"
InstrumentNameEquities InstrumentName = "EQUITIES"
InstrumentNameCommodityFuture InstrumentName = "FUTCOM"
InstrumentNameCurrencyFuture InstrumentName = "FUTCUR"
InstrumentNameIndexFuture InstrumentName = "FUTIDX"
InstrumentNameInterestFuture InstrumentName = "FUTIRC"
InstrumentNameInterestFutureT InstrumentName = "FUTIRT"
InstrumentNameStockFuture InstrumentName = "FUTSTK"
InstrumentNameCurrencyOption InstrumentName = "OPTCUR"
InstrumentNameCommodityOption InstrumentName = "OPTFUT"
InstrumentNameIndexOption InstrumentName = "OPTIDX"
InstrumentNameInterestOption InstrumentName = "OPTIRC"
InstrumentNameStockOption InstrumentName = "OPTSTK"
InstrumentNameCurrentcyUnderlying InstrumentName = "UNDCUR"
)
type OptionType string
const (
OptionTypeCall OptionType = "CE"
OptionTypePut OptionType = "PE"
)
type GttOrderbookResponse struct {
Status string `json:"status"`
Data []*GttOrderResponse `json:"data"`
}
type GttOrderResponse struct {
Id string `json:"id"`
Token int `json:"token" binding:"required"`
Exchange ExchangeTypes `json:"exchange" binding:"required"`
Symbol string `json:"symbol" binding:"required"`
Series string `json:"series" binding:"required"`
InstrumentName InstrumentName `json:"instrument_name" binding:"required"`
ExpiryDate string `json:"expiry_date" binding:"required"`
StrikePrice float64 `json:"strike_price" binding:"required"`
OptionType OptionType `json:"option_type" binding:"required"`
LotSize int `json:"lot_size" binding:"required"`
TriggerType GttTriggerType `json:"trigger_type" binding:"required"`
TransactionType TransactionTypes `json:"transaction_type" binding:"required"`
TagIds pq.Int32Array `json:"tag_ids"`
Orders []GttOrderResponseOrders `json:"orders" binding:"required"`
}
type GttOrderResponseOrders struct {
Id uint `json:"id"`
ProductType ProductTypes `json:"product"`
Variety VarietyTypes `json:"variety"`
TransactionType TransactionTypes `json:"transaction_type"`
Price float64 `json:"price"`
TriggerPrice float64 `json:"trigger_price"`
Quantity int `json:"quantity"`
Status GttOrderStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
TrigerredAt time.Time `json:"trigerred_at"`
}
type GttOrderStatus string
const (
GttOrderStatusTriggered GttOrderStatus = "triggered"
GttOrderStatusActive GttOrderStatus = "active"
GttOrderStatusCancelled GttOrderStatus = "cancelled"
GttOrderStatusExpired GttOrderStatus = "expired"
GttOrderStatusCompleted GttOrderStatus = "completed"
)
type FundResponse struct {
Nse ExchangeFundResponse `json:"nse"`
Mcx ExchangeFundResponse `json:"mcx"`
}
type ExchangeFundResponse struct {
Deposit float64 `json:"deposit"`
FundsTransferred float64 `json:"funds_transferred"`
Collateral float64 `json:"collateral"`
CreditForSale float64 `json:"credit_for_sale"`
OptionCreditForSale float64 `json:"option_credit_for_sale"`
LimitUtilization float64 `json:"limit_utilization"`
MtmAndBookedLoss float64 `json:"mtm_and_booked_loss"`
BookedProfit float64 `json:"booked_profit"`
TotalTradingPower float64 `json:"total_trading_power"`
TotalUtilization float64 `json:"total_utilization"`
NetAvailable float64 `json:"net_available"`
FundsWithdrawal float64 `json:"funds_withdrawal"`
}
type FundWithdrawalListResponse struct {
Status string `json:"status"`
Message string `json:"message,omitempty"`
Data []FundWithdrawalItem `json:"data"`
}
type FundWithdrawalItem struct {
TransactionId string `json:"transaction_id"`
Amount float64 `json:"amount"`
CreatedAt time.Time `json:"created_at"`
Status string `json:"status"`
Exchange ExchangeTypes `json:"exchange"`
}
type TagResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data TagInfo `json:"data"`
}
type TagsResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data []TagInfo `json:"data"`
}
type TagInfo struct {
Id int `json:"id"`
ClientCode string `json:"client_code"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type IcebergOrderResponse struct {
Message string `json:"message"`
Code string `json:"code"`
Status string `json:"status"`
Data IcebergOrderData `json:"data"`
}
type CancelIcebergOrderResponse struct {
Message string `json:"message"`
Status string `json:"status"`
}
type IcebergOrderData struct {
IcebergOrderId string `json:"iceberg_order_id"`
FirstOrderId string `json:"first_order_id"`
}
type StrategiesResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data StrategiesResult `json:"data"`
}
type StrategiesResult struct {
Symbol string `json:"symbol"`
Token int `json:"token"`
Ltp float64 `json:"ltp"`
Strategies []Strategy `json:"strategies"`
}
type Strategy struct {
Name string `json:"strategy_name"`
TradingOpportunities []TradingOpportunity `json:"trading_opportunities"`
}
type TradingOpportunity struct {
Legs []StrategyLeg `json:"legs"`
MaxLoss float64 `json:"max_loss"`
MaxProfit float64 `json:"max_profit"`
IsInfiniteProfit bool `json:"is_infinite_profit"`
IsInfiniteLoss bool `json:"is_infinite_loss"`
BreakEven []float64 `json:"breakeven"`
}
type StrategyLeg struct {
Option StrategyStock `json:"option"`
Action string `json:"action"`
Quantity int `json:"quantity"`
}
type StrategyStock struct {
Token int `json:"token"`
InstrumentName string `json:"instrument_name"`
Symbol string `json:"symbol"`
StrikePrice float64 `json:"strike_price"`
OptionType OptionType `json:"option_type"`
LotSize int `json:"lot_size"`
SecurityDesc string `json:"security_description"`
Exchange ExchangeTypes `json:"exchange"`
ExpYyyymmdd string `json:"expiry_date"`
Ltp float64 `json:"ltp"`
Greeks struct {
Theta float64 `json:"theta"`
Delta float64 `json:"delta"`
Gamma float64 `json:"gamma"`
Vega float64 `json:"vega"`
Iv float64 `json:"iv"`
} `json:"greeks"`
}
type OptionChainResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Response OptionchainResult `json:"response"`
}
type OptionchainResult struct {
Symbol string `json:"symbol"`
ExpiryDate string `json:"expiry_date"`
HasParentStock bool `json:"has_parent_stock"`
ExpiryDates []string `json:"expiry_dates"`
Options struct {
Exchange ExchangeTypes `json:"exchange"`
List []*DateOptionData `json:"list"`
} `json:"options"`
ParentStock struct {
Symbol string `json:"symbol"`
Exchange ExchangeTypes `json:"exchange"`
Token int `json:"token"`
ISINCode string `json:"isin"`
LTP float64 `json:"ltp"`
} `json:"parent"`
}
type DateOptionData struct {
StrikePrice float64 `json:"strike_price"`
IV float64 `json:"iv"`
Theta float64 `json:"theta"`
Vega float64 `json:"vega"`
Gamma float64 `json:"gamma"`
CE StockWithGreek `json:"CE"`
PE StockWithGreek `json:"PE"`
}
type StockWithGreek struct {
Token int `json:"token"`
InstrumentName string `json:"instrument_name"`
LotSize int `json:"lot_size"`
SecurityDesc string `json:"security_description"`
Eligibility int `json:"eligibility"`
Ltp float64 `json:"ltp"`
OpenInterest int `json:"open_interest"`
DayFirstTickOI int `json:"day_first_tick_oi" `
Volume int `json:"volume"`
Delta float64 `json:"delta"`
}
type PayoffResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data PayOffData `json:"data"`
}
type PayOffData struct {
MaxLoss float64 `json:"max_loss"`
MaxProfit float64 `json:"max_profit"`
IsInfiniteProfit bool `json:"infinite_profit"`
IsInfiniteLoss bool `json:"infinite_loss"`
BreakEvens []float64 `json:"breakevens"`
PayOffs []PayOff `json:"payoffs"`
CombinedGreeks Greeks `json:"combined_greeks"`
LivePrice float64 `json:"last_trade_price"`
LegStocks []LegStockGreek `json:"leg_greeks"`
MinDaysToExpiry int `json:"min_days_to_expiry"`
}
type LegStockGreek struct {
Token int `json:"token" binding:"required"`
StrikePrice float64 `json:"strike_price"`
OptionType OptionType `json:"option_type"`
ExpYYYYMMDD string `json:"expiry_date"`
Action string `json:"action"`
LotSize int `json:"lot_size"`
Quantity int `json:"quantity"`
Ltp float64 `json:"last_trade_price"` // Update
Iv float64 `json:"iv"` // Update *hide
Greeks Greeks `json:"greeks" gorm:"-"`
}
type Greeks struct {
Theta float64 `json:"theta"`
Delta float64 `json:"delta"`
Gamma float64 `json:"gamma"`
Vega float64 `json:"vega"`
Iv float64 `json:"iv"`
}
type PayOff struct {
IPayoff float64 `json:"intraday_pay_off"`
EPayoff float64 `json:"expiry_pay_off"`
At float64 `json:"at"`
}
type MultipleOrderResponse struct {
Status string `json:"status"`
Data []OrderResponse `json:"data"`
}
type BanksResponse struct {
Status string `json:"status"`
Data ExchangeBankDetails `json:"data"`
}
type ExchangeBankDetails struct {
Nse []BankDetails `json:"nse"`
Mcx []BankDetails `json:"mcx"`
}
type BankDetails struct {
AccountNumber string `json:"account_number"`
Ifsc string `json:"ifsc"`
IsPrimary bool `json:"is_primary"`
AccountType string `json:"account_type"`
BankName string `json:"bank_name"`
}