Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mchapala/AtsCamelV2
base: 4be2a6ed8f
...
head fork: mchapala/AtsCamelV2
compare: b5c9e70aa2
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
7 README.md
@@ -1,4 +1,9 @@
AtsCamel
========
-AtsCamel +
+AtsCamel +
+
+
+
+TODO
+a)
View
38 app/src/main/scala/com/ats/api/model/Account.scala
@@ -1,14 +1,38 @@
package com.ats.api.model
import beans.BeanProperty
+import javax.persistence.{Entity, Table}
+import org.springframework.data.jpa.repository.JpaRepository
+
+
+/**
+ - Account cash balance
+l Currency - Currency string
+l DayTradesRemaining - Number of day trades left
+l EquityWithLoanValue - Equity with Loan Value
+l InitMarginReq - Current initial margin requirement
+l LongOptionValue - Long option value
+l MaintMarginReq - Current maintenance margin
+l NetLiquidation - Net liquidation value
+l OptionMarketValue - Option market value
+l ShortOptionValue - Short option value
+l StockMarketValue - Stock market value
+l UnalteredInitMarginReq - Overnight initial margin requirement
+l UnalteredMaintMarginReq - Overnight maintenance margin requirement
+
+ *
+ *
+ */
+object AccountKey extends Enumeration {
+ type AccountKey = Value
+ val Currency,DayTradesRemaining,EquityWithLoanValue,InitMarginReq,LongOptionValue,MaintMarginReq,NetLiquidation,OptionMarketValue,ShortOptionValue,StockMarketValue,UnalteredInitMarginReq,UnalteredMaintMarginReq= Value
+}
-class Account {
-
+@Entity
+@Table(name = "ACCOUNT")
+class Account extends AbstractEntity{
- /**
- *
- */
var serialVersionUID: Long = 6669464777716480909L;
@BeanProperty
@@ -30,3 +54,7 @@ class Account {
var cash: Double = _;
}
+
+trait AccountRepository extends JpaRepository[Account,java.lang.Long] {
+
+}
View
12 app/src/main/scala/com/ats/api/model/AtsContract.scala
@@ -1,6 +1,7 @@
package com.ats.api.model
import javax.persistence._
+import org.springframework.data.jpa.repository.JpaRepository
// Analogous to Contract object of tws
@@ -12,7 +13,6 @@ class AtsContract() {
@GeneratedValue(strategy = GenerationType.AUTO)
var contract_id:Long=_;
-
@Column(name = "mSymbol")
var mSymbol: String = _;
@@ -55,10 +55,15 @@ class AtsContract() {
var mComboLegs: String = _;
}
+trait AtsContractRepository extends JpaRepository[AtsContract, java.lang.Long] {
+
+
+}
+
object AtsContractUtil {
def makeContract(m_symbol: String, m_secType: String, m_expiry: String, m_strike: java.lang.Double, m_right: String, m_multiplier: String, m_exchange: String, m_currency: String
- , m_localSymbol: String, m_primaryExch: String, m_includeExpired: Boolean, m_comboLegsDescrip: String
- , m_comboLegs:String): AtsContract = {
+ , m_localSymbol: String, m_primaryExch: String, m_includeExpired: Boolean, m_comboLegsDescrip: String
+ , m_comboLegs:String): AtsContract = {
val contract: AtsContract = new AtsContract();
contract.mComboLegs = m_comboLegs;
contract.mComboLegsDescrip = m_comboLegsDescrip;
@@ -76,5 +81,4 @@ object AtsContractUtil {
return contract;
}
-
}
View
74 app/src/main/scala/com/ats/api/model/PortifolioModel.scala
@@ -1,12 +1,78 @@
package com.ats.api.model;
+
+
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.List;
+import java.util.List
+import javax.persistence._
+import scala.beans.BeanProperty
+import scala.Array
+import org.springframework.data.jpa.repository.JpaRepository
+import java.lang.Long
+;
+
+/**
+ * virtual void updatePortfolio(const Contract& contract, int position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, const CString& accountName)
+contract This structure contains a description of the contract which is being traded. The exchange field in a contract is not set for portfolio update.
+position This integer indicates the position on the contract. If the position is 0, it means the position has just cleared.
+marketPrice Unit price of the instrument.
+marketValue The total market value of the instrument.
+averageCost The average cost per share is calculated by dividing your cost (execution price + commission) by the quantity of your position.
+unrealizedPNL The difference between the current market value of your open positions and the average cost, or Value - Average Cost.
+realizedPNL Shows your profit on closed positions, which is the difference between your entry execution cost (execution price + commissions to open the position) and exit execution cost ((execution price + commissions to close the position)
+accountName States the account to which the message applies. Useful for Financial Advisor
+ *
+ *
+ */
+@Entity
+@Table(name = "PORTIFOLIO")
+class Portifolio extends AbstractEntity{
+
+ @OneToMany
+ var portifolioItem:java.util.Set[PortifolioItem]=_;
+}
+
+@Entity
+@Table(name = "PORTIFOLIO_ITEM")
+class PortifolioItem{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ var id: Long = null
+
+
+ @BeanProperty
+ @OneToOne(cascade = Array(CascadeType.DETACH,CascadeType.MERGE,CascadeType.REFRESH),fetch= FetchType.EAGER)
+ @JoinColumn(name = "contract_id")
+ var contract:AtsContract=_;
+
+ @BeanProperty
+ var position:Int=_;
+
+ @BeanProperty
+ var marketPrice:Double=_;
+
+ @BeanProperty
+ var marketValue:Double=_;
+
+ @BeanProperty
+ var averageCost:Double=_;
+
+ @BeanProperty
+ var unrealizedPNL:Double=_;
+
+ @BeanProperty
+ var realizedPNL:Double=_;
+
+ @BeanProperty
+ var accountName:String=_;
+}
-public class PortifolioModel implements Serializable {
- private static final long serialVersionUID = -547060689701573376L;
+trait PortifolioRepository extends JpaRepository[Portifolio,java.lang.Long] {
+}
+trait PortifolioItemRepository extends JpaRepository[PortifolioItem,java.lang.Long] {
-}
+}
View
4 app/src/main/scala/com/ats/api/model/RequestHistoricalData.scala
@@ -3,6 +3,7 @@ package com.ats.api.model
import javax.persistence._
import scala.beans.BeanProperty
+import org.springframework.data.jpa.repository.JpaRepository
/**
@@ -68,5 +69,8 @@ object RequestHistoricalDataUtil {
}
+trait RequestHistoricalDataRepository extends JpaRepository[RequestHistoricalData,java.lang.Long] {
+ def findByContractMSymbol(symbol:String);
+}
View
5 app/src/main/scala/com/ats/api/model/RequestMarketData.scala
@@ -2,6 +2,7 @@ package com.ats.api.model
import javax.persistence._
import scala.beans.BeanProperty
+import org.springframework.data.jpa.repository.JpaRepository
@Entity
@Table(name = "REQUEST_MARKET_DATA")
@@ -22,6 +23,10 @@ class RequestMarketData() extends AbstractEntity {
var snapshot: Boolean = _;
}
+trait RequestMarketDataRepository extends JpaRepository[RequestMarketData,java.lang.Long] {
+ def findByContractMSymbol(symbol:String);
+}
+
object RequestMarketDataUtil {
def makeRequest(contract: AtsContract, tickTypeList: String, snapShot: Boolean): RequestMarketData = {
val request: RequestMarketData = new RequestMarketData()
View
5 app/src/main/scala/com/ats/script/DBScript.scala
@@ -1,10 +1,10 @@
package com.ats.script
import org.springframework.stereotype.Component
-import com.ats.persistence.impl.{RequestHistoricalDataRepository, AtsContractRepository, RequestMarketDataRepository}
+
import org.springframework.beans.factory.annotation.Autowired
-import com.ats.api.model.{RequestHistoricalData,RequestHistoricalDataUtil ,RequestMarketDataUtil, RequestMarketData, AtsContractUtil}
import scala.beans.BeanProperty
+import com.ats.api.model.{RequestMarketDataUtil,RequestMarketData, RequestHistoricalDataUtil,RequestHistoricalDataRepository, AtsContractRepository,AtsContractUtil, RequestMarketDataRepository}
/**
* Created with IntelliJ IDEA.
@@ -52,5 +52,4 @@ class DBScript {
-
}
View
2  app/src/test/scala/AtsRepositoryTest.scala
@@ -1,7 +1,7 @@
import com.ats.api.model._
import com.ats.app.config.spring.AtsSpringDataConfig
-import com.ats.persistence.impl.{RequestHistoricalDataRepository, RequestMarketDataRepository, AtsContractRepository}
+
import com.thoughtworks.xstream.XStream
import org.scalatest.testng.TestNGSuite
View
85 app/src/test/scala/PortifolioRepositoryTest.scala
@@ -1,3 +1,17 @@
+import com.ats.api.model.{AtsContract,AtsContractRepository, PortifolioItem, PortifolioItemRepository, PortifolioRepository}
+import com.ats.app.config.spring.AtsSpringDataConfig
+import java.lang.{Iterable, Long}
+import java.util
+import org.scalatest.testng.TestNGSuite
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.data.domain.{Sort, Page, Pageable}
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.support.AnnotationConfigContextLoader
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests
+import org.springframework.transaction.annotation.Transactional
+import org.testng.annotations.Test
+import scala.beans.BeanProperty
+
/**
* Created with IntelliJ IDEA.
* User: mchapala
@@ -5,6 +19,75 @@
* Time: 11:11 PM
* To change this template use File | Settings | File Templates.
*/
-class PortifolioRepositoryTest {
+
+@ContextConfiguration(loader = classOf[AnnotationConfigContextLoader], classes = Array(classOf[AtsSpringDataConfig]))
+class PortifolioRepositoryTest extends AbstractTestNGSpringContextTests with TestNGSuite {
+
+ @Autowired
+ var repositoryItem: PortifolioItemRepository = _;
+
+ @Autowired
+ var repository: PortifolioRepository = _;
+
+ @Autowired
+ @BeanProperty
+ var contractRepository: AtsContractRepository = _;
+
+
+ @Test
+ //@Transactional
+ def testPortifolioItemAdd() {
+
+ val item: PortifolioItem = new PortifolioItem();
+ val contract: AtsContract = this.contractRepository.findAll().get(0);
+
+ item.setAccountName("DUMMY");
+ item.setAverageCost(100.0);
+ item.setContract(contract);
+ item.setMarketPrice(101.0);
+ item.setMarketValue(10100.10);
+ item.setPosition(100);
+ item.setRealizedPNL(0);
+ item.setUnrealizedPNL(100);
+ this.repositoryItem.saveAndFlush(item);
+ //val port:Portifolio = new Portifolio();
+
+ //this.repository.saveAndFlush();
+ }
+
+ def deleteAll() {}
+
+ def saveAndFlush(entity: PortifolioItem): PortifolioItem = ???
+
+ def deleteInBatch(entities: Iterable[PortifolioItem]) {}
+
+ def deleteAllInBatch() {}
+
+ def findOne(id: Long): PortifolioItem = ???
+
+ def findAll(sort: Sort): util.List[PortifolioItem] = ???
+
+ def findAll(): util.List[PortifolioItem] = ???
+
+ def findAll(pageable: Pageable): Page[PortifolioItem] = ???
+
+ def findAll(ids: Iterable[Long]): Iterable[PortifolioItem] = ???
+
+ def flush() {}
+
+ def delete(entities: Iterable[_ <: PortifolioItem]) {}
+
+ def delete(entity: PortifolioItem) {}
+
+ def delete(id: Long) {}
+
+ def save[S <: PortifolioItem](entities: Iterable[S]): util.List[S] = ???
+
+ def save[S <: PortifolioItem](entity: S): S = ???
+
+ def exists(id: Long): Boolean = ???
+
+
+
}
View
BIN  scripts/APIprintable.pdf
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.