Skip to content

Commit

Permalink
Implement TradeStation API (new Lean Plugin) (#1)
Browse files Browse the repository at this point in the history
* remove: template ref to another project

* rename: templateBrokerage to TradeStationBrokerage

* refactor: templates proj toTradStation ones

* rename: template to TradeStationBrokerage
feat: add ref lean test

* fix: encoding of csproj

* feat: getSignUrl on 0Auth

* feat: AccessToken and RefreshToken 0Auth

* feat: getAccount to get balance per each

* refactor: RefreshAccessToken in ApiClient

* feat: GetAllAccountBalances

* feat: IBrokerage => GetCashBalance

* refactor: pull out of TradeSationError struct

* feat: IBrokerage => GetAccountHoldings

* feat: support of prxoy for TradeStationApiClient

* refactor: additional tests

* feat: xml description to several variables

* feat: RetrieveOrdersForAllAccount

* test:fix: template constructor

* refactor: TradeStationOrder several properties

* refactor: new description several order status

* feat: TradeStationSymbolMapper GetLeanSymbol()

* feat: IBrokerage -> GetOpenOrders
feat: convert extensions

* refactor: TSApi requested uri

* feat:todo: Symbol in GetAccountHolding

* feat: IBrokerage -> CancelOrder

* feat: caching account request

* feat: collection of supported security types

* feat: GetBrokerageSymbol + test

* feat: PlaceOrder

* feat: SerializeSetting in ApiClient

* feat: IBrokerage -> UpdateOrder

* feat: param of prxoy in brokerage class

* feat: update RestSharp version
refactor: update code base to new -v RestSharp

* rename: TemplateBrokerage to TradeStation

* remove: TradeStationExchangeInfoDownloader

* remove: TradeStationExchangeInfoDownloader from Program

* revert: use new version of RestSharp

* refactor: RestSharp to HttpClient

* remove: extra custom converter

* remove: not used part of code

* feat: handle order event

* refactor: brokerage connection process

* remove: not used code

* remove: not used code

* feat: wrap  subscribe order event in while

* feat: ValidateSubscription()

* remove: repeat securityType in collection

* feat: use future code from Lean

* feat: add Trade Station Account Type in config

* missed: ref proj on Lean.Common in solution

* feat: description in API RequestAsync

* fix: missed init of global test params

* fix: GetAccountHoldings() for different account
feat: parsing option symbol in poistion + test

* refactor: deserialize wrong http response

* refactor: Quantity in GetAccountHoldings

* feat: support TradeStationOrderProperty
feat: rejected message in handleOrderEvent
feat: different position side for Option orders

* feat: pass OrderProperty in PlaceOrder()

* feat: pull out redirect url in config file

* remove: not used test

* feat: TradeStationBrokerageFactory

* feat: github action

* fix: autorization header

* feat: LookupSymbols

* feat: getQuote()

* refactor: placeOrder

* feat: handle error of an existing position.

* rename: TradeStationOrderResponse entity

* feat: implement Brokerage CrossZero logic

* fix: holding quantity sign

* refactor: PlaceOrder depend on holding quantity
feat: use DirectionOfOrder in PlaceOrder
feat: try take order again if it was cross
fix: orderEvent quantity sign
feat: use TryHandleEvent of CrossZeroOrder
feat: clean cached of second part of CrossZeroOrder
fix: stop price of StopLimitOrder in Test
feat: increase delay of placiing order when crossing (because TradeStationBrokerage has delay)

* feat: ConcurrentMessagveHandler of Order Events
feat: lock Place/Update Order
refactor: UpdateTradeStationOrder
feat: vlidate specific tradestation error codesa
feat: temp cache for quantity
feat: util to validate right side of order's brokerage
feat: implement TryGetOrRemoveCrossZeroOrder
fix: test input data

* remove: temp cache ofr order Quantity
refactor: UpdateOrder
feat: handle case of OrderStatus
feat:test: new tests parameters

* feat: Validate of CorssZeroOrder in UpdateOrder
fix: use wrong OrderStatus for canceled order
feat: write specific test case to update order

* refactor: UpdateCrossZeroOrder take specific quantity
refactor: ReplaceOrder API endpoint

* feat: use accountID preload process
refactor: use leanOrder status internally
fix: comment in tests
remove: attribute explicit in several tests

* feat: TradeStation ActionType to enum instead of string
carry_out: OptionStrire model to models folder
refactor: IsShort and Direction to extension and carry out from main class
feat: desirialize ActionType string to enum with diifferent case

* refactor: get rid getStop/Limit price by LenaOrder

* remove: duplication code of PlaceOrder in TradeStation API

* fix: github workflow file

* fix: type param in entity
feat: Option test cases

* feat: add TradeStation.json

* feat: test cases fro SecurityType.Future
fix: Convert OrderDirection of TradeStation on SecurityType.Future

* feat: additional property in TradeStation Factory

* refactor: CrossZeroOrder implementation

* feat: Add Lean.Common project in sln

* remove: PROXY implementation

* refactor: Convert OrderDirection extension

* refactor: AccountId and AccountType
feat: extension parse AccountType

* refactor: change access modifier of GetQuote()

* refactor: use error generic interface for error

* remove: IDataQueueUniverseProvider

* remove: duplication of code PlaceOrder

* remove: extra proxy

* remove: hardcoded orders error codes

* feat: increase AutoResetEvent wait handle time

* fix: log parameters

* feat: use _isSubscribeOnStreamOrderUpdate flag explicitly

* feat: additional log on subscribe on order updates
feat: cancellation token for subscribe on order updates
refactor: description on method

* feat: add missed support asset in json config

* feat: explicit attribute for SecurityType.Future tests
remove: not used using`
  • Loading branch information
Romazes authored Jul 2, 2024
1 parent dea5b60 commit 1ab42af
Show file tree
Hide file tree
Showing 51 changed files with 5,170 additions and 1,032 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/gh-actions.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Build & Test
name: Trade Station Build & Test

on:
push:
branches: ['*']
branches: ["*"]

jobs:
build:
runs-on: ubuntu-20.04
env:
QC_TEMPLATE_BROKERAGE_KEY: ${{ secrets.QC_TEMPLATE_BROKERAGE_KEY }}
QC_TEMPLATE_BROKERAGE_SECRET: ${{ secrets.QC_TEMPLATE_BROKERAGE_SECRET }}
QC_TRADE_STATION_API_KEY: ${{ secrets.QC_TRADE_STATION_API_KEY }}
QC_TRADE_STATION_API_SECRET: ${{ secrets.QC_TRADE_STATION_API_SECRET }}
QC_TRADE_STATION_ACCOUNT_TYPE: ${{ secrets.QC_TRADE_STATION_ACCOUNT_TYPE }}
QC_TRADE_STATION_REFRESH_TOKEN: ${{ secrets.QC_TRADE_STATION_REFRESH_TOKEN }}
QC_JOB_USER_ID: ${{ secrets.QC_JOB_USER_ID }}
QC_API_ACCESS_TOKEN: ${{ secrets.QC_API_ACCESS_TOKEN }}
QC_JOB_ORGANIZATION_ID: ${{ secrets.QC_JOB_ORGANIZATION_ID }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -19,7 +24,7 @@ jobs:
- uses: addnab/docker-run-action@v3
with:
image: quantconnect/lean:foundation
options: --workdir /__w/Lean.Brokerages.Template/Lean.Brokerages.Template -v /home/runner/work:/__w -e QC_TEMPLATE_BROKERAGE_KEY=${{ secrets.QC_TEMPLATE_BROKERAGE_KEY }} -e QC_TEMPLATE_BROKERAGE_SECRET=${{ secrets.QC_TEMPLATE_BROKERAGE_SECRET }} -e QC_JOB_USER_ID=${{ secrets.QC_JOB_USER_ID }} -e QC_API_ACCESS_TOKEN=${{ secrets.QC_API_ACCESS_TOKEN }} -e QC_JOB_ORGANIZATION_ID=${{ secrets.QC_JOB_ORGANIZATION_ID }}
options: --workdir /__w/Lean.Brokerages.TradeStation/Lean.Brokerages.TradeStation -v /home/runner/work:/__w -e QC_TRADE_STATION_API_KEY=${{ env.QC_TRADE_STATION_API_KEY }} -e QC_TRADE_STATION_API_SECRET=${{ env.QC_TRADE_STATION_API_SECRET }} -e QC_TRADE_STATION_ACCOUNT_TYPE=${{ env.QC_TRADE_STATION_ACCOUNT_TYPE }} -e QC_TRADE_STATION_REFRESH_TOKEN=${{ env.QC_TRADE_STATION_REFRESH_TOKEN }} -e QC_JOB_USER_ID=${{ env.QC_JOB_USER_ID }} -e QC_API_ACCESS_TOKEN=${{ env.QC_API_ACCESS_TOKEN }} -e QC_JOB_ORGANIZATION_ID=${{ env.QC_JOB_ORGANIZATION_ID }}

- name: Checkout Lean Same Branch
id: lean-same-branch
Expand All @@ -40,8 +45,8 @@ jobs:
- name: Move Lean
run: mv Lean ../Lean

- name: Build
run: dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.TemplateBrokerage.sln
- name: Build Trade Station Solution
run: dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.TradeStationBrokerage.sln

- name: Run Tests
run: dotnet test ./QuantConnect.TemplateBrokerage.Tests/bin/Release/QuantConnect.Brokerages.Template.Tests.dll
- name: Run Trade Station Tests
run: dotnet test ./QuantConnect.TradeStationBrokerage.Tests/bin/Release/QuantConnect.Brokerages.TradeStation.Tests.dll

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1ab42af

Please sign in to comment.