Permalink
Browse files

Added new table hist table

  • Loading branch information...
1 parent 1d8a41c commit daa3d0f6280883235503c933f1981f6df9f9f07e @mchapala committed May 24, 2013
@@ -1,40 +0,0 @@
-package com.ats.api.messages
-
-import reflect.BeanProperty
-
-
-/**
- * Created by IntelliJ IDEA.
- * User: mchapala
- * Date: 2/10/12
- * Time: 9:58 PM
- * To change this template use File | Settings | File Templates.
- */
-
-
-//public synchronized void reqHistoricalData(int tickerId, com.ib.client.Contract contract, java.lang.String endDateTime, java.lang.String durationStr, java.lang.String barSizeSetting, java.lang.String whatToShow, int useRTH, int formatDate) { /* compiled code */ }
-class RequestHistoricalData {
-
- @BeanProperty
- var tickerId: Int = 0;
-
-
- @BeanProperty
- var endDateTimeAsStr: String = "";
-
- @BeanProperty
- var durationStr: String = "";
-
- @BeanProperty
- var barSizeSetting: String = "";
-
- @BeanProperty
- var whatToShow: String = "";
-
-
- @BeanProperty
- var useRTH: Int = 0;
-
- @BeanProperty
- var formatDate: Int = 0;
-}
@@ -0,0 +1,72 @@
+package com.ats.api.model
+
+import reflect.BeanProperty
+import javax.persistence.{Column, OneToMany, Table, Entity}
+import org.springframework.data.jpa.repository.JpaRepository
+
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: mchapala
+ * Date: 2/10/12
+ * Time: 9:58 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+
+//public synchronized void reqHistoricalData(int tickerId, com.ib.client.Contract contract, java.lang.String endDateTime, java.lang.String durationStr, java.lang.String barSizeSetting, java.lang.String whatToShow, int useRTH, int formatDate) { /* compiled code */ }
+
+
+
+@Entity
+@Table(name = "REQUEST_HISTORICAL_DATA")
+class RequestHistoricalData extends AbstractEntity{
+
+ @BeanProperty
+ var contract:AtsContract=_;
+
+ @BeanProperty
+ @Column(name = "endDateTimeAsStr")
+ var endDateTimeAsStr: String = "";
+
+ @BeanProperty
+ @Column(name = "durationStr")
+ var durationStr: String = "";
+
+ @BeanProperty
+ @Column(name = "barSizeSetting")
+ var barSizeSetting: String = "";
+
+ @BeanProperty
+ @Column(name = "whatToShow")
+ var whatToShow: String = "";
+
+ @BeanProperty
+ @Column(name = "useRTH")
+ var useRTH: Int = 0;
+
+ @BeanProperty
+ @Column(name = "formatDate")
+ var formatDate: Int = 0;
+}
+
+
+object RequestHistoricalDataUtil {
+ def makeRequestHistoricalData(contract:AtsContract, endDateTimeAsStr: String, durationStr: String,barSizeSetting: String,whatToShow: String,useRTH: Int,formatDate: Int): RequestHistoricalData = {
+ val request: RequestHistoricalData = new RequestHistoricalData
+ request.contract = contract
+ request.endDateTimeAsStr = endDateTimeAsStr;
+ request.durationStr=durationStr
+ request.barSizeSetting=barSizeSetting
+ request.whatToShow=whatToShow
+ request.useRTH=useRTH
+ request.formatDate=formatDate
+ return request;
+ }
+}
+
+
+trait RequestHistoricalDataRepository extends JpaRepository[RequestHistoricalData,java.lang.Long] {
+ def findByContractMSymbol(symbol:String);
+}
+
@@ -1,18 +1,22 @@
package com.ats.api.model
import javax.persistence._
+import scala.beans.BeanProperty
@Entity
@Table(name = "REQUEST_MARKET_DATA")
class RequestMarketData() extends AbstractEntity {
@OneToMany
+ @BeanProperty
var contract: java.util.Set[AtsContract] = _;
@Column(name = "tickTypeList")
+ @BeanProperty
var tickTypeList: String = _;
@Column(name = "snapshot")
+ @BeanProperty
var snapshot: Boolean = _;
}
@@ -1,7 +1,7 @@
import com.ats.api.model._
import com.ats.app.config.spring.AtsSpringDataConfig
-import com.ats.persistence.impl.{AtsContractRepository, RequestMarketDataRepository}
+import com.ats.persistence.impl.{RequestMarketDataRepository, AtsContractRepository}
import com.thoughtworks.xstream.XStream
import org.scalatest.testng.TestNGSuite
@@ -15,16 +15,17 @@ import scala.Some
@ContextConfiguration(loader = classOf[AnnotationConfigContextLoader], classes = Array(classOf[AtsSpringDataConfig]))
-class AtsContractsRepositoryTest extends AbstractTestNGSpringContextTests with TestNGSuite {
+class AtsRepositoryTest extends AbstractTestNGSpringContextTests with TestNGSuite {
@Autowired
@BeanProperty
- var repository: RequestMarketDataRepository = _;
+ var requestMarketDataRepository: RequestMarketDataRepository = _;
@Autowired
- @BeanProperty
+// @BeanProperty
var contractRepository: AtsContractRepository = _;
+
var marketData:RequestMarketData=_;
@Test(dependsOnGroups = Array("addContract"))
@@ -34,7 +35,7 @@ class AtsContractsRepositoryTest extends AbstractTestNGSpringContextTests with T
val set: java.util.Set[AtsContract] = new java.util.HashSet[AtsContract]();
set.add(contract);
val data: RequestMarketData = RequestMarketDataUtil.makeRequest(set, "100", false);
- marketData = repository.save(data)
+ marketData = requestMarketDataRepository.save(data)
assert(true)
}
@@ -57,19 +58,19 @@ class AtsContractsRepositoryTest extends AbstractTestNGSpringContextTests with T
@Test(groups = Array("deleteSingleContract"),dependsOnGroups = Array("addContract"))
def testDeleteOneRequestMarketData() {
- this.repository.delete(marketData.getId);
+ this.requestMarketDataRepository.delete(marketData.getId);
assert(true)
}
@Test(dependsOnGroups = Array("deleteSingleContract"))
def testDeleteAllRequestMarketData() {
- this.repository.deleteAll();
+ this.requestMarketDataRepository.deleteAll();
assert(true)
}
@Test
def testfindByContractM_symbol(){
- val contracts = repository.findByContractMSymbol("BAC")
+ val contracts = requestMarketDataRepository.findByContractMSymbol("BAC")
logger.debug(new XStream().toXML(contracts));
assert(true)
}

0 comments on commit daa3d0f

Please sign in to comment.