123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package response
- import (
- "encoding/xml"
- "log"
- "time"
- )
- type CommercialInfo struct {
- AggressiveCommissionPerContract float64 `xml:"aggressiveCommissionPerContract"`
- PassiveCommissionPerContract float64 `xml:"passiveCommissionPerContract"`
- FundingPremiumPercentage float64 `xml:"fundingPremiumPercentage"`
- FundingReductionPercentage float64 `xml:"fundingReductionPercentage"`
- FundingBaseRate string `xml:"fundingBaseRate"`
- }
- type Instrument struct {
- Id int64 `xml:"id"`
- Name string `xml:"name"`
- StartTime *time.Time `xml:"-"`
- StartTimeStr string `xml:"startTime"`
- OpenOffset int `xml:"tradingHours>openingOffset"`
- CloseOffset int `xml:"tradingHours>closingOffset"`
- TimeZone string `xml:"tradingHours>timezone"`
- MarginRate float64 `xml:"margin"`
- Currency string `xml:"currency"`
- UnitPrice float64 `xml:"unitPrice"`
- MinimumOrderQuantity float64 `xml:"minimumOrderQuantity"`
- OrderQuantityIncrement float64 `xml:"orderQuantityIncrement"`
- MinimumPrice float64 `xml:"minimumPrice"`
- MaximumPrice float64 `xml:"maximumPrice"`
- TrustedSpread float64 `xml:"trustedSpread"`
- PriceIncrement float64 `xml:"priceIncrement"`
- StopBuffer bool `xml:"stopBuffer"`
- AssetClass string `xml:"assetClass"`
- Isin string `xml:"underlyingIsin"`
- Symbol string `xml:"symbol"`
- MaximumPosition float64 `xml:"maximumPositionThreshold"`
- AggressiveCommissionRate float64 `xml:"aggressiveCommissionRate"`
- PassiveCommissionRate float64 `xml:"passiveCommissionRate"`
- MinimumCommission float64 `xml:"minimumCommission"`
- LongSwapPoints float64 `xml:"longSwapPoints"`
- ShortSwapPoints float64 `xml:"shortSwapPoints"`
- DailyInterestRateBasis int `xml:"dailyInterestRateBasis"`
- UnitOfMeasure string `xml:"contractUnitOfMeasure"`
- ContractSize float64 `xml:"contractSize"`
- TradingDays []string `xml:"tradingDays>tradingDay"`
- VolatilityBandPercentage float64 `xml:"retailVolatilityBandPercentage"`
- }
- type Instruments struct {
- XMLName xml.Name `xml:"res"`
- Header
- Data []*Instrument `xml:"body>instruments>instrument"`
- HasMoreResults bool `xml:"body>hasMoreResults"`
- }
- func NewInstrument(data []byte) *Instrument {
- r := Instrument{}
- err := xml.Unmarshal(data, &r)
- if err != nil {
- log.Println(err)
- return nil
- }
- t , err := time.Parse("2006-01-02T15:04:05", r.StartTimeStr)
- if err != nil {
- log.Println(err)
- return nil
- }
- r.StartTime = &t
- r.MarginRate = r.MarginRate / 100
- return &r
- }
- func NewInstruments(data string) *Instruments {
- r := Instruments{}
- err := xml.Unmarshal([]byte(data), &r)
- if err != nil {
- log.Println(err)
- return nil
- }
- for i := 0; i < len(r.Data); i++ {
- t , err := time.Parse("2006-01-02T15:04:05", r.Data[i].StartTimeStr)
- if err != nil {
- log.Println(err)
- return nil
- }
- r.Data[i].StartTime = &t
- r.Data[i].MarginRate = r.Data[i].MarginRate / 100
- }
- return &r
- }
- type ExchangeRateEvent struct {
- XMLName xml.Name `xml:"exchangeRate"`
- From string `xml:"from"`
- To string `xml:"to"`
- Buy float64 `xml:"buy"`
- Sell float64 `xml:"sell"`
- Wallet float64 `xml:"-"`
- }
- func NewExchangeRateEvent(data string) *ExchangeRateEvent {
- r := &ExchangeRateEvent{}
- err := xml.Unmarshal([]byte(data), r)
- if err != nil {
- return nil
- }
- return r
- }
|