47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package extrapolation
|
|
|
|
import (
|
|
"fmt"
|
|
"gullion/currency_convert_ssheets/models"
|
|
"gullion/currency_convert_ssheets/timeSeriesDB"
|
|
"gullion/currency_convert_ssheets/utility"
|
|
"time"
|
|
)
|
|
|
|
func ExtrapolateXauToTLForexRates() {
|
|
|
|
usdToTlDatalist := timeSeriesDB.ReadExchangeRecords("USDTL",
|
|
utility.GetTimeFromString("01 Jan 2011"), utility.GetTimeFromString("02 Jan 2015"))
|
|
xauToUsdDatalist := timeSeriesDB.ReadExchangeRecords("XAUUSD",
|
|
utility.GetTimeFromString("01 Dec 2010"), utility.GetTimeFromString("01 Jan 2015"))
|
|
hashMapXauToUSD := make(map[time.Time]models.ExchangeRecord)
|
|
var xauToTl []models.ExchangeRecord
|
|
|
|
for _, recordXauToUSD := range xauToUsdDatalist {
|
|
hashMapXauToUSD[recordXauToUSD.Date] = recordXauToUSD
|
|
}
|
|
|
|
for _, usdTlRecord := range usdToTlDatalist {
|
|
day := usdTlRecord.Date
|
|
for {
|
|
|
|
if _, ok := hashMapXauToUSD[day]; ok {
|
|
break
|
|
}
|
|
day = day.AddDate(0, 0, -1)
|
|
}
|
|
|
|
newRecord := hashMapXauToUSD[day]
|
|
newRecord.Date = usdTlRecord.Date
|
|
newRecord.ToCurrency = usdTlRecord.ToCurrency * newRecord.ToCurrency
|
|
newRecord.Tag = "XAUTL"
|
|
|
|
xauToTl = append(xauToTl, newRecord)
|
|
}
|
|
|
|
exchangeModel := models.ExchangeRecords{ExchangeRecords: xauToTl}
|
|
//timeSeriesDB.WriteExchangeRecords(exchangeModel)
|
|
fmt.Println(exchangeModel)
|
|
|
|
}
|